Added: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/taggedpdf/PDTableAttributeObject.java URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/taggedpdf/PDTableAttributeObject.java?rev=932448&view=auto ============================================================================== --- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/taggedpdf/PDTableAttributeObject.java (added) +++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/taggedpdf/PDTableAttributeObject.java Fri Apr 9 15:02:03 2010 @@ -0,0 +1,222 @@ +/* + * 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.apache.pdfbox.pdmodel.documentinterchange.taggedpdf; + +import org.apache.pdfbox.cos.COSDictionary; +import org.apache.pdfbox.pdmodel.documentinterchange.logicalstructure.PDStructureElement; + +/** + * A Table attribute object. + * + * @author <a href="mailto:johannes%20koch%20%[email protected]%3e">Johannes Koch</a> + * @version $Revision: $ + */ +public class PDTableAttributeObject extends PDStandardAttributeObject +{ + + /** + * standard attribute owner: Table + */ + public static final String OWNER_TABLE = "Table"; + + protected static final String ROW_SPAN = "RowSpan"; + protected static final String COL_SPAN = "ColSpan"; + protected static final String HEADERS = "Headers"; + protected static final String SCOPE = "Scope"; + protected static final String SUMMARY = "Summary"; + + /** + * Scope: Both + */ + public static final String SCOPE_BOTH = "Both"; + /** + * Scope: Column + */ + public static final String SCOPE_COLUMN = "Column"; + /** + * Scope: Row + */ + public static final String SCOPE_ROW = "Row"; + + + /** + * Default constructor. + */ + public PDTableAttributeObject() + { + this.setOwner(OWNER_TABLE); + } + + /** + * Creates a new Table attribute object with a given dictionary. + * + * @param dictionary the dictionary + */ + public PDTableAttributeObject(COSDictionary dictionary) + { + super(dictionary); + } + + + /** + * Gets the number of rows in the enclosing table that shall be spanned by + * the cell (RowSpan). The default value is 1. + * + * @return the row span + */ + public int getRowSpan() + { + return this.getInteger(ROW_SPAN, 1); + } + + /** + * Sets the number of rows in the enclosing table that shall be spanned by + * the cell (RowSpan). + * + * @param rowSpan the row span + */ + public void setRowSpan(int rowSpan) + { + this.setInteger(ROW_SPAN, rowSpan); + } + + /** + * Gets the number of columns in the enclosing table that shall be spanned + * by the cell (ColSpan). The default value is 1. + * + * @return the column span + */ + public int getColSpan() + { + return this.getInteger(COL_SPAN, 1); + } + + /** + * Sets the number of columns in the enclosing table that shall be spanned + * by the cell (ColSpan). + * + * @param colSpan the column span + */ + public void setColSpan(int colSpan) + { + this.setInteger(COL_SPAN, colSpan); + } + + /** + * Gets the headers (Headers). An array of byte strings, where each string + * shall be the element identifier (see the + * {...@link PDStructureElement#getElementIdentifier()}) for a TH structure + * element that shall be used as a header associated with this cell. + * + * @return the headers. + */ + public String[] getHeaders() + { + return this.getArrayOfString(HEADERS); + } + + /** + * Sets the headers (Headers). An array of byte strings, where each string + * shall be the element identifier (see the + * {...@link PDStructureElement#getElementIdentifier()}) for a TH structure + * element that shall be used as a header associated with this cell. + * + * @param headers the headers + */ + public void setHeaders(String[] headers) + { + this.setArrayOfString(HEADERS, headers); + } + + /** + * Gets the scope (Scope). It shall reflect whether the header cell applies + * to the rest of the cells in the row that contains it, the column that + * contains it, or both the row and the column that contain it. + * + * @return the scope + */ + public String getScope() + { + return this.getName(SCOPE); + } + + /** + * Sets the scope (Scope). It shall reflect whether the header cell applies + * to the rest of the cells in the row that contains it, the column that + * contains it, or both the row and the column that contain it. The value + * shall be one of the following: + * <ul> + * <li>{...@link #SCOPE_ROW},</li> + * <li>{...@link #SCOPE_COLUMN}, or</li> + * <li>{...@link #SCOPE_BOTH}.</li> + * </ul> + * + * @param scope the scope + */ + public void setScope(String scope) + { + this.setName(SCOPE, scope); + } + + /** + * Gets the summary of the tableâs purpose and structure. + * + * @return the summary + */ + public String getSummary() + { + return this.getString(SUMMARY); + } + + /** + * Sets the summary of the tableâs purpose and structure. + * + * @param summary the summary + */ + public void setSummary(String summary) + { + this.setString(SUMMARY, summary); + } + + @Override + public String toString() + { + StringBuilder sb = new StringBuilder().append(super.toString()); + if (this.isSpecified(ROW_SPAN)) + { + sb.append(", RowSpan=").append(String.valueOf(this.getRowSpan())); + } + if (this.isSpecified(COL_SPAN)) + { + sb.append(", ColSpan=").append(String.valueOf(this.getColSpan())); + } + if (this.isSpecified(HEADERS)) + { + sb.append(", Headers=").append(arrayToString(this.getHeaders())); + } + if (this.isSpecified(SCOPE)) + { + sb.append(", Scope=").append(this.getScope()); + } + if (this.isSpecified(SUMMARY)) + { + sb.append(", Summary=").append(this.getSummary()); + } + return sb.toString(); + } + +}
Added: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/taggedpdf/StandardStructureTypes.java URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/taggedpdf/StandardStructureTypes.java?rev=932448&view=auto ============================================================================== --- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/taggedpdf/StandardStructureTypes.java (added) +++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/taggedpdf/StandardStructureTypes.java Fri Apr 9 15:02:03 2010 @@ -0,0 +1,320 @@ +/* + * 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.apache.pdfbox.pdmodel.documentinterchange.taggedpdf; + +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * The standard structure types. + * + * @author <a href="mailto:johannes%20koch%20%[email protected]%3e">Johannes Koch</a> + * @version $Revision: $ + */ +public class StandardStructureTypes +{ + + private StandardStructureTypes() + { + } + + + // Grouping Elements + /** + * Document + */ + public static final String DOCUMENT = "Document"; + + /** + * Part + */ + public static final String PART = "Part"; + + /** + * Art + */ + public static final String ART = "Art"; + + /** + * Sect + */ + public static final String SECT = "Sect"; + + /** + * Div + */ + public static final String DIV = "Div"; + + /** + * BlockQuote + */ + public static final String BLOCK_QUOTE = "BlockQuote"; + + /** + * Caption + */ + public static final String CAPTION = "Caption"; + + /** + * TOC + */ + public static final String TOC = "TOC"; + + /** + * TOCI + */ + public static final String TOCI = "TOCI"; + + /** + * Index + */ + public static final String INDEX = "Index"; + + /** + * NonStruct + */ + public static final String NON_STRUCT = "NonStruct"; + + /** + * Private + */ + public static final String PRIVATE = "Private"; + + + // Block-Level Structure Elements + /** + * P + */ + public static final String P = "P"; + + /** + * H + */ + public static final String H = "H"; + + /** + * H1 + */ + public static final String H1 = "H1"; + + /** + * H2 + */ + public static final String H2 = "H2"; + + /** + * H3 + */ + public static final String H3 = "H3"; + + /** + * H4 + */ + public static final String H4 = "H4"; + + /** + * H5 + */ + public static final String H5 = "H5"; + + /** + * H6 + */ + public static final String H6 = "H6"; + + /** + * L + */ + public static final String L = "L"; + + /** + * LI + */ + public static final String LI = "LI"; + + /** + * Lbl + */ + public static final String LBL = "Lbl"; + + /** + * LBody + */ + public static final String L_BODY = "LBody"; + + /** + * Table + */ + public static final String TABLE = "Table"; + + /** + * TR + */ + public static final String TR = "TR"; + + /** + * TH + */ + public static final String TH = "TH"; + + /** + * TD + */ + public static final String TD = "TD"; + + /** + * THead + */ + public static final String T_HEAD = "THead"; + + /** + * TBody + */ + public static final String T_BODY = "TBody"; + + /** + * TFoot + */ + public static final String T_FOOT = "TFoot"; + + + // Inline-Level Structure Elements + /** + * Span + */ + public static final String SPAN = "Span"; + + /** + * Quote + */ + public static final String QUOTE = "Quote"; + + /** + * Note + */ + public static final String NOTE = "Note"; + + /** + * Reference + */ + public static final String REFERENCE = "Reference"; + + /** + * BibEntry + */ + public static final String BIB_ENTRY = "BibEntry"; + + /** + * Code + */ + public static final String CODE = "Code"; + + /** + * Link + */ + public static final String LINK = "Link"; + + /** + * Annot + */ + public static final String ANNOT = "Annot"; + + /** + * Ruby + */ + public static final String RUBY = "Ruby"; + + /** + * RB + */ + public static final String RB = "RB"; + + /** + * RT + */ + public static final String RT = "RT"; + + /** + * RP + */ + public static final String RP = "RP"; + + /** + * Warichu + */ + public static final String WARICHU = "Warichu"; + + /** + * WT + */ + public static final String WT = "WT"; + + /** + * WP + */ + public static final String WP = "WP"; + + + // Illustration Elements + /** + * Figure + */ + public static final String Figure = "Figure"; + + /** + * Formula + */ + public static final String FORMULA = "Formula"; + + /** + * Form + */ + public static final String FORM = "Form"; + + /** + * All standard structure types. + */ + public static List<String> types = new ArrayList<String>(); + + static + { + Field[] fields = StandardStructureTypes.class.getFields(); + for (int i = 0; i < fields.length; i++) + { + if (Modifier.isFinal(fields[i].getModifiers())) + { + try + { + types.add(fields[i].get(null).toString()); + } + catch (IllegalArgumentException e) + { + e.printStackTrace(); + } + catch (IllegalAccessException e) + { + e.printStackTrace(); + } + } + } + Collections.sort(types); + } + +} Added: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/taggedpdf/package.html URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/taggedpdf/package.html?rev=932448&view=auto ============================================================================== --- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/taggedpdf/package.html (added) +++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/taggedpdf/package.html Fri Apr 9 15:02:03 2010 @@ -0,0 +1,26 @@ +<!-- + ! 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. + !--> +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> +<head> + +</head> +<body> +The tagged PDF package provides a mechanism for incorporating "tags" (standard +structure types and attributes) into a PDF file. +</body> +</html>
