/** * Create a new appearance stream. * * @param appearance * The appearance stream to write to. * @throws IOException If there is an error writing to the content stream. */ public PDAppearanceContentStream(PDAppearanceStream appearance) throws IOException { this(appearance, appearance.getStream().createOutputStream()); }
/** * Create a new appearance stream. Note that this is not actually a "page" content stream. * * @param doc The document the page is part of. * @param appearance The appearance stream to write to. * @throws IOException If there is an error writing to the page contents. */ public PDPageContentStream(PDDocument doc, PDAppearanceStream appearance) throws IOException { this (doc, appearance, appearance.getStream().createOutputStream()); }
/** * Create a new appearance stream. * * @param appearance The appearance stream to write to. * @param compress whether the content stream is to be compressed. Set this to true when * creating long content streams. * @throws IOException If there is an error writing to the content stream. */ public PDAppearanceContentStream(PDAppearanceStream appearance, boolean compress) throws IOException { this(appearance, appearance.getStream().createOutputStream(compress ? COSName.FLATE_DECODE : null)); }
private static void writeTokensToStream(PDStream newContents, List<Object> newTokens) throws IOException { try (OutputStream out = newContents.createOutputStream(COSName.FLATE_DECODE)) { ContentStreamWriter writer = new ContentStreamWriter(out); writer.writeTokens(newTokens); } }
/** * Create a new tiling pattern content stream. * * @param pattern The tiling pattern stream to write to. * * @throws IOException If there is an error writing to the form contents. */ public PDPatternContentStream(PDTilingPattern pattern) throws IOException { super(null, pattern.getContentStream().createOutputStream(), pattern.getResources()); } }
/** * Create a new form XObject content stream. * * @param form The form XObject stream to write to. * * @throws IOException If there is an error writing to the form contents. */ public PDFormContentStream(PDFormXObject form) throws IOException { super(null, form.getContentStream().createOutputStream(), form.getResources()); } }
OutputStream out = newContents.createOutputStream(COSName.FLATE_DECODE); ContentStreamWriter writer = new ContentStreamWriter(out); writer.writeTokens(newTokens);
@Override public void injectAppearanceStreams(PDStream holderFormStream, PDStream innerFormStream, PDStream imageFormStream, COSName imageFormName, COSName imageName, COSName innerFormName, PDVisibleSignDesigner properties) throws IOException { // Use width and height of BBox as values for transformation matrix. int width = (int) this.getStructure().getFormatterRectangle().getWidth(); int height = (int) this.getStructure().getFormatterRectangle().getHeight(); String imgFormContent = "q " + width + " 0 0 " + height + " 0 0 cm /" + imageName.getName() + " Do Q\n"; String holderFormContent = "q 1 0 0 1 0 0 cm /" + innerFormName.getName() + " Do Q\n"; String innerFormContent = "q 1 0 0 1 0 0 cm /n0 Do Q q 1 0 0 1 0 0 cm /" + imageFormName.getName() + " Do Q\n"; appendRawCommands(pdfStructure.getHolderFormStream().createOutputStream(), holderFormContent); appendRawCommands(pdfStructure.getInnerFormStream().createOutputStream(), innerFormContent); appendRawCommands(pdfStructure.getImageFormStream().createOutputStream(), imgFormContent); LOG.info("Injected appearance stream to pdf"); }
PDResources resources) throws IOException super(document, stream.createOutputStream(compress ? COSName.FLATE_DECODE : null), resources); OutputStream prefixOut = prefixStream.createOutputStream(); prefixOut.write("q".getBytes(Charsets.US_ASCII)); prefixOut.write('\n');
.createOutputStream(COSName.FLATE_DECODE))
/** * Create a new appearance stream. * * @param appearance * The appearance stream to write to. * @throws IOException * If there is an error writing to the page contents. */ public PDAppearanceContentStream(PDAppearanceStream appearance) throws IOException { this(appearance, appearance.getStream().createOutputStream()); }
/** * Create a new appearance stream. Note that this is not actually a "page" content stream. * * @param doc The document the page is part of. * @param appearance The appearance stream to write to. * @throws IOException If there is an error writing to the page contents. */ public PDPageContentStream(PDDocument doc, PDAppearanceStream appearance) throws IOException { this (doc, appearance, appearance.getStream().createOutputStream()); }
/** * Create a new appearance stream. * * @param appearance The appearance stream to write to. * @throws IOException If there is an error writing to the page contents. */ public PDAbstractContentStream(PDAppearanceStream appearance) throws IOException { this (appearance, appearance.getStream().createOutputStream()); }
/** * Create a new appearance stream. Note that this is not actually a "page" content stream. * * @param doc The document the page is part of. * @param appearance The appearance stream to write to. * @throws IOException If there is an error writing to the page contents. */ public PDPageContentStream(PDDocument doc, PDAppearanceStream appearance) throws IOException { this (doc, appearance, appearance.getStream().createOutputStream()); }
try (OutputStream os = form.getStream().createOutputStream())
private static void writeTokensToStream(PDStream newContents, List<Object> newTokens) throws IOException { OutputStream out = newContents.createOutputStream(COSName.FLATE_DECODE); ContentStreamWriter writer = new ContentStreamWriter(out); writer.writeTokens(newTokens); out.close(); }
@Override public void injectAppearanceStreams(PDStream holderFormStream, PDStream innerFormStream, PDStream imageFormStream, COSName imageFormName, COSName imageName, COSName innerFormName, PDVisibleSignDesigner properties) throws IOException { // 100 means that document width is 100% via the rectangle. if rectangle // is 500px, images 100% is 500px. // String imgFormContent = "q "+imageWidthSize+ " 0 0 50 0 0 cm /" + // imageName + " Do Q\n" + builder.toString(); String imgFormContent = "q " + 100 + " 0 0 50 0 0 cm /" + imageName.getName() + " Do Q\n"; String holderFormContent = "q 1 0 0 1 0 0 cm /" + innerFormName.getName() + " Do Q\n"; String innerFormContent = "q 1 0 0 1 0 0 cm /n0 Do Q q 1 0 0 1 0 0 cm /" + imageFormName.getName() + " Do Q\n"; appendRawCommands(pdfStructure.getHolderFormStream().createOutputStream(), holderFormContent); appendRawCommands(pdfStructure.getInnerFormStream().createOutputStream(), innerFormContent); appendRawCommands(pdfStructure.getImageFormStream().createOutputStream(), imgFormContent); LOG.info("Injected appearance stream to pdf"); }
public static PDAppearanceStream createCheckboxAppearance(String appear, PDDocument doc, PDResources resources) { PDAppearanceStream s = new PDAppearanceStream(doc); s.setBBox(new PDRectangle(100f, 100f)); OutputStream os = null; try { os = s.getContentStream().createOutputStream(); os.write(appear.getBytes("ASCII")); } catch (IOException e) { throw new PdfContentStreamAdapter.PdfException("createCheckboxAppearance", e); } finally { try { if (os != null) os.close(); } catch (IOException e) { } } s.setResources(resources); return s; }
public static PDAppearanceStream createCheckboxAppearance(String appear, PDDocument doc, PDResources resources) { PDAppearanceStream s = new PDAppearanceStream(doc); s.setBBox(new PDRectangle(100f, 100f)); OutputStream os = null; try { os = s.getContentStream().createOutputStream(); os.write(appear.getBytes("ASCII")); } catch (IOException e) { throw new PdfContentStreamAdapter.PdfException("createCheckboxAppearance", e); } finally { try { if (os != null) os.close(); } catch (IOException e) { } } s.setResources(resources); return s; }
@Override public void injectAppearanceStreams(PDStream holderFormStream, PDStream innerFormStream, PDStream imageFormStream, COSName imageFormName, COSName imageName, COSName innerFormName, PDVisibleSignDesigner properties) throws IOException { // Use width and height of BBox as values for transformation matrix. int width = (int) this.getStructure().getFormatterRectangle().getWidth(); int height = (int) this.getStructure().getFormatterRectangle().getHeight(); String imgFormContent = "q " + width + " 0 0 " + height + " 0 0 cm /" + imageName.getName() + " Do Q\n"; String holderFormContent = "q 1 0 0 1 0 0 cm /" + innerFormName.getName() + " Do Q\n"; String innerFormContent = "q 1 0 0 1 0 0 cm /n0 Do Q q 1 0 0 1 0 0 cm /" + imageFormName.getName() + " Do Q\n"; appendRawCommands(pdfStructure.getHolderFormStream().createOutputStream(), holderFormContent); appendRawCommands(pdfStructure.getInnerFormStream().createOutputStream(), innerFormContent); appendRawCommands(pdfStructure.getImageFormStream().createOutputStream(), imgFormContent); LOG.info("Injected appearance stream to pdf"); }