Example usage for com.lowagie.text Document addCreator

List of usage examples for com.lowagie.text Document addCreator

Introduction

In this page you can find the example usage for com.lowagie.text Document addCreator.

Prototype


public boolean addCreator(String creator) 

Source Link

Document

Adds the creator to a Document.

Usage

From source file:gov.noaa.pfel.coastwatch.sgt.SgtUtil.java

License:Open Source License

/**
 * This creates a file to capture the pdf output generated by calls to 
 * graphics2D (e.g., use makeMap)./*from   ww w  . ja va 2s  . c  o m*/
 * This will overwrite an existing file.
 * 
 * @param pageSize e.g, PageSize.LETTER or PageSize.LETTER.rotate() (or A4, or, ...)
 * @param width the bounding box width, in 1/144ths of an inch
 * @param height the bounding box height, in 1/144ths of an inch
 * @param outputStream
 * @return an object[] with 0=g2D, 1=document, 2=pdfContentByte, 3=pdfTemplate
 * @throws Exception if trouble
 */
public static Object[] createPdf(com.lowagie.text.Rectangle pageSize, int bbWidth, int bbHeight,
        OutputStream outputStream) throws Exception {
    //currently, this uses itext
    //see the sample program:
    //  file://localhost/C:/programs/iText/examples/com/lowagie/examples/directcontent/graphics2D/G2D.java
    //Document.compress = false; //for test purposes only
    Document document = new Document(pageSize);
    document.addCreationDate();
    document.addCreator("gov.noaa.pfel.coastwatch.SgtUtil.createPdf");

    document.setPageSize(pageSize);
    PdfWriter writer = PdfWriter.getInstance(document, outputStream);
    document.open();

    //create contentByte and template and Graphics2D objects
    PdfContentByte pdfContentByte = writer.getDirectContent();
    PdfTemplate pdfTemplate = pdfContentByte.createTemplate(bbWidth, bbHeight);
    Graphics2D g2D = pdfTemplate.createGraphics(bbWidth, bbHeight);

    return new Object[] { g2D, document, pdfContentByte, pdfTemplate };
}

From source file:io.vertigo.dynamo.plugins.export.pdfrtf.AbstractExporterIText.java

License:Apache License

/**
 * Mthode principale qui gre l'export d'un tableau vers un fichier ODS.
 *
 * @param export paramtres du document  exporter
 * @param out flux de sortie/*from  w  w w.  java  2s  .  c om*/
 * @throws DocumentException Exception
 */
public final void exportData(final Export export, final OutputStream out) throws DocumentException {
    // step 1: creation of a document-object
    final boolean landscape = export.getOrientation() == Export.Orientation.Landscape;
    final Rectangle pageSize = landscape ? PageSize.A4.rotate() : PageSize.A4;
    final Document document = new Document(pageSize, 20, 20, 50, 50); // left,
    // right,
    // top,
    // bottom
    // step 2: we create a writer that listens to the document and directs a
    // PDF-stream to out
    createWriter(document, out);

    // we add some meta information to the document, and we open it
    final String title = export.getTitle();
    if (title != null) {
        final HeaderFooter header = new HeaderFooter(new Phrase(title), false);
        header.setAlignment(Element.ALIGN_LEFT);
        header.setBorder(Rectangle.NO_BORDER);
        document.setHeader(header);
        document.addTitle(title);
    }

    final String author = export.getAuthor();
    document.addAuthor(author);
    document.addCreator(CREATOR);
    document.open();
    try {
        // pour ajouter l'ouverture automatique de la bote de dialogue
        // imprimer
        // (print(false) pour imprimer directement)
        // ((PdfWriter) writer).addJavaScript("this.print(true);", false);

        for (final ExportSheet exportSheet : export.getSheets()) {
            final Table datatable;
            if (exportSheet.hasDtObject()) {
                // table
                datatable = new Table(2);
                datatable.setCellsFitPage(true);
                datatable.setPadding(4);
                datatable.setSpacing(0);

                // data rows
                renderObject(exportSheet, datatable);
            } else {
                // table
                datatable = new Table(exportSheet.getExportFields().size());
                datatable.setCellsFitPage(true);
                datatable.setPadding(4);
                datatable.setSpacing(0);

                // headers
                renderHeaders(exportSheet, datatable);

                // data rows
                renderList(exportSheet, datatable);
            }
            document.add(datatable);
        }
    } finally {
        // we close the document
        document.close();
    }
}

