Example usage for com.lowagie.text PageSize A3

List of usage examples for com.lowagie.text PageSize A3

Introduction

In this page you can find the example usage for com.lowagie.text PageSize A3.

Prototype

Rectangle A3

To view the source code for com.lowagie.text PageSize A3.

Click Source Link

Document

This is the a3 format

Usage

From source file:org.geomajas.plugin.printing.command.print.PrintGetTemplateCommand.java

License:Open Source License

private float getPageSizeRelativeToA3(PrintGetTemplateRequest request) {
    Rectangle r;//from   w w w.j  a  va2 s .  c  o  m
    if (request.getPageSize() != null) {
        r = PageSize.getRectangle(request.getPageSize());
    } else {
        float width = request.getTemplate().getPage().getLayoutConstraint().getWidth();
        float height = request.getTemplate().getPage().getLayoutConstraint().getHeight();
        r = new Rectangle(0, 0, width, height);
    }
    return (r.getWidth() / PageSize.A3.getWidth() + r.getHeight() / PageSize.A3.getHeight()) / 2;
}

From source file:org.kitodo.production.services.data.ProcessService.java

License:Open Source License

/**
 * Generate result as PDF./*from   w ww.  j  av a  2 s.  com*/
 *
 * @param filter
 *            for generating search results
 */
public void generateResultAsPdf(String filter) throws DocumentException, IOException {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    if (!facesContext.getResponseComplete()) {
        ExternalContext response = prepareHeaderInformation(facesContext, "search.pdf");
        try (OutputStream out = response.getResponseOutputStream()) {
            SearchResultGeneration sr = new SearchResultGeneration(filter, this.showClosedProcesses,
                    this.showInactiveProjects);
            HSSFWorkbook wb = sr.getResult();
            List<List<HSSFCell>> rowList = new ArrayList<>();
            HSSFSheet mySheet = wb.getSheetAt(0);
            Iterator<Row> rowIter = mySheet.rowIterator();
            while (rowIter.hasNext()) {
                HSSFRow myRow = (HSSFRow) rowIter.next();
                Iterator<Cell> cellIter = myRow.cellIterator();
                List<HSSFCell> row = new ArrayList<>();
                while (cellIter.hasNext()) {
                    HSSFCell myCell = (HSSFCell) cellIter.next();
                    row.add(myCell);
                }
                rowList.add(row);
            }
            Document document = new Document();
            Rectangle rectangle = new Rectangle(PageSize.A3.getHeight(), PageSize.A3.getWidth());
            PdfWriter.getInstance(document, out);
            document.setPageSize(rectangle);
            document.open();
            if (!rowList.isEmpty()) {
                Paragraph paragraph = new Paragraph(rowList.get(0).get(0).toString());
                document.add(paragraph);
                document.add(getPdfTable(rowList));
            }

            document.close();
            out.flush();
            facesContext.responseComplete();
        }
    }
}

From source file:org.locationtech.udig.printing.ui.pdf.ExportPDFWizard.java

License:Open Source License

/**
 * converts a page size "name" (such as "A3" or "A4" into a 
 * rectangle object that iText will understand.
 *///from w  w  w.j ava  2s  .  c o m
private Rectangle getITextPageSize(String pageSizeName) {
    if (pageSizeName.equals("A3")) //$NON-NLS-1$
        return PageSize.A3;
    if (pageSizeName.equals("A4")) //$NON-NLS-1$
        return PageSize.A4;
    throw new IllegalArgumentException(pageSizeName + " is not a supported page size"); //$NON-NLS-1$
}

From source file:org.locationtech.udig.printing.ui.pdf.PrintWizard.java

License:Open Source License

/**
 * converts a page size "name" (such as "A3" or "A4" into a 
 * rectangle object that iText will understand.
 *///w  ww .  j  a v  a 2s .  c o  m
private Rectangle getITextPageSize(String pageSizeName) {
    if (pageSizeName.equals("A3")) //$NON-NLS-1$
        return PageSize.A3;
    if (pageSizeName.equals("A4")) //$NON-NLS-1$
        return PageSize.A4;
    if (pageSizeName.equals("Letter"))
        return PageSize.LETTER;
    throw new IllegalArgumentException(pageSizeName + " is not a supported page size"); //$NON-NLS-1$
}

