Search in sources :

Example 36 with PdfWriter

use of com.itextpdf.kernel.pdf.PdfWriter in project i7js-highlevel by itext.

the class C03E12_MaryReillyV5 method createPdf.

public void createPdf(String dest) throws IOException {
    PdfDocument pdf = new PdfDocument(new PdfWriter(dest));
    Document document = new Document(pdf);
    Paragraph p = new Paragraph("Mary Reilly is a maid in the household of Dr. Jekyll: ");
    document.add(p);
    Image img = new Image(ImageDataFactory.create(MARY));
    img.setFixedPosition(320, 750, UnitValue.createPointValue(50));
    document.add(img);
    document.close();
}
Also used : PdfWriter(com.itextpdf.kernel.pdf.PdfWriter) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument) Document(com.itextpdf.layout.Document) Image(com.itextpdf.layout.element.Image) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument) Paragraph(com.itextpdf.layout.element.Paragraph)

Example 37 with PdfWriter

use of com.itextpdf.kernel.pdf.PdfWriter in project i7js-highlevel by itext.

the class C03E14_MaryReillyV7 method manipulatePdf.

public void manipulatePdf(String src, String dest) throws IOException {
    PdfReader reader = new PdfReader(src);
    PdfWriter writer = new PdfWriter(dest);
    PdfDocument pdfDoc = new PdfDocument(reader, writer);
    Document document = new Document(pdfDoc);
    Image img = new Image(ImageDataFactory.create(MARY));
    img.setFixedPosition(1, 350, 750, UnitValue.createPointValue(50));
    document.add(img);
    document.close();
}
Also used : PdfWriter(com.itextpdf.kernel.pdf.PdfWriter) PdfReader(com.itextpdf.kernel.pdf.PdfReader) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument) Document(com.itextpdf.layout.Document) Image(com.itextpdf.layout.element.Image) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument)

Example 38 with PdfWriter

use of com.itextpdf.kernel.pdf.PdfWriter in project i7js-highlevel by itext.

the class C03E16_MaryReillyV9 method createPdf.

public void createPdf(String dest) throws IOException {
    PdfDocument pdf = new PdfDocument(new PdfWriter(dest));
    Document document = new Document(pdf);
    Paragraph p = new Paragraph("Mary Reilly is a maid in the household of Dr. Jekyll: ");
    Image img = new Image(ImageDataFactory.create(MARY));
    p.add(img);
    document.add(p);
    document.close();
}
Also used : PdfWriter(com.itextpdf.kernel.pdf.PdfWriter) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument) Document(com.itextpdf.layout.Document) Image(com.itextpdf.layout.element.Image) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument) Paragraph(com.itextpdf.layout.element.Paragraph)

Example 39 with PdfWriter

use of com.itextpdf.kernel.pdf.PdfWriter in project i7js-highlevel by itext.

the class C04E02_DivExample2 method createPdf.

public void createPdf(String dest) throws IOException {
    PdfDocument pdf = new PdfDocument(new PdfWriter(dest));
    Document document = new Document(pdf);
    List<List<String>> resultSet = CsvTo2DList.convert(SRC, "|");
    resultSet.remove(0);
    for (List<String> record : resultSet) {
        Div div = new Div().setKeepTogether(true).setBorderLeft(new SolidBorder(2)).setPaddingLeft(3).setMarginBottom(10);
        String url = String.format("http://www.imdb.com/title/tt%s", record.get(0));
        Link movie = new Link(record.get(2), PdfAction.createURI(url));
        div.add(new Paragraph(movie.setFontSize(14))).add(new Paragraph(String.format("Directed by %s (%s, %s)", record.get(3), record.get(4), record.get(1))));
        File file = new File(String.format("src/main/resources/img/%s.jpg", record.get(0)));
        if (file.exists()) {
            Image img = new Image(ImageDataFactory.create(file.getPath()));
            img.scaleToFit(10000, 120);
            div.add(img);
        }
        document.add(div);
    }
    document.close();
}
Also used : PdfWriter(com.itextpdf.kernel.pdf.PdfWriter) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument) Document(com.itextpdf.layout.Document) Image(com.itextpdf.layout.element.Image) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument) SolidBorder(com.itextpdf.layout.borders.SolidBorder) Paragraph(com.itextpdf.layout.element.Paragraph) Div(com.itextpdf.layout.element.Div) CsvTo2DList(com.itextpdf.highlevel.util.CsvTo2DList) List(java.util.List) File(java.io.File) Link(com.itextpdf.layout.element.Link)

Example 40 with PdfWriter

use of com.itextpdf.kernel.pdf.PdfWriter in project i7js-highlevel by itext.

the class C05E02_ColumnWidths3 method createPdf.

public void createPdf(String dest) throws IOException {
    // Initialize PDF document
    PdfDocument pdf = new PdfDocument(new PdfWriter(dest));
    // Initialize document
    Document document = new Document(pdf);
    Table table = new Table(UnitValue.createPercentArray(new float[] { 2, 1, 1 }));
    table.setWidth(450);
    table.setHorizontalAlignment(HorizontalAlignment.CENTER);
    table.addCell(new Cell(1, 3).add(new Paragraph("Cell with colspan 3")));
    table.addCell(new Cell(2, 1).add(new Paragraph("Cell with rowspan 2")));
    table.addCell("row 1; cell 1");
    table.addCell("row 1; cell 2");
    table.addCell("row 2; cell 1");
    table.addCell("row 2; cell 2");
    document.add(table);
    document.close();
}
Also used : Table(com.itextpdf.layout.element.Table) PdfWriter(com.itextpdf.kernel.pdf.PdfWriter) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument) Document(com.itextpdf.layout.Document) Cell(com.itextpdf.layout.element.Cell) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument) Paragraph(com.itextpdf.layout.element.Paragraph)

Aggregations

PdfDocument (com.itextpdf.kernel.pdf.PdfDocument)194 PdfWriter (com.itextpdf.kernel.pdf.PdfWriter)194 Document (com.itextpdf.layout.Document)130 Paragraph (com.itextpdf.layout.element.Paragraph)110 PdfReader (com.itextpdf.kernel.pdf.PdfReader)56 PdfFont (com.itextpdf.kernel.font.PdfFont)45 ExtendedITextTest (com.itextpdf.test.ExtendedITextTest)39 IntegrationTest (com.itextpdf.test.annotations.type.IntegrationTest)39 Test (org.junit.Test)39 Rectangle (com.itextpdf.kernel.geom.Rectangle)37 HyphenationConfig (com.itextpdf.layout.hyphenation.HyphenationConfig)32 BufferedReader (java.io.BufferedReader)26 FileReader (java.io.FileReader)26 AreaBreak (com.itextpdf.layout.element.AreaBreak)25 Image (com.itextpdf.layout.element.Image)25 Table (com.itextpdf.layout.element.Table)25 ArrayList (java.util.ArrayList)24 List (java.util.List)22 Cell (com.itextpdf.layout.element.Cell)21 CsvTo2DList (com.itextpdf.highlevel.util.CsvTo2DList)20