/** Throws an error if it is a pattern. * @param t the object to check */ void checkNoPattern(final PdfTemplate t) { if (t.getType() == PdfTemplate.TYPE_PATTERN) throw new RuntimeException(MessageLocalization.getComposedMessage("invalid.use.of.a.pattern.a.template.was.expected")); }
/** Throws an error if it is a pattern. * @param t the object to check */ void checkNoPattern(final PdfTemplate t) { if (t.getType() == PdfTemplate.TYPE_PATTERN) throw new RuntimeException(MessageLocalization.getComposedMessage("invalid.use.of.a.pattern.a.template.was.expected")); }
protected void addXFormsToBody() throws IOException { for (Object objs[] : formXObjects.values()) { PdfTemplate template = (PdfTemplate)objs[1]; if (template != null && template.getIndirectReference() instanceof PRIndirectReference) continue; if (template != null && template.getType() == PdfTemplate.TYPE_TEMPLATE) { addToBody(template.getFormXObject(compressionLevel), template.getIndirectReference()); } } }
protected void addXFormsToBody() throws IOException { for (Object objs[] : formXObjects.values()) { PdfTemplate template = (PdfTemplate)objs[1]; if (template != null && template.getIndirectReference() instanceof PRIndirectReference) continue; if (template != null && template.getType() == PdfTemplate.TYPE_TEMPLATE) { addToBody(template.getFormXObject(compressionLevel), template.getIndirectReference()); } } }
if (template.getType() == PdfTemplate.TYPE_IMPORTED) {
if (template.getType() == PdfTemplate.TYPE_IMPORTED) {
/** * Use this method to releases the memory used by a template. * This method writes the template to the output. * The template can still be added to any content * but changes to the template itself won't have any effect. * @param tp the template to release * @throws IOException on error */ public void releaseTemplate(final PdfTemplate tp) throws IOException { PdfIndirectReference ref = tp.getIndirectReference(); Object[] objs = formXObjects.get(ref); if (objs == null || objs[1] == null) return; PdfTemplate template = (PdfTemplate)objs[1]; if (template.getIndirectReference() instanceof PRIndirectReference) return; if (template.getType() == PdfTemplate.TYPE_TEMPLATE) { addToBody(template.getFormXObject(compressionLevel), template.getIndirectReference()); objs[1] = null; } }
/** * Use this method to releases the memory used by a template. * This method writes the template to the output. * The template can still be added to any content * but changes to the template itself won't have any effect. * @param tp the template to release * @throws IOException on error */ public void releaseTemplate(final PdfTemplate tp) throws IOException { PdfIndirectReference ref = tp.getIndirectReference(); Object[] objs = formXObjects.get(ref); if (objs == null || objs[1] == null) return; PdfTemplate template = (PdfTemplate)objs[1]; if (template.getIndirectReference() instanceof PRIndirectReference) return; if (template.getType() == PdfTemplate.TYPE_TEMPLATE) { addToBody(template.getFormXObject(compressionLevel), template.getIndirectReference()); objs[1] = null; } }
/** Creates an Image from a PdfTemplate. * * @param template the PdfTemplate * @throws BadElementException on error */ public ImgTemplate(PdfTemplate template) throws BadElementException{ super((URL)null); if (template == null) throw new BadElementException(MessageLocalization.getComposedMessage("the.template.can.not.be.null")); if (template.getType() == PdfTemplate.TYPE_PATTERN) throw new BadElementException(MessageLocalization.getComposedMessage("a.pattern.can.not.be.used.as.a.template.to.create.an.image")); type = IMGTEMPLATE; scaledHeight = template.getHeight(); setTop(scaledHeight); scaledWidth = template.getWidth(); setRight(scaledWidth); setTemplateData(template); plainWidth = getWidth(); plainHeight = getHeight(); }
/** Creates an Image from a PdfTemplate. * * @param template the PdfTemplate * @throws BadElementException on error */ public ImgTemplate(PdfTemplate template) throws BadElementException{ super((URL)null); if (template == null) throw new BadElementException(MessageLocalization.getComposedMessage("the.template.can.not.be.null")); if (template.getType() == PdfTemplate.TYPE_PATTERN) throw new BadElementException(MessageLocalization.getComposedMessage("a.pattern.can.not.be.used.as.a.template.to.create.an.image")); type = IMGTEMPLATE; scaledHeight = template.getHeight(); setTop(scaledHeight); scaledWidth = template.getWidth(); setRight(scaledWidth); setTemplateData(template); plainWidth = getWidth(); plainHeight = getHeight(); }