From source file:org.tn5250j.spoolfile.SpoolExportWizard.java

License:Open Source License

/**
 * Open the correct type of output file depending on selection(s)
 *///  ww w  .  j  a va2 s  .c o m
public void openOutputFile() {

    try {

        // update status
        updateStatus("Opening File");

        // default to txt extention
        String suffix = ".txt";
        String fileName = "";

        // if pdf then change to pdf extenstion
        if (cvtType.getSelectedIndex() == 0)
            suffix = ".pdf";

        // for e-mailing setup a temporary file
        if (email.isSelected()) {
            File dir = new File(System.getProperty("user.dir"));

            //  setup the temp file name
            String tempFile = spooledFile.getText().trim() + '_' + jobName.getText().trim() + '_'
                    + user.getText().trim() + '_' + spooledFileNumber.getText().trim() + '_'
                    + number.getText().trim();

            // create the temporary file
            File f = File.createTempFile(tempFile, suffix, dir);

            System.out.println(f.getName());
            System.out.println(f.getCanonicalPath());

            conicalPath = f.getCanonicalPath();

            // set it to delete on exit
            f.deleteOnExit();

            // create the file
            fw = new FileOutputStream(f);
        } else

        if (ifs.isSelected()) {
            fileName = ifsPathInfo.getText().trim();
            ifsfw = new IFSFileOutputStream(splfile.getSystem(), fileName);
        } else {
            fileName = pcPathInfo.getText().trim();
            fw = new FileOutputStream(fileName);
        }

        // if not PDF then this is all we have to do so return
        if (cvtType.getSelectedIndex() > 0)
            return;

        // On pdf's then we need to create a PDF document
        if (document == null) {

            document = new Document();

            // create the pdf writer based on selection of pc or ifs file
            if (ifs.isSelected()) {
                bos = PdfWriter.getInstance(document, ifsfw);
            } else {
                bos = PdfWriter.getInstance(document, fw);
            }

            // create the base font
            BaseFont bf = BaseFont.createFont("Courier", "Cp1252", false);

            // set the default size of the font to 9.0
            float fontsize = 9.0f;

            // if we have a font selectd then try to use it
            if (fontSize.getText().length() > 0)
                fontsize = Float.parseFloat(fontSize.getText().trim());

            // create the pdf font to use within the document
            font = new com.lowagie.text.Font(bf, fontsize, com.lowagie.text.Font.NORMAL);

            // set the PDF properties of the supplied properties
            if (author.getText().length() > 0)
                document.addAuthor(author.getText());
            if (title.getText().length() > 0)
                document.addTitle(title.getText());
            if (subject.getText().length() > 0)
                document.addSubject(subject.getText());

            // set the page sizes and the page orientation
            String ps = (String) pageSize.getSelectedItem();

            if (ps.equals("A3")) {
                if (portrait.isSelected())
                    document.setPageSize(PageSize.A3);
                else
                    document.setPageSize(PageSize.A3.rotate());

            }

            if (ps.equals("A4")) {
                if (portrait.isSelected())
                    document.setPageSize(PageSize.A4);
                else
                    document.setPageSize(PageSize.A4.rotate());
            }

            if (ps.equals("A5")) {
                if (portrait.isSelected())
                    document.setPageSize(PageSize.A5);
                else
                    document.setPageSize(PageSize.A5.rotate());
            }
            if (ps.equals("LETTER")) {
                if (portrait.isSelected())
                    document.setPageSize(PageSize.LETTER);
                else
                    document.setPageSize(PageSize.LETTER.rotate());
            }
            if (ps.equals("LEGAL")) {
                if (portrait.isSelected())
                    document.setPageSize(PageSize.LEGAL);
                else
                    document.setPageSize(PageSize.LEGAL.rotate());
            }
            if (ps.equals("LEDGER")) {
                if (portrait.isSelected())
                    document.setPageSize(PageSize.LEDGER);
                else
                    document.setPageSize(PageSize.LEDGER.rotate());
            }
        }
    } catch (IOException _ex) {
        System.out.println("Cannot open 1 " + _ex.getMessage());

    } catch (Exception _ex2) {
        System.out.println("Cannot open 2 " + _ex2.getMessage());
    }

}