Example usage for com.lowagie.text.pdf PdfWriter VERSION_1_6

List of usage examples for com.lowagie.text.pdf PdfWriter VERSION_1_6

Introduction

In this page you can find the example usage for com.lowagie.text.pdf PdfWriter VERSION_1_6.

Prototype

char VERSION_1_6

To view the source code for com.lowagie.text.pdf PdfWriter VERSION_1_6.

Click Source Link

Document

possible PDF version (header)

Usage

From source file:lucee.runtime.tag.PDF.java

License:Open Source License

/**
 * @param version the version to set/*from   www.  j a  v a  2s.co m*/
 * @throws ApplicationException 
 */
public void setVersion(double version) throws ApplicationException {
    if (1.1 == version)
        this.version = '1';
    else if (1.2 == version)
        this.version = PdfWriter.VERSION_1_2;
    else if (1.3 == version)
        this.version = PdfWriter.VERSION_1_3;
    else if (1.4 == version)
        this.version = PdfWriter.VERSION_1_4;
    else if (1.5 == version)
        this.version = PdfWriter.VERSION_1_5;
    else if (1.6 == version)
        this.version = PdfWriter.VERSION_1_6;

    else
        throw new ApplicationException("invalid version definition [" + Caster.toString(version)
                + "], valid version definitions are " + "[1.1, 1.2, 1.3, 1.4, 1.5, 1.6]");
}

From source file:org.eclipse.osee.framework.ui.skynet.util.TableWriterAdaptor.java

License:Open Source License

private void setDocWriter(String value) throws Exception {
    if (value.equalsIgnoreCase(PDF)) {
        this.writer = PdfWriter.getInstance(document, outputStream);
        //         ((PdfWriter) writer).setPDFXConformance(PdfWriter.PDFX32002);
        ((PdfWriter) writer).setPdfVersion(PdfWriter.VERSION_1_6);
    } else if (value.equalsIgnoreCase(HTML)) {
        this.writer = HtmlWriter.getInstance(document, outputStream);
    } else if (value.equalsIgnoreCase(RTF)) {
        this.writer = RtfWriter2.getInstance(document, outputStream);
    }//from w  ww.j a  v  a 2 s  . c o m
}

From source file:org.lucee.extension.pdf.tag.PDF.java

License:Open Source License

/**
 * @param version//w  ww.  j a v a2 s.co  m
 *            the version to set
 * @throws PageException
 */
public void setVersion(double version) throws PageException {
    if (1.1 == version)
        this.version = '1';
    else if (1.2 == version)
        this.version = PdfWriter.VERSION_1_2;
    else if (1.3 == version)
        this.version = PdfWriter.VERSION_1_3;
    else if (1.4 == version)
        this.version = PdfWriter.VERSION_1_4;
    else if (1.5 == version)
        this.version = PdfWriter.VERSION_1_5;
    else if (1.6 == version)
        this.version = PdfWriter.VERSION_1_6;

    else
        throw engine.getExceptionUtil().createApplicationException(
                "invalid version definition [" + engine.getCastUtil().toString(version)
                        + "], valid version definitions are " + "[1.1, 1.2, 1.3, 1.4, 1.5, 1.6]");
}

From source file:org.openconcerto.erp.generationDoc.SheetUtils.java

License:Open Source License

public static void convert2PDF(final OpenDocument doc, final File pdfFileToCreate) throws Exception {
    assert (!SwingUtilities.isEventDispatchThread());
    // Open the PDF document
    Document document = new Document(PageSize.A4, 50, 50, 50, 50);

    try {/*from  w  ww  .j a v  a2  s .c o m*/

        FileOutputStream fileOutputStream = new FileOutputStream(pdfFileToCreate);

        // Create the writer
        PdfWriter writer = PdfWriter.getInstance(document, fileOutputStream);
        writer.setPdfVersion(PdfWriter.VERSION_1_6);
        writer.setFullCompression();

        document.open();

        PdfContentByte cb = writer.getDirectContent();

        // Configure the renderer
        ODTRenderer renderer = new ODTRenderer(doc);
        renderer.setIgnoreMargins(false);
        renderer.setPaintMaxResolution(true);

        // Scale the renderer to fit width
        renderer.setResizeFactor(renderer.getPrintWidth() / document.getPageSize().getWidth());

        // Print pages
        for (int i = 0; i < renderer.getPrintedPagesNumber(); i++) {

            Graphics2D g2 = cb.createGraphics(PageSize.A4.getWidth(), PageSize.A4.getHeight());

            // If you want to prevent copy/paste, you can use
            // g2 = tp.createGraphicsShapes(w, h, true, 0.9f);

            // Render
            renderer.setCurrentPage(i);
            renderer.paintComponent(g2);
            g2.dispose();

            // Add our spreadsheet in the middle of the page
            if (i < renderer.getPrintedPagesNumber() - 1)
                document.newPage();

        }
        // Close the PDF document
        document.close();
        // writer.close();
        fileOutputStream.close();

    } catch (Exception originalExn) {
        ExceptionHandler.handle("Impossible de crer le PDF " + pdfFileToCreate.getAbsolutePath(),
                originalExn);
    }

}