/** * Get the {@link PdfObject} object with specified type and name. * * @param resType the resource type. Should be {@link PdfName#ColorSpace}, {@link PdfName#ExtGState}, * {@link PdfName#Pattern}, {@link PdfName#Shading}, {@link PdfName#XObject}, {@link PdfName#Font}. * @param resName the name of the resource object. * @return the {@link PdfObject} with specified name in the resources of specified type or {@code null} * in case of incorrect type or missing resource with such name. */ public PdfObject getResourceObject(PdfName resType, PdfName resName) { PdfDictionary resource = getResource(resType); if (resource != null) { return resource.get(resName); } return null; }
protected PdfStream getXObjectStream(PdfName xobjectName) { PdfDictionary xobjects = getResources().getResource(PdfName.XObject); return xobjects.getAsStream(xobjectName); }
public PdfExtGState getPdfExtGState(PdfName name) { PdfDictionary dic = getResource(PdfName.ExtGState).getAsDictionary(name); return dic != null ? new PdfExtGState(dic) : null; }
if (tokeniser.getTokenType() == PdfTokenizer.TokenType.Other) { if (ob.toString().equals("BI")) { PdfStream inlineImageAsStream = InlineImageParsingUtils.parse(this, currentResources.getResource(PdfName.ColorSpace)); ls.clear(); ls.add(inlineImageAsStream);
PdfDictionary getPropertiesDictionary(PdfObject operand1, PdfResources resources) { if (operand1.isDictionary()) return (PdfDictionary) operand1; PdfName dictionaryName = ((PdfName) operand1); PdfDictionary properties = resources.getResource(PdfName.Properties); if (null == properties) { Logger logger = LoggerFactory.getLogger(PdfCanvasProcessor.class); logger.warn(MessageFormatUtil.format(LogMessageConstant.PDF_REFERS_TO_NOT_EXISTING_PROPERTY_DICTIONARY, PdfName.Properties)); return null; } PdfDictionary propertiesDictionary = properties.getAsDictionary(dictionaryName); if (null == propertiesDictionary) { Logger logger = LoggerFactory.getLogger(PdfCanvasProcessor.class); logger.warn(MessageFormatUtil.format(LogMessageConstant.PDF_REFERS_TO_NOT_EXISTING_PROPERTY_DICTIONARY, dictionaryName)); return null; } return properties.getAsDictionary(dictionaryName); } }
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; }
/** * {@inheritDoc} */ public void invoke(PdfCanvasProcessor processor, PdfLiteral operator, List<PdfObject> operands) { PdfName fontResourceName = (PdfName) operands.get(0); float size = ((PdfNumber) operands.get(1)).floatValue(); PdfDictionary fontsDictionary = processor.getResources().getResource(PdfName.Font); PdfDictionary fontDict = fontsDictionary.getAsDictionary(fontResourceName); PdfFont font = null; font = processor.getFont(fontDict); processor.getGraphicsState().setFont(font); processor.getGraphicsState().setFontSize(size); } }
private void displayImage(Stack<CanvasTag> canvasTagHierarchy, PdfStream imageStream, PdfName resourceName, boolean isInline) { PdfDictionary colorSpaceDic = getResources().getResource(PdfName.ColorSpace); ImageRenderInfo renderInfo = new ImageRenderInfo(canvasTagHierarchy, getGraphicsState(), getGraphicsState().getCtm(), imageStream, resourceName, colorSpaceDic, isInline); eventOccurred(renderInfo, EventType.RENDER_IMAGE); }
/** * {@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); } } }