From source file:io.vertigo.quarto.plugins.export.pdfrtf.AbstractExporterIText.java

License:Apache License

/**
 * Mthode principale qui gre l'export d'un tableau vers un fichier ODS.
 *
 * @param export paramtres du document  exporter
 * @param out flux de sortie/*w  ww  .  j  a  va 2  s.c om*/
 * @throws DocumentException Exception
 */
public final void exportData(final Export export, final OutputStream out) throws DocumentException {
    // step 1: creation of a document-object
    final boolean landscape = export.getOrientation() == Export.Orientation.Landscape;
    final Rectangle pageSize = landscape ? PageSize.A4.rotate() : PageSize.A4;
    final Document document = new Document(pageSize, 20, 20, 50, 50); // left, right, top, bottom
    // step 2: we create a writer that listens to the document and directs a PDF-stream to out
    createWriter(document, out);

    // we add some meta information to the document, and we open it
    final String title = export.getTitle();
    if (title != null) {
        final HeaderFooter header = new HeaderFooter(new Phrase(title), false);
        header.setAlignment(Element.ALIGN_LEFT);
        header.setBorder(Rectangle.NO_BORDER);
        document.setHeader(header);
        document.addTitle(title);
    }

    final String author = export.getAuthor();
    document.addAuthor(author);
    document.addCreator(CREATOR);
    document.open();
    try {
        // pour ajouter l'ouverture automatique de la bote de dialogue imprimer (print(false) pour imprimer directement)
        // ((PdfWriter) writer).addJavaScript("this.print(true);", false);

        for (final ExportSheet exportSheet : export.getSheets()) {
            final Table datatable;
            if (exportSheet.hasDtObject()) {
                // table
                datatable = new Table(2);
                datatable.setCellsFitPage(true);
                datatable.setPadding(4);
                datatable.setSpacing(0);

                // data rows
                renderObject(exportSheet, datatable);
            } else {
                // table
                datatable = new Table(exportSheet.getExportFields().size());
                datatable.setCellsFitPage(true);
                datatable.setPadding(4);
                datatable.setSpacing(0);

                // headers
                renderHeaders(exportSheet, datatable);

                // data rows
                renderList(exportSheet, datatable);
            }
            document.add(datatable);
        }
    } finally {
        // we close the document
        document.close();
    }
}

From source file:it.govpay.web.console.pagamenti.gde.exporter.PdfExporter.java

License:Open Source License

private static void addMetaData(Document document) {
    document.addTitle("Report Eventi");
    document.addSubject("Report Eventi selezionati nella console Govpay");
    document.addKeywords("Report, Eventi, Govpay");
    document.addAuthor("Govpay");
    document.addCreator("Govpay");
}

From source file:it.pdfsam.console.MainConsole.java

License:Open Source License

/**
 * Sets the Meta data "Creator" of the document
 * @param doc_to_set The document to set the creator
 *//*  www  .  j  a  va 2  s  .  c o  m*/
public static void setDocumentCreator(Document doc_to_set) {
    doc_to_set.addCreator(MainConsole.CREATOR);
}

From source file:jdbreport.model.io.pdf.itext2.PdfWriter.java

License:Apache License

