Example usage for com.itextpdf.text PageSize A1

List of usage examples for com.itextpdf.text PageSize A1

Introduction

In this page you can find the example usage for com.itextpdf.text PageSize A1.

Prototype

Rectangle A1

To view the source code for com.itextpdf.text PageSize A1.

Click Source Link

Document

This is the a1 format

Usage

From source file:br.com.ifrn.panfleto.gui.PainelCadastrar.java

public Rectangle tamanhoDaPagina() {
    if (comboxSelecionarTamanhoPaginaPainelGerarPdf.getSelectedItem().equals("A0")) {
        return new Rectangle(PageSize.A0);
    } else if (comboxSelecionarTamanhoPaginaPainelGerarPdf.getSelectedItem().equals("A1")) {
        return new Rectangle(PageSize.A1);
    } else if (comboxSelecionarTamanhoPaginaPainelGerarPdf.getSelectedItem().equals("A2")) {
        return new Rectangle(PageSize.A2);
    } else if (comboxSelecionarTamanhoPaginaPainelGerarPdf.getSelectedItem().equals("A3")) {
        return new Rectangle(PageSize.A3);
    } else if (comboxSelecionarTamanhoPaginaPainelGerarPdf.getSelectedItem().equals("A4")) {
        return new Rectangle(PageSize.A4);
    } else if (comboxSelecionarTamanhoPaginaPainelGerarPdf.getSelectedItem().equals("A5")) {
        return new Rectangle(PageSize.A5);
    } else if (comboxSelecionarTamanhoPaginaPainelGerarPdf.getSelectedItem().equals("B0")) {
        return new Rectangle(PageSize.B0);
    } else if (comboxSelecionarTamanhoPaginaPainelGerarPdf.getSelectedItem().equals("B1")) {
        return new Rectangle(PageSize.B1);
    } else if (comboxSelecionarTamanhoPaginaPainelGerarPdf.getSelectedItem().equals("B2")) {
        return new Rectangle(PageSize.B2);
    } else if (comboxSelecionarTamanhoPaginaPainelGerarPdf.getSelectedItem().equals("B3")) {
        return new Rectangle(PageSize.B3);
    } else if (comboxSelecionarTamanhoPaginaPainelGerarPdf.getSelectedItem().equals("B4")) {
        return new Rectangle(PageSize.B4);
    } else if (comboxSelecionarTamanhoPaginaPainelGerarPdf.getSelectedItem().equals("B5")) {
        return new Rectangle(PageSize.B5);
    }//w  w  w.ja  v a2 s. c o m

    //caso erro, retorna o tamanho a4 como padrao
    return new Rectangle(PageSize.A4);
}

From source file:com.base2.kagura.core.ExportHandler.java

License:Apache License

/**
 * Takes the output and transforms it into a PDF file.
 * @param out Output stream./*from   w  ww .  j a  va2s. c  o m*/
 * @param rows Rows of data from reporting-core
 * @param columns Columns to list on report
 */
