public static Document createListingPDF(List<PdfPageData> pages, String file) { return createListing(new PdfWriter(new FileOutputStream(file)), pages); } public static Document createListingRTF(List<PdfPageData> pages, String file) { return createListing(new RtfWriter2(new FileOutputStream(file)), pages) } private static Document createListing(DocumentWriter writer, List<PdfPageData> pages) { Document document = new Document(pages); writer.write(document); return document; }
Map<String, String> someMapOfFieldToValues = new HashMap<>(); try ( PdfDocument finalOutput = new PdfDocument(new PdfWriter(new FileOutputStream(new File("finalOutput.pdf"))); ) { for (/* some looping condition */int x = 0; x < 5; x++) { PdfDocument filledInAcroFormTemplate = new PdfDocument(new PdfReader(new FileInputStream(acroFormTemplate)), new PdfWriter(tmp)); ) { PdfAcroForm acroForm = PdfAcroForm.getAcroForm(filledInAcroFormTemplate, true);
PdfDocument document = new PdfDocument(new PdfReader(src), new PdfWriter(dest + "_temp")); if (initial == true)
/** * Use this method to get an instance of the <CODE>PdfWriter</CODE>. * * @param document The <CODE>Document</CODE> that has to be written * @param os The <CODE>OutputStream</CODE> the writer has to write to. * @return a new <CODE>PdfWriter</CODE> * * @throws DocumentException on error */ public static PdfWriter getInstance(final Document document, final OutputStream os) throws DocumentException { PdfDocument pdf = new PdfDocument(); document.addDocListener(pdf); PdfWriter writer = new PdfWriter(pdf, os); pdf.addWriter(writer); return writer; }
/** * Use this method to get an instance of the <CODE>PdfWriter</CODE>. * * @param document The <CODE>Document</CODE> that has to be written * @param os The <CODE>OutputStream</CODE> the writer has to write to. * @return a new <CODE>PdfWriter</CODE> * * @throws DocumentException on error */ public static PdfWriter getInstance(final Document document, final OutputStream os) throws DocumentException { PdfDocument pdf = new PdfDocument(); document.addDocListener(pdf); PdfWriter writer = new PdfWriter(pdf, os); pdf.addWriter(writer); return writer; }
PdfDocument pdfPageDocument = new PdfDocument(new PdfWriter(interimPage)) ) try ( PdfDocument pdfMainDocument = new PdfDocument(pdfReader, new PdfWriter(interimMain)); PdfDocument pdfSectionDocument = new PdfDocument(new PdfReader(new ByteArrayInputStream(interimPage.toByteArray())), new PdfWriter(interimSection)) ) PdfDocument pdfMainDocument = new PdfDocument(new PdfReader(new ByteArrayInputStream(interimMain.toByteArray())), new PdfWriter(targetFile)) )
public void createPdf(String dest) throws IOException { PdfDocument pdf = new PdfDocument(new PdfWriter(dest)); Document document = new Document(pdf); List topLevel = new List(); ListItem item1 = new ListItem(); item1.add(new Paragraph().add("Item 1")); List secondLevel = new List(); secondLevel.add("Sub Item 1"); ListItem subItem2 = new ListItem(); subItem2.add(new Paragraph("Sub Item 2")); List thirdLevel = new List(); thirdLevel.add("Sub Sub Item 1"); thirdLevel.add("Sub Sub Item 2"); subItem2.add(thirdLevel); secondLevel.add(subItem2); item1.add(secondLevel); topLevel.add(item1); document.add(topLevel); document.close(); }
/** * Use this method to get an instance of the <CODE>PdfWriter</CODE>. * * @return a new <CODE>PdfWriter</CODE> * @param document The <CODE>Document</CODE> that has to be written * @param os The <CODE>OutputStream</CODE> the writer has to write to. * @param listener A <CODE>DocListener</CODE> to pass to the PdfDocument. * @throws DocumentException on error */ public static PdfWriter getInstance(final Document document, final OutputStream os, final DocListener listener) throws DocumentException { PdfDocument pdf = new PdfDocument(); pdf.addDocListener(listener); document.addDocListener(pdf); PdfWriter writer = new PdfWriter(pdf, os); pdf.addWriter(writer); return writer; }
/** * Use this method to get an instance of the <CODE>PdfWriter</CODE>. * * @return a new <CODE>PdfWriter</CODE> * @param document The <CODE>Document</CODE> that has to be written * @param os The <CODE>OutputStream</CODE> the writer has to write to. * @param listener A <CODE>DocListener</CODE> to pass to the PdfDocument. * @throws DocumentException on error */ public static PdfWriter getInstance(final Document document, final OutputStream os, final DocListener listener) throws DocumentException { PdfDocument pdf = new PdfDocument(); pdf.addDocListener(listener); document.addDocListener(pdf); PdfWriter writer = new PdfWriter(pdf, os); pdf.addWriter(writer); return writer; }
com.itextpdf.layout.element.Image pdfImg = new com.itextpdf.layout.element.Image(imgData); PdfWriter writer = new PdfWriter(new FileOutputStream(file)); PdfDocument pdfDoc = new PdfDocument(writer); Document doc = new Document(pdfDoc);
PdfDocument pdfDoc = new PdfDocument(new PdfWriter(dest)); Document doc = new Document(pdfDoc); Paragraph p = new Paragraph();
try ( OutputStream result = new FileOutputStream("simpleTableRahulDevMishra.pdf"); PdfWriter writer = new PdfWriter(result); PdfDocument pdfDocument = new PdfDocument(writer); Document doc = new Document(pdfDocument) ) { Table table = new Table(2, true); table.addCell(new Cell().add("C1")); table.addCell(new Cell().add("C2")); /* for (TaxTypeModel taxType : sale.getTaxModel().getTaxTypeModelList()) { table.addCell(new Cell().add("C9")); table.addCell(new Cell().add("C10")); } */ table.addCell(new Cell().add("C3")); table.addCell(new Cell().add("C4")); table.addCell(new Cell().add("C5")); table.addCell(new Cell().add("C6")); table.addCell(new Cell().add("C7")); table.addCell(new Cell().add("C8")); doc.add(table); table.complete(); doc.close(); }