public void save(OutputStream out, ReportBook reportBook) throws SaveReportException {

    double oldScaleX = GraphicUtil.getScaleX();
    double oldScaleY = GraphicUtil.getScaleY();
    try {//from   ww  w . ja v  a 2  s.  c o  m
        GraphicUtil.setScaleX(1);
        GraphicUtil.setScaleY(1);

        ReportPage pageFormat;
        int i = 0;
        while (i < reportBook.size() - 1 && !reportBook.getReportModel(i).isVisible()) {
            i++;
        }

        pageFormat = reportBook.getReportModel(i).getReportPage();

        Paper paper = pageFormat.getPaper();
        Rectangle pageSize = new Rectangle(Math.round((float) paper.getWidth()),
                Math.round((float) paper.getHeight()));
        if (pageFormat.getOrientation() == ReportPage.LANDSCAPE) {
            pageSize = pageSize.rotate();
        }
        Document document = new Document(pageSize, Math.round((float) pageFormat.getLeftMargin(Units.PT)),
                Math.round((float) pageFormat.getRightMargin(Units.PT)),
                Math.round((float) pageFormat.getTopMargin(Units.PT)),
                Math.round((float) pageFormat.getBottomMargin(Units.PT)));
        try {
            com.lowagie.text.pdf.PdfWriter.getInstance(document, out);
            document.addTitle(reportBook.getReportCaption());
            document.addCreator("JDBReport using iText");
            document.addAuthor(System.getProperty("user.name"));
            document.open();
            int listCount = 0;
            try {
                for (ReportModel model : reportBook) {
                    if (model.isVisible()) {
                        listCount = saveSheet(document, listCount, model);
                    }
                }
                document.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        } catch (DocumentException e) {
            throw new SaveReportException(e);
        }
    } finally {
        GraphicUtil.setScaleX(oldScaleX);
        GraphicUtil.setScaleY(oldScaleY);
    }
}

From source file:mesquite.lib.MesquitePDFFile.java

License:Open Source License

/**
 *@arg document Document object representing the output file
 * Add metadata to the PDF fle/*from w  w w  .  java 2s . c  om*/
 */
private void addMetaData(Document document) {
    document.addCreator(
            "Mesquite " + MesquiteModule.getMesquiteVersion() + " using portions of " + document.getVersion());
    try {
        String uname = System.getProperty("user.name");
        document.addAuthor(uname);
    } catch (SecurityException e) {
        document.addAuthor("Unknown");
    }
    document.addKeywords("Mesquite"); // more later
    //document.addTitle(this.component.getParent().getName());  // ToDo: get the window's actual title 
}

From source file:mitm.common.pdf.MessagePDFBuilder.java

License:Open Source License

private Document createDocument() throws DocumentException {
    Rectangle pageSize = new Rectangle(documentWidth, documentHeight);

    pageSize.setGrayFill(grayFill);//from w  w w. j a  v  a  2s  .  co m

    Document document = new Document(pageSize, marginLeft, marginRight, marginTop, marginBottom);

    document.addCreator(CREATOR);

    return document;
}

From source file:net.bull.javamelody.internal.web.pdf.PdfDocumentFactory.java

License:Apache License

Document createDocument(boolean landscape) throws DocumentException, IOException {
    // creation of a document-object
    final Rectangle pageSize = getPageSize(landscape);
    // marges de 20  gauche,  droite et en haut pour bien utiliser la largeur
    // et avoir une meilleur lisibilit sur les tableaux larges,
    // mais marge de 40 en bas pour ne pas empiter sur les numros de pages
    final Document document = new Document(pageSize, 20, 20, 20, 40);

    final String title;
    if (range == null) {
        title = I18N.getFormattedString("Monitoring_sur", application);
    } else {// w  w w.  j a v a 2 s  .  com
        title = I18N.getFormattedString("Monitoring_sur", application) + " - " + range.getLabel();
    }
    createWriter(document, title);

    // we add some meta information to the document (after writer)
    document.addAuthor(application);
    document.addCreator("JavaMelody par E. Vernat, https://github.com/javamelody/javamelody/wiki");
    document.addTitle(title);
    return document;
}

From source file:net.bull.javamelody.PdfDocumentFactory.java

License:Apache License

Document createDocument(boolean landscape) throws DocumentException, IOException {
    // creation of a document-object
    final Rectangle pageSize = getPageSize(landscape);
    // marges de 20  gauche,  droite et en haut pour bien utiliser la largeur
    // et avoir une meilleur lisibilit sur les tableaux larges,
    // mais marge de 40 en bas pour ne pas empiter sur les numros de pages
    final Document document = new Document(pageSize, 20, 20, 20, 40);

    final String title;
    if (range == null) {
        title = I18N.getFormattedString("Monitoring_sur", application);
    } else {/*from   ww  w . j a v a2s  . c  om*/
        title = I18N.getFormattedString("Monitoring_sur", application) + " - " + range.getLabel();
    }
    createWriter(document, title);

    // we add some meta information to the document (after writer)
    document.addAuthor(application);
    document.addCreator("JavaMelody par E. Vernat, http://javamelody.googlecode.com");
    document.addTitle(title);
    return document;
}