/** * Gets the XMP Metadata object. * * @return {@link PdfStream} object, that represent XMP Metadata. */ public PdfStream getXmpMetadata() { return getPdfObject().getAsStream(PdfName.Metadata); }
public PdfStream getRedactRolloverAppearance() { return getPdfObject().getAsStream(PdfName.RO); }
public PdfStream getDestOutputProfile() { return getPdfObject().getAsStream(PdfName.DestOutputProfile); }
public PdfStream getSound() { return getPdfObject().getAsStream(PdfName.Sound); }
public PdfStream getStateObject(PdfName stateName) { return getPdfObject().getAsStream(stateName); }
/** * PDF 2.0. Gets a stream object defining the thumbnail image for the file specification. * * @return image used as a thumbnail, or <code>null</code> if it is not set */ public PdfImageXObject getThumbnailImage() { PdfStream thumbnailStream = ((PdfDictionary) getPdfObject()).getAsStream(PdfName.Thumb); return thumbnailStream != null ? new PdfImageXObject(thumbnailStream) : null; }
private void setCheckerOutputIntent(PdfDictionary outputIntent) { if (outputIntent != null) { PdfStream destOutputProfile = outputIntent.getAsStream(PdfName.DestOutputProfile); if (destOutputProfile != null) { String intentCS = IccProfile.getIccColorSpaceName(destOutputProfile.getBytes()); this.pdfAOutputIntentColorSpace = intentCS; } } } }
/** * Sets a stream object that shall define the page’s thumbnail image. Thumbnail images represent the contents of * its pages in miniature form * * @return the thumbnail image, or <code>null</code> if it is not present */ public PdfImageXObject getThumbnailImage() { PdfStream thumbStream = getPdfObject().getAsStream(PdfName.Thumb); return thumbStream != null ? new PdfImageXObject(thumbStream) : null; }
private void setCheckerOutputIntent(PdfDictionary outputIntent) { if (outputIntent != null) { PdfStream destOutputProfile = outputIntent.getAsStream(PdfName.DestOutputProfile); if (destOutputProfile != null) { String intentCS = IccProfile.getIccColorSpaceName(destOutputProfile.getBytes()); this.pdfAOutputIntentColorSpace = intentCS; } } } }
protected PdfStream getXObjectStream(PdfName xobjectName) { PdfDictionary xobjects = getResources().getResource(PdfName.XObject); return xobjects.getAsStream(xobjectName); }
@Override protected void checkFileSpec(PdfDictionary fileSpec) { if (fileSpec.containsKey(PdfName.EF)) { if (!fileSpec.containsKey(PdfName.F) || !fileSpec.containsKey(PdfName.UF)) { throw new PdfAConformanceException(PdfAConformanceException.FILE_SPECIFICATION_DICTIONARY_SHALL_CONTAIN_F_KEY_AND_UF_KEY); } if (!fileSpec.containsKey(PdfName.Desc)) { Logger logger = LoggerFactory.getLogger(PdfAChecker.class); logger.warn(PdfAConformanceLogMessageConstant.FILE_SPECIFICATION_DICTIONARY_SHOULD_CONTAIN_DESC_KEY); } PdfDictionary ef = fileSpec.getAsDictionary(PdfName.EF); PdfStream embeddedFile = ef.getAsStream(PdfName.F); if (embeddedFile == null) { throw new PdfAConformanceException(PdfAConformanceException.EF_KEY_OF_FILE_SPECIFICATION_DICTIONARY_SHALL_CONTAIN_DICTIONARY_WITH_VALID_F_KEY); } // iText doesn't check whether provided file is compliant to PDF-A specs. Logger logger = LoggerFactory.getLogger(PdfAChecker.class); logger.warn(PdfAConformanceLogMessageConstant.EMBEDDED_FILE_SHALL_BE_COMPLIANT_WITH_SPEC); } }
@Override protected void checkFileSpec(PdfDictionary fileSpec) { if (fileSpec.containsKey(PdfName.EF)) { if (!fileSpec.containsKey(PdfName.F) || !fileSpec.containsKey(PdfName.UF)) { throw new PdfAConformanceException(PdfAConformanceException.FILE_SPECIFICATION_DICTIONARY_SHALL_CONTAIN_F_KEY_AND_UF_KEY); } if (!fileSpec.containsKey(PdfName.Desc)) { Logger logger = LoggerFactory.getLogger(PdfAChecker.class); logger.warn(PdfAConformanceLogMessageConstant.FILE_SPECIFICATION_DICTIONARY_SHOULD_CONTAIN_DESC_KEY); } PdfDictionary ef = fileSpec.getAsDictionary(PdfName.EF); PdfStream embeddedFile = ef.getAsStream(PdfName.F); if (embeddedFile == null) { throw new PdfAConformanceException(PdfAConformanceException.EF_KEY_OF_FILE_SPECIFICATION_DICTIONARY_SHALL_CONTAIN_DICTIONARY_WITH_VALID_F_KEY); } // iText doesn't check whether provided file is compliant to PDF-A specs. Logger logger = LoggerFactory.getLogger(PdfAChecker.class); logger.warn(PdfAConformanceLogMessageConstant.EMBEDDED_FILE_SHALL_BE_COMPLIANT_WITH_SPEC); } }
public PdfImageXObject getImage(PdfName name) { PdfStream image = getResource(PdfName.XObject).getAsStream(name); return image != null && PdfName.Image.equals(image.getAsName(PdfName.Subtype)) ? new PdfImageXObject(image) : null; }
public PdfFormXObject getForm(PdfName name) { PdfStream form = getResource(PdfName.XObject).getAsStream(name); return form != null && PdfName.Form.equals(form.getAsName(PdfName.Subtype)) ? new PdfFormXObject(form) : null; }
public static PdfFileSpec wrap(PdfDictionary dictionary) { if (!PdfName.EncryptedPayload.equals(dictionary.getAsName(PdfName.AFRelationship))) { LoggerFactory.getLogger(PdfEncryptedPayloadFileSpecFactory.class).error(LogMessageConstant.ENCRYPTED_PAYLOAD_FILE_SPEC_SHALL_HAVE_AFRELATIONSHIP_FILED_EQUAL_TO_ENCRYPTED_PAYLOAD); } PdfDictionary ef = dictionary.getAsDictionary(PdfName.EF); if (ef == null || (ef.getAsStream(PdfName.F) == null) && (ef.getAsStream(PdfName.UF) == null)) { throw new PdfException(PdfException.EncryptedPayloadFileSpecShallHaveEFDictionary); } if (!PdfName.Filespec.equals(dictionary.getAsName(PdfName.Type))) { throw new PdfException(PdfException.EncryptedPayloadFileSpecShallHaveTypeEqualToFilespec); } if (!dictionary.isIndirect()) { throw new PdfException(PdfException.EncryptedPayloadFileSpecShallBeIndirect); } PdfFileSpec fileSpec = PdfFileSpec.wrapFileSpecObject(dictionary); if (PdfEncryptedPayload.extractFrom(fileSpec) == null) { throw new PdfException(PdfException.EncryptedPayloadFileSpecDoesntHaveEncryptedPayloadDictionary); } return fileSpec; }
if (normal.isDictionary()) { for (PdfName key : ((PdfDictionary) normal).keySet()) { PdfStream appearance = ((PdfDictionary) normal).getAsStream(key); PdfDictionary resDict = appearance.getAsDictionary(PdfName.Resources); if (resDict != null) {
if (normal.isDictionary()) { for (PdfName key : ((PdfDictionary) normal).keySet()) { PdfStream appearance = ((PdfDictionary) normal).getAsStream(key); PdfDictionary resDict = appearance.getAsDictionary(PdfName.Resources); if (resDict != null) {
private static void createPushButtonAppearanceState(PdfDictionary widget) { PdfDictionary appearances = widget.getAsDictionary(PdfName.AP); PdfStream normalAppearanceStream = appearances.getAsStream(PdfName.N); if (normalAppearanceStream != null) { PdfName stateName = widget.getAsName(PdfName.AS); if (stateName == null) { stateName = new PdfName("push"); } widget.put(PdfName.AS, stateName); PdfDictionary normalAppearance = new PdfDictionary(); normalAppearance.put(stateName, normalAppearanceStream); appearances.put(PdfName.N, normalAppearance); } }
private static void createPushButtonAppearanceState(PdfDictionary widget) { PdfDictionary appearances = widget.getAsDictionary(PdfName.AP); PdfStream normalAppearanceStream = appearances.getAsStream(PdfName.N); if (normalAppearanceStream != null) { PdfName stateName = widget.getAsName(PdfName.AS); if (stateName == null) { stateName = new PdfName("push"); } widget.put(PdfName.AS, stateName); PdfDictionary normalAppearance = new PdfDictionary(); normalAppearance.put(stateName, normalAppearanceStream); appearances.put(PdfName.N, normalAppearance); } }
/** * {@inheritDoc} */ public void invoke(PdfCanvasProcessor processor, PdfLiteral operator, List<PdfObject> operands) { PdfName dictionaryName = (PdfName) operands.get(0); PdfDictionary extGState = processor.getResources().getResource(PdfName.ExtGState); if (extGState == null) throw new PdfException(PdfException.ResourcesDoNotContainExtgstateEntryUnableToProcessOperator1).setMessageParams(operator); PdfDictionary gsDic = extGState.getAsDictionary(dictionaryName); if (gsDic == null) { gsDic = extGState.getAsStream(dictionaryName); if (gsDic == null) throw new PdfException(PdfException._1IsAnUnknownGraphicsStateDictionary).setMessageParams(dictionaryName); } // at this point, all we care about is the FONT entry in the GS dictionary TODO merge the whole gs dictionary PdfArray fontParameter = gsDic.getAsArray(PdfName.Font); if (fontParameter != null) { PdfFont font = processor.getFont(fontParameter.getAsDictionary(0)); float size = fontParameter.getAsNumber(1).floatValue(); processor.getGraphicsState().setFont(font); processor.getGraphicsState().setFontSize(size); } } }