public void generatePdf(OutputStream out, List<Map<String, Object>> rows, List<ColumnDef> columns) {
    try {
        Document document = new Document();
        PdfWriter.getInstance(document, out);
        if (columns == null) {
            if (rows.size() > 0)
                return;
            columns = new ArrayList<ColumnDef>(CollectionUtils.collect(rows.get(0).keySet(), new Transformer() {
                @Override
                public Object transform(final Object input) {
                    return new ColumnDef() {
                        {
                            setName((String) input);
                        }
                    };
                }
            }));
        }
        if (columns.size() > 14)
            document.setPageSize(PageSize.A1);
        else if (columns.size() > 10)
            document.setPageSize(PageSize.A2);
        else if (columns.size() > 7)
            document.setPageSize(PageSize.A3);
        else
            document.setPageSize(PageSize.A4);
        document.open();
        Font font = FontFactory.getFont(FontFactory.COURIER, 8, Font.NORMAL, BaseColor.BLACK);
        Font headerFont = FontFactory.getFont(FontFactory.COURIER, 8, Font.BOLD, BaseColor.BLACK);

        int size = columns.size();
        PdfPTable table = new PdfPTable(size);
        for (ColumnDef column : columns) {
            PdfPCell c1 = new PdfPCell(new Phrase(column.getName(), headerFont));
            c1.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(c1);
        }
        table.setHeaderRows(1);
        if (rows != null)
            for (Map<String, Object> row : rows) {
                for (ColumnDef column : columns) {
                    table.addCell(new Phrase(String.valueOf(row.get(column.getName())), font));
                }
            }
        document.add(table);
        document.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:org.fhaes.neofhchart.PDFExportOptionsDialog.java

License:Open Source License

/**
 * Handles when actions are performed on the dialog.
 *///w  w  w. java2 s  .  c o m
@Override
public void actionPerformed(ActionEvent evt) {

    if (evt.getActionCommand().equals("OK")) {
        // Perform the export operation
        boolean completedSuccessfully = doExportToPDF();

        if (completedSuccessfully) {
            MainWindow.getInstance().getFeedbackMessagePanel().updateFeedbackMessage(FeedbackMessageType.INFO,
                    FeedbackDisplayProtocol.AUTO_HIDE,
                    FeedbackDictionary.NEOFHCHART_PDF_EXPORT_MESSAGE.toString());
        } else {
            MainWindow.getInstance().getFeedbackMessagePanel().updateFeedbackMessage(FeedbackMessageType.ERROR,
                    FeedbackDisplayProtocol.MANUAL_HIDE,
                    "An error occured while attempting to export chart as PDF.");
        }

        this.dispose();
    } else if (evt.getActionCommand().equals("Cancel")) {
        // Close the dialog
        this.dispose();
    } else if (evt.getActionCommand().equals("PaperSize")) {
        // Update the paper size label
        if (this.cboPaperSize.getSelectedItem() instanceof Rectangle) {
            Object value = this.cboPaperSize.getSelectedItem();
            if (value.equals(PageSize.A5)) {
                this.lblSize.setText("148 x 210mm  /  5.83 x 8.27\"");
            } else if (value.equals(PageSize.A4)) {
                this.lblSize.setText("210 x 297mm  /  8.27 x 11.7\"");
            } else if (value.equals(PageSize.A3)) {
                this.lblSize.setText("297 x 420mm  /  11.7 x 16.5\"");
            } else if (value.equals(PageSize.A2)) {
                this.lblSize.setText("420 x 594mm  /  16.5 x 23.4\"");
            } else if (value.equals(PageSize.A1)) {
                this.lblSize.setText("594 x 841mm  /  23.4 x 33.1\"");
            } else if (value.equals(PageSize.A0)) {
                this.lblSize.setText("841 x 1189mm  /  33.1 x 46.8\"");
            } else if (value.equals(PageSize.LETTER)) {
                this.lblSize.setText("215.9 x 279.4mm  /  8.5 x 11\"");
            } else if (value.equals(PageSize.LEGAL)) {
                this.lblSize.setText("215.9 x 355.6mm  /  8.5 x 14\"");
            } else if (value.equals(PageSize.EXECUTIVE)) {
                this.lblSize.setText("184 x 267mm  /  7.25 x 10.5\"");
            } else {
                this.lblSize.setText("");
            }

            radLandscape.setEnabled(true);
            radPortrait.setEnabled(true);
        } else {
            this.lblSize.setText("");
            radLandscape.setEnabled(false);
            radPortrait.setEnabled(false);
        }
    }
}

From source file:org.gephi.ui.exporter.preview.UIExporterPDFPanel.java

License:Open Source License

public UIExporterPDFPanel() {
    initComponents();/* ww w .  j ava2  s.  c o  m*/

    sizeFormatter = NumberFormat.getNumberInstance();
    sizeFormatter.setMaximumFractionDigits(3);
    marginFormatter = NumberFormat.getNumberInstance();
    marginFormatter.setMaximumFractionDigits(1);

    //Page size model - http://en.wikipedia.org/wiki/Paper_size
    DefaultComboBoxModel comboBoxModel = new DefaultComboBoxModel();
    comboBoxModel.addElement(new PageSizeItem(PageSize.A0, "A0", 841, 1189, 33.1, 46.8));
    comboBoxModel.addElement(new PageSizeItem(PageSize.A1, "A1", 594, 841, 23.4, 33.1));
    comboBoxModel.addElement(new PageSizeItem(PageSize.A2, "A2", 420, 594, 16.5, 23.4));
    comboBoxModel.addElement(new PageSizeItem(PageSize.A3, "A3", 297, 420, 11.7, 16.5));
    comboBoxModel.addElement(new PageSizeItem(PageSize.A4, "A4", 210, 297, 8.3, 11.7));
    comboBoxModel.addElement(new PageSizeItem(PageSize.A5, "A5", 148, 210, 5.8, 8.3));
    comboBoxModel.addElement(new PageSizeItem(PageSize.ARCH_A, "ARCH A", 229, 305, 9, 12));
    comboBoxModel.addElement(new PageSizeItem(PageSize.ARCH_B, "ARCH B", 305, 457, 12, 18));
    comboBoxModel.addElement(new PageSizeItem(PageSize.ARCH_C, "ARCH C", 457, 610, 18, 24));
    comboBoxModel.addElement(new PageSizeItem(PageSize.ARCH_D, "ARCH D", 610, 914, 24, 36));
    comboBoxModel.addElement(new PageSizeItem(PageSize.ARCH_E, "ARCH E", 914, 1219, 36, 48));
    comboBoxModel.addElement(new PageSizeItem(PageSize.B0, "B0", 1000, 1414, 39.4, 55.7));
    comboBoxModel.addElement(new PageSizeItem(PageSize.B1, "B1", 707, 1000, 27.8, 39.4));
    comboBoxModel.addElement(new PageSizeItem(PageSize.B2, "B2", 500, 707, 19.7, 27.8));
    comboBoxModel.addElement(new PageSizeItem(PageSize.B3, "B3", 353, 500, 13.9, 19.7));
    comboBoxModel.addElement(new PageSizeItem(PageSize.B4, "B4", 250, 353, 9.8, 13.9));
    comboBoxModel.addElement(new PageSizeItem(PageSize.B5, "B5", 176, 250, 6.9, 9.8));
    comboBoxModel.addElement(new PageSizeItem(PageSize.LEDGER, "Ledger", 432, 279, 17, 11));
    comboBoxModel.addElement(new PageSizeItem(PageSize.LEGAL, "Legal", 216, 356, 8.5, 14));
    comboBoxModel.addElement(new PageSizeItem(PageSize.LETTER, "Letter", 216, 279, 8.5, 11));
    comboBoxModel.addElement(new PageSizeItem(PageSize.TABLOID, "Tabloid", 279, 432, 11, 17));

    customSizeString = NbBundle.getMessage(UIExporterPDFPanel.class, "UIExporterPDFPanel.pageSize.custom");
    comboBoxModel.addElement(customSizeString);
    pageSizeCombo.setModel(comboBoxModel);

    loadPreferences();

    initEvents();
    refreshUnit(false);
}

From source file:org.saiku.web.export.PdfReport.java

License:Apache License

public byte[] pdf(QueryResult qr, String svg) throws Exception {

    int resultWidth = qr != null && qr.getCellset() != null && qr.getCellset().size() > 0
            ? qr.getCellset().get(0).length
            : 0;/*  ww  w .  j  ava 2  s.c  o m*/
    if (resultWidth == 0) {
        throw new SaikuServiceException("Cannot convert empty result to PDF");
    }
    Rectangle size = PageSize.A4.rotate();
    if (resultWidth > 8) {
        size = PageSize.A3.rotate();
    }
    if (resultWidth > 16) {
        size = PageSize.A2.rotate();
    }
    if (resultWidth > 32) {
        size = PageSize.A1.rotate();
    }
    if (resultWidth > 64) {
        size = PageSize.A0.rotate();
    }

    Document document = new Document(size, 15, 15, 10, 10);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PdfWriter writer = PdfWriter.getInstance(document, baos);
    document.open();
    populatePdf(document, writer, qr);

    // do we want to add a svg image?
    if (StringUtils.isNotBlank(svg)) {
        document.newPage();
        StringBuffer s1 = new StringBuffer(svg);
        if (!svg.startsWith("<svg xmlns=\"http://www.w3.org/2000/svg\" ")) {
            s1.insert(s1.indexOf("<svg") + 4, " xmlns='http://www.w3.org/2000/svg'");
        }

        String t = "<?xml version='1.0' encoding='ISO-8859-1'" + " standalone='no'?>" + s1.toString();
        PdfContentByte cb = writer.getDirectContent();
        cb.saveState();
        cb.concatCTM(1.0f, 0, 0, 1.0f, 36, 0);
        float width = document.getPageSize().getWidth() - 20;
        float height = document.getPageSize().getHeight() - 20;
        Graphics2D g2 = cb.createGraphics(width, height);
        //g2.rotate(Math.toRadians(-90), 100, 100);
        PrintTranscoder prm = new PrintTranscoder();
        TranscoderInput ti = new TranscoderInput(new StringReader(t));
        prm.transcode(ti, null);
        PageFormat pg = new PageFormat();
        Paper pp = new Paper();
        pp.setSize(width, height);
        pp.setImageableArea(5, 5, width, height);
        pg.setPaper(pp);
        prm.print(g2, pg, 0);
        g2.dispose();
        cb.restoreState();
    }

    document.close();
    return baos.toByteArray();
}