Java Code Examples for org.apache.pdfbox.cos.COSDictionary#getNameAsString()
The following examples show how to use
org.apache.pdfbox.cos.COSDictionary#getNameAsString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PDStructureNode.java From gcs with Mozilla Public License 2.0 | 6 votes |
private COSObjectable createObjectFromDic(COSDictionary kidDic) { String type = kidDic.getNameAsString(COSName.TYPE); if ((type == null) || PDStructureElement.TYPE.equals(type)) { // A structure element dictionary denoting another structure element return new PDStructureElement(kidDic); } else if (PDObjectReference.TYPE.equals(type)) { // An object reference dictionary denoting a PDF object return new PDObjectReference(kidDic); } else if (PDMarkedContentReference.TYPE.equals(type)) { // A marked-content reference dictionary denoting a marked-content sequence return new PDMarkedContentReference(kidDic); } return null; }
Example 2
Source File: PDStructureNode.java From gcs with Mozilla Public License 2.0 | 5 votes |
/** * Creates a node in the structure tree. Can be either a structure tree root, * or a structure element. * * @param node the node dictionary * @return the structure node */ public static PDStructureNode create(COSDictionary node) { String type = node.getNameAsString(COSName.TYPE); if ("StructTreeRoot".equals(type)) { return new PDStructureTreeRoot(node); } if (type == null || "StructElem".equals(type)) { return new PDStructureElement(node); } throw new IllegalArgumentException("Dictionary must not include a Type entry with a value that is neither StructTreeRoot nor StructElem."); }
Example 3
Source File: PDAttributeObject.java From gcs with Mozilla Public License 2.0 | 5 votes |
/** * Creates an attribute object. * * @param dictionary the dictionary * @return the attribute object */ public static PDAttributeObject create(COSDictionary dictionary) { String owner = dictionary.getNameAsString(COSName.O); if (PDUserAttributeObject.OWNER_USER_PROPERTIES.equals(owner)) { return new PDUserAttributeObject(dictionary); } else if (PDListAttributeObject.OWNER_LIST.equals(owner)) { return new PDListAttributeObject(dictionary); } else if (PDPrintFieldAttributeObject.OWNER_PRINT_FIELD.equals(owner)) { return new PDPrintFieldAttributeObject(dictionary); } else if (PDTableAttributeObject.OWNER_TABLE.equals(owner)) { return new PDTableAttributeObject(dictionary); } else if (PDLayoutAttributeObject.OWNER_LAYOUT.equals(owner)) { return new PDLayoutAttributeObject(dictionary); } else if (PDExportFormatAttributeObject.OWNER_XML_1_00.equals(owner) || PDExportFormatAttributeObject.OWNER_HTML_3_20.equals(owner) || PDExportFormatAttributeObject.OWNER_HTML_4_01.equals(owner) || PDExportFormatAttributeObject.OWNER_OEB_1_00.equals(owner) || PDExportFormatAttributeObject.OWNER_RTF_1_05.equals(owner) || PDExportFormatAttributeObject.OWNER_CSS_1_00.equals(owner) || PDExportFormatAttributeObject.OWNER_CSS_2_00.equals(owner)) { return new PDExportFormatAttributeObject(dictionary); } return new PDDefaultAttributeObject(dictionary); }
Example 4
Source File: PDFieldFactory.java From gcs with Mozilla Public License 2.0 | 5 votes |
private static String findFieldType(COSDictionary dic) { String retval = dic.getNameAsString(COSName.FT); if (retval == null) { COSBase base = dic.getDictionaryObject(COSName.PARENT, COSName.P); if (base instanceof COSDictionary) { retval = findFieldType((COSDictionary) base); } } return retval; }
Example 5
Source File: PDAnnotation.java From gcs with Mozilla Public License 2.0 | 4 votes |
/** * Create the correct annotation from the base COS object. * * @param base The COS object that is the annotation. * @return The correctly typed annotation object. * * @throws IOException If the annotation type is unknown. */ public static PDAnnotation createAnnotation(COSBase base) throws IOException { PDAnnotation annot = null; if (base instanceof COSDictionary) { COSDictionary annotDic = (COSDictionary) base; String subtype = annotDic.getNameAsString(COSName.SUBTYPE); if (PDAnnotationFileAttachment.SUB_TYPE.equals(subtype)) { annot = new PDAnnotationFileAttachment(annotDic); } else if (PDAnnotationLine.SUB_TYPE.equals(subtype)) { annot = new PDAnnotationLine(annotDic); } else if (PDAnnotationLink.SUB_TYPE.equals(subtype)) { annot = new PDAnnotationLink(annotDic); } else if (PDAnnotationPopup.SUB_TYPE.equals(subtype)) { annot = new PDAnnotationPopup(annotDic); } else if (PDAnnotationRubberStamp.SUB_TYPE.equals(subtype)) { annot = new PDAnnotationRubberStamp(annotDic); } else if (PDAnnotationSquareCircle.SUB_TYPE_SQUARE.equals(subtype) || PDAnnotationSquareCircle.SUB_TYPE_CIRCLE.equals(subtype)) { annot = new PDAnnotationSquareCircle(annotDic); } else if (PDAnnotationText.SUB_TYPE.equals(subtype)) { annot = new PDAnnotationText(annotDic); } else if (PDAnnotationTextMarkup.SUB_TYPE_HIGHLIGHT.equals(subtype) || PDAnnotationTextMarkup.SUB_TYPE_UNDERLINE.equals(subtype) || PDAnnotationTextMarkup.SUB_TYPE_SQUIGGLY.equals(subtype) || PDAnnotationTextMarkup.SUB_TYPE_STRIKEOUT.equals(subtype)) { // see 12.5.6.10 Text Markup Annotations annot = new PDAnnotationTextMarkup(annotDic); } else if (PDAnnotationWidget.SUB_TYPE.equals(subtype)) { annot = new PDAnnotationWidget(annotDic); } else if (PDAnnotationMarkup.SUB_TYPE_FREETEXT.equals(subtype) || PDAnnotationMarkup.SUB_TYPE_POLYGON.equals(subtype) || PDAnnotationMarkup.SUB_TYPE_POLYLINE.equals(subtype) || PDAnnotationMarkup.SUB_TYPE_CARET.equals(subtype) || PDAnnotationMarkup.SUB_TYPE_INK.equals(subtype) || PDAnnotationMarkup.SUB_TYPE_SOUND.equals(subtype)) { annot = new PDAnnotationMarkup(annotDic); } else { // TODO not yet implemented: // Movie, Screen, PrinterMark, TrapNet, Watermark, 3D, Redact annot = new PDAnnotationUnknown(annotDic); LOG.debug("Unknown or unsupported annotation subtype " + subtype); } } else { throw new IOException("Error: Unknown annotation type " + base); } return annot; }
Example 6
Source File: PDActionFactory.java From gcs with Mozilla Public License 2.0 | 4 votes |
/** * This will create the correct type of action based on the type specified * in the dictionary. * * @param action An action dictionary. * * @return An action of the correct type. */ public static PDAction createAction( COSDictionary action ) { PDAction retval = null; if( action != null ) { String type = action.getNameAsString( COSName.S ); if( PDActionJavaScript.SUB_TYPE.equals( type ) ) { retval = new PDActionJavaScript( action ); } else if( PDActionGoTo.SUB_TYPE.equals( type ) ) { retval = new PDActionGoTo( action ); } else if( PDActionLaunch.SUB_TYPE.equals( type ) ) { retval = new PDActionLaunch( action ); } else if( PDActionRemoteGoTo.SUB_TYPE.equals( type ) ) { retval = new PDActionRemoteGoTo( action ); } else if( PDActionURI.SUB_TYPE.equals( type ) ) { retval = new PDActionURI( action ); } else if (PDActionNamed.SUB_TYPE.equals(type)) { retval = new PDActionNamed(action); } else if (PDActionSound.SUB_TYPE.equals(type)) { retval = new PDActionSound(action); } else if (PDActionMovie.SUB_TYPE.equals(type)) { retval = new PDActionMovie(action); } else if (PDActionImportData.SUB_TYPE.equals(type)) { retval = new PDActionImportData(action); } else if (PDActionResetForm.SUB_TYPE.equals(type)) { retval = new PDActionResetForm(action); } else if (PDActionHide.SUB_TYPE.equals(type)) { retval = new PDActionHide(action); } else if (PDActionSubmitForm.SUB_TYPE.equals(type)) { retval = new PDActionSubmitForm(action); } else if (PDActionThread.SUB_TYPE.equals(type)) { retval = new PDActionThread(action); } else if (PDActionEmbeddedGoTo.SUB_TYPE.equals(type)) { retval = new PDActionEmbeddedGoTo(action); } } return retval; }