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()); } } }
/** * 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; } }
public boolean setFieldAsTemplate(String field, PdfTemplate template) { try { PdfDictionary d = new PdfDictionary(); if (template instanceof PdfImportedPage) d.put(PdfName.N, template.getIndirectReference()); else { PdfStream str = template.getFormXObject(PdfStream.NO_COMPRESSION); PdfIndirectReference ref = wrt.addToBody(str).getIndirectReference(); d.put(PdfName.N, ref); } return setField(field, d); } catch (Exception e) { throw new ExceptionConverter(e); } }
public boolean setFieldAsTemplate(String field, PdfTemplate template) { try { PdfDictionary d = new PdfDictionary(); if (template instanceof PdfImportedPage) d.put(PdfName.N, template.getIndirectReference()); else { PdfStream str = template.getFormXObject(PdfStream.NO_COMPRESSION); PdfIndirectReference ref = wrt.addToBody(str).getIndirectReference(); d.put(PdfName.N, ref); } return setField(field, d); } catch (Exception e) { throw new ExceptionConverter(e); } }
public boolean setFieldAsImage(String field, Image image) { try { if (Float.isNaN(image.getAbsoluteX())) image.setAbsolutePosition(0, image.getAbsoluteY()); if (Float.isNaN(image.getAbsoluteY())) image.setAbsolutePosition(image.getAbsoluteY(), 0); PdfTemplate tmpl = PdfTemplate.createTemplate(wrt, image.getWidth(), image.getHeight()); tmpl.addImage(image); PdfStream str = tmpl.getFormXObject(PdfStream.NO_COMPRESSION); PdfIndirectReference ref = wrt.addToBody(str).getIndirectReference(); PdfDictionary d = new PdfDictionary(); d.put(PdfName.N, ref); return setField(field, d); } catch (Exception de) { throw new ExceptionConverter(de); } }
public boolean setFieldAsImage(String field, Image image) { try { if (Float.isNaN(image.getAbsoluteX())) image.setAbsolutePosition(0, image.getAbsoluteY()); if (Float.isNaN(image.getAbsoluteY())) image.setAbsolutePosition(image.getAbsoluteY(), 0); PdfTemplate tmpl = PdfTemplate.createTemplate(wrt, image.getWidth(), image.getHeight()); tmpl.addImage(image); PdfStream str = tmpl.getFormXObject(PdfStream.NO_COMPRESSION); PdfIndirectReference ref = wrt.addToBody(str).getIndirectReference(); PdfDictionary d = new PdfDictionary(); d.put(PdfName.N, ref); return setField(field, d); } catch (Exception de) { throw new ExceptionConverter(de); } }