Skip to content

Commit

Permalink
Implements Page "/Tabs" getter/setters
Browse files Browse the repository at this point in the history
  • Loading branch information
ediweissmann committed Jan 13, 2025
1 parent 970a0db commit 0a7aa54
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/main/java/org/sejda/sambox/cos/COSName.java
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,7 @@ public final class COSName extends COSBase implements Comparable<COSName>
public static final COSName SW = newCommonInstance("SW");
// T
public static final COSName T = newCommonInstance("T");
public static final COSName Tabs = newCommonInstance("Tabs");
public static final COSName TARGET = newCommonInstance("Target");
public static final COSName TEMPLATES = newCommonInstance("Templates");
public static final COSName THREADS = newCommonInstance("Threads");
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/org/sejda/sambox/pdmodel/PDPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import org.sejda.sambox.pdmodel.interactive.action.PDPageAdditionalActions;
import org.sejda.sambox.pdmodel.interactive.annotation.AnnotationFilter;
import org.sejda.sambox.pdmodel.interactive.annotation.PDAnnotation;
import org.sejda.sambox.pdmodel.interactive.form.Tabs;
import org.sejda.sambox.pdmodel.interactive.measurement.PDViewportDictionary;
import org.sejda.sambox.pdmodel.interactive.pagenavigation.PDThreadBead;
import org.sejda.sambox.pdmodel.interactive.pagenavigation.PDTransition;
Expand Down Expand Up @@ -938,4 +939,20 @@ public COSDictionary getPageTreeParent()
{
return pageTreeParent;
}

public Tabs getTabs()
{
return Tabs.fromString(page.getString(COSName.Tabs));
}

public void setTabs(Tabs value)
{
if (value == null)
{
page.removeItem(COSName.Tabs);
return;
}

page.setString(COSName.Tabs, value.stringValue());
}
}
53 changes: 53 additions & 0 deletions src/main/java/org/sejda/sambox/pdmodel/interactive/form/Tabs.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.sejda.sambox.pdmodel.interactive.form;

public enum Tabs {
ROW_ORDER("R"),
COLUMN_ORDER("C"),
STRUCTURE_ORDER("S");

public static Tabs fromString(String value)
{
if (value == null)
{
return null;
}

for (Tabs instance : Tabs.values())
{
if (instance.value.equals(value))
{
return instance;
}
}

return null;
}

private final String value;

Tabs(String value)
{
this.value = value;
}

public String stringValue()
{
return value;
}
}

0 comments on commit 0a7aa54

Please sign in to comment.