Example usage for com.lowagie.text PageSize A6

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

Introduction

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

Prototype

Rectangle A6

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

Click Source Link

Document

This is the a6 format

Usage

From source file:include.nseer_cookie.printPDF.java

License:Open Source License

public Document print_type_across(String print_type, int print_left, int print_right, int print_top,
        int print_bottom) {

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

        if (print_type.equals("A0"))
            document = new Document(PageSize.A0.rotate(), print_left, print_right, print_top, print_bottom);
        if (print_type.equals("A1"))
            document = new Document(PageSize.A1.rotate(), print_left, print_right, print_top, print_bottom);
        if (print_type.equals("A2"))
            document = new Document(PageSize.A2.rotate(), print_left, print_right, print_top, print_bottom);
        if (print_type.equals("A3"))
            document = new Document(PageSize.A3.rotate(), print_left, print_right, print_top, print_bottom);
        if (print_type.equals("A4"))
            document = new Document(PageSize.A4.rotate(), print_left, print_right, print_top, print_bottom);
        if (print_type.equals("A5"))
            document = new Document(PageSize.A5.rotate(), print_left, print_right, print_top, print_bottom);
        if (print_type.equals("A6"))
            document = new Document(PageSize.A6.rotate(), print_left, print_right, print_top, print_bottom);
        if (print_type.equals("A7"))
            document = new Document(PageSize.A7.rotate(), print_left, print_right, print_top, print_bottom);
        if (print_type.equals("A8"))
            document = new Document(PageSize.A8.rotate(), print_left, print_right, print_top, print_bottom);
        if (print_type.equals("A9"))
            document = new Document(PageSize.A9.rotate(), print_left, print_right, print_top, print_bottom);
        if (print_type.equals("B0"))
            document = new Document(PageSize.B0.rotate(), print_left, print_right, print_top, print_bottom);
        if (print_type.equals("B1"))
            document = new Document(PageSize.B1.rotate(), print_left, print_right, print_top, print_bottom);
        if (print_type.equals("B2"))
            document = new Document(PageSize.B2.rotate(), print_left, print_right, print_top, print_bottom);
        if (print_type.equals("B3"))
            document = new Document(PageSize.B3.rotate(), print_left, print_right, print_top, print_bottom);
        if (print_type.equals("B4"))
            document = new Document(PageSize.B4.rotate(), print_left, print_right, print_top, print_bottom);
        if (print_type.equals("B5"))
            document = new Document(PageSize.B5.rotate(), print_left, print_right, print_top, print_bottom);
        if (print_type.equals("ARCH_A"))
            document = new Document(PageSize.ARCH_A.rotate(), print_left, print_right, print_top, print_bottom);
        if (print_type.equals("ARCH_B"))
            document = new Document(PageSize.ARCH_B.rotate(), print_left, print_right, print_top, print_bottom);
        if (print_type.equals("ARCH_C"))
            document = new Document(PageSize.ARCH_C.rotate(), print_left, print_right, print_top, print_bottom);
        if (print_type.equals("ARCH_D"))
            document = new Document(PageSize.ARCH_D.rotate(), print_left, print_right, print_top, print_bottom);
        if (print_type.equals("ARCH_E"))
            document = new Document(PageSize.ARCH_E.rotate(), print_left, print_right, print_top, print_bottom);
        if (print_type.equals("FLSA"))
            document = new Document(PageSize.FLSA.rotate(), print_left, print_right, print_top, print_bottom);
        if (print_type.equals("FLSE"))
            document = new Document(PageSize.FLSE.rotate(), print_left, print_right, print_top, print_bottom);
        if (print_type.equals("NOTE"))
            document = new Document(PageSize.NOTE.rotate(), print_left, print_right, print_top, print_bottom);
        if (print_type.equals("_11X17"))
            document = new Document(PageSize._11X17.rotate(), print_left, print_right, print_top, print_bottom);
        if (print_type.equals("LETTER"))
            document = new Document(PageSize.LETTER.rotate(), print_left, print_right, print_top, print_bottom);
        if (print_type.equals("HALFLETTER"))
            document = new Document(PageSize.HALFLETTER.rotate(), print_left, print_right, print_top,
                    print_bottom);
        if (print_type.equals("LEDGER"))
            document = new Document(PageSize.LEDGER.rotate(), print_left, print_right, print_top, print_bottom);

    } catch (Exception e) {
        e.printStackTrace();
    }
    return document;
}

From source file:include.nseer_cookie.printPDF.java

License:Open Source License

public Document print_type_vertical(String print_type, int print_left, int print_right, int print_top,
        int print_bottom) {

    try {//  w w  w .j  a va2 s .co m
        if (print_type.equals("A0"))
            document = new Document(PageSize.A0, print_left, print_right, print_top, print_bottom);
        if (print_type.equals("A1"))
            document = new Document(PageSize.A1, print_left, print_right, print_top, print_bottom);
        if (print_type.equals("A2"))
            document = new Document(PageSize.A2, print_left, print_right, print_top, print_bottom);
        if (print_type.equals("A3"))
            document = new Document(PageSize.A3, print_left, print_right, print_top, print_bottom);
        if (print_type.equals("A4"))
            document = new Document(PageSize.A4, print_left, print_right, print_top, print_bottom);
        if (print_type.equals("A5"))
            document = new Document(PageSize.A5, print_left, print_right, print_top, print_bottom);
        if (print_type.equals("A6"))
            document = new Document(PageSize.A6, print_left, print_right, print_top, print_bottom);
        if (print_type.equals("A7"))
            document = new Document(PageSize.A7, print_left, print_right, print_top, print_bottom);
        if (print_type.equals("A8"))
            document = new Document(PageSize.A8, print_left, print_right, print_top, print_bottom);
        if (print_type.equals("A9"))
            document = new Document(PageSize.A9, print_left, print_right, print_top, print_bottom);
        if (print_type.equals("B0"))
            document = new Document(PageSize.B0, print_left, print_right, print_top, print_bottom);
        if (print_type.equals("B1"))
            document = new Document(PageSize.B1, print_left, print_right, print_top, print_bottom);
        if (print_type.equals("B2"))
            document = new Document(PageSize.B2, print_left, print_right, print_top, print_bottom);
        if (print_type.equals("B3"))
            document = new Document(PageSize.B3, print_left, print_right, print_top, print_bottom);
        if (print_type.equals("B4"))
            document = new Document(PageSize.B4, print_left, print_right, print_top, print_bottom);
        if (print_type.equals("B5"))
            document = new Document(PageSize.B5, print_left, print_right, print_top, print_bottom);
        if (print_type.equals("ARCH_A"))
            document = new Document(PageSize.ARCH_A, print_left, print_right, print_top, print_bottom);
        if (print_type.equals("ARCH_B"))
            document = new Document(PageSize.ARCH_B, print_left, print_right, print_top, print_bottom);
        if (print_type.equals("ARCH_C"))
            document = new Document(PageSize.ARCH_C, print_left, print_right, print_top, print_bottom);
        if (print_type.equals("ARCH_D"))
            document = new Document(PageSize.ARCH_D, print_left, print_right, print_top, print_bottom);
        if (print_type.equals("ARCH_E"))
            document = new Document(PageSize.ARCH_E, print_left, print_right, print_top, print_bottom);
        if (print_type.equals("FLSA"))
            document = new Document(PageSize.FLSA, print_left, print_right, print_top, print_bottom);
        if (print_type.equals("FLSE"))
            document = new Document(PageSize.FLSE, print_left, print_right, print_top, print_bottom);
        if (print_type.equals("NOTE"))
            document = new Document(PageSize.NOTE, print_left, print_right, print_top, print_bottom);
        if (print_type.equals("_11X17"))
            document = new Document(PageSize._11X17, print_left, print_right, print_top, print_bottom);
        if (print_type.equals("LETTER"))
            document = new Document(PageSize.LETTER, print_left, print_right, print_top, print_bottom);
        if (print_type.equals("HALFLETTER"))
            document = new Document(PageSize.HALFLETTER, print_left, print_right, print_top, print_bottom);
        if (print_type.equals("LEDGER"))
            document = new Document(PageSize.LEDGER, print_left, print_right, print_top, print_bottom);

    } catch (Exception e) {
        e.printStackTrace();
    }
    return document;
}

From source file:oscar.eform.util.EFormPDFServlet.java

License:Open Source License

private void addDocumentProps(Document document, String title, Properties props) {
    document.addTitle(title);/*from ww w  .  j  ava  2s  .  c  o m*/
    document.addSubject("");
    document.addKeywords("pdf, itext");
    document.addCreator("OSCAR");
    document.addAuthor("");
    document.addHeader("Expires", "0");

    // A0-A10, LEGAL, LETTER, HALFLETTER, _11x17, LEDGER, NOTE, B0-B5, ARCH_A-ARCH_E, FLSA
    // and FLSE
    // the following shows a temp way to get a print page size
    final String PAGESIZE = "printPageSize";
    Rectangle pageSize = PageSize.LETTER;
    if ("PageSize.HALFLETTER".equals(props.getProperty(PAGESIZE)))
        pageSize = PageSize.HALFLETTER;
    if ("PageSize.A6".equals(props.getProperty(PAGESIZE)))
        pageSize = PageSize.A6;
    document.setPageSize(pageSize);
    document.open();
}

From source file:oscar.form.pdfservlet.FrmCustomedPDFServlet.java

License:Open Source License

protected ByteArrayOutputStream generatePDFDocumentBytes(final HttpServletRequest req, final ServletContext ctx)
        throws DocumentException {
    logger.debug("***in generatePDFDocumentBytes2 FrmCustomedPDFServlet.java***");
    // added by vic, hsfo
    Enumeration<String> em = req.getParameterNames();
    while (em.hasMoreElements()) {
        logger.debug("para=" + em.nextElement());
    }/* w  w  w.j  a v  a  2s.com*/
    em = req.getAttributeNames();
    while (em.hasMoreElements())
        logger.debug("attr: " + em.nextElement());

    if (HSFO_RX_DATA_KEY.equals(req.getParameter("__title"))) {
        return generateHsfoRxPDF(req);
    }
    String newline = System.getProperty("line.separator");

    ByteArrayOutputStream baosPDF = new ByteArrayOutputStream();
    PdfWriter writer = null;
    String method = req.getParameter("__method");
    String origPrintDate = null;
    String numPrint = null;
    if (method != null && method.equalsIgnoreCase("rePrint")) {
        origPrintDate = req.getParameter("origPrintDate");
        numPrint = req.getParameter("numPrints");
    }

    logger.debug("method in generatePDFDocumentBytes " + method);
    String clinicName;
    String clinicTel;
    String clinicFax;
    // check if satellite clinic is used
    String useSatelliteClinic = req.getParameter("useSC");
    logger.debug(useSatelliteClinic);
    if (useSatelliteClinic != null && useSatelliteClinic.equalsIgnoreCase("true")) {
        String scAddress = req.getParameter("scAddress");
        logger.debug("clinic detail" + "=" + scAddress);
        HashMap<String, String> hm = parseSCAddress(scAddress);
        clinicName = hm.get("clinicName");
        clinicTel = hm.get("clinicTel");
        clinicFax = hm.get("clinicFax");
    } else {
        // parameters need to be passed to header and footer
        clinicName = req.getParameter("clinicName");
        logger.debug("clinicName" + "=" + clinicName);
        clinicTel = req.getParameter("clinicPhone");
        clinicFax = req.getParameter("clinicFax");
    }
    String patientPhone = req.getParameter("patientPhone");
    String patientCityPostal = req.getParameter("patientCityPostal");
    String patientAddress = req.getParameter("patientAddress");
    String patientName = req.getParameter("patientName");
    String sigDoctorName = req.getParameter("sigDoctorName");
    String rxDate = req.getParameter("rxDate");
    String rx = req.getParameter("rx");
    String patientDOB = req.getParameter("patientDOB");
    String showPatientDOB = req.getParameter("showPatientDOB");
    String imgFile = req.getParameter("imgFile");
    String patientHIN = req.getParameter("patientHIN");
    String patientChartNo = req.getParameter("patientChartNo");
    String pracNo = req.getParameter("pracNo");
    Locale locale = req.getLocale();

    boolean isShowDemoDOB = false;
    if (showPatientDOB != null && showPatientDOB.equalsIgnoreCase("true")) {
        isShowDemoDOB = true;
    }
    if (!isShowDemoDOB)
        patientDOB = "";
    if (rx == null) {
        rx = "";
    }

    String additNotes = req.getParameter("additNotes");
    String[] rxA = rx.split(newline);
    List<String> listRx = new ArrayList<String>();
    String listElem = "";
    // parse rx and put into a list of rx;
    for (String s : rxA) {

        if (s.equals("") || s.equals(newline) || s.length() == 1) {
            listRx.add(listElem);
            listElem = "";
        } else {
            listElem = listElem + s;
            listElem += newline;
        }

    }

    // get the print prop values
    Properties props = new Properties();
    StringBuilder temp = new StringBuilder();
    for (Enumeration<String> e = req.getParameterNames(); e.hasMoreElements();) {
        temp = new StringBuilder(e.nextElement().toString());
        props.setProperty(temp.toString(), req.getParameter(temp.toString()));
    }

    for (Enumeration<String> e = req.getAttributeNames(); e.hasMoreElements();) {
        temp = new StringBuilder(e.nextElement().toString());
        props.setProperty(temp.toString(), req.getAttribute(temp.toString()).toString());
    }
    Document document = new Document();

    try {
        String title = req.getParameter("__title") != null ? req.getParameter("__title") : "Unknown";

        // specify the page of the picture using __graphicPage, it may be used multiple times to specify multiple pages
        // however the same graphic will be applied to all pages
        // ie. __graphicPage=2&__graphicPage=3
        String[] cfgGraphicFile = req.getParameterValues("__cfgGraphicFile");
        int cfgGraphicFileNo = cfgGraphicFile == null ? 0 : cfgGraphicFile.length;
        if (cfgGraphicFile != null) {
            // for (String s : cfgGraphicFile) {
            // p("cfgGraphicFile", s);
            // }
        }

        String[] graphicPage = req.getParameterValues("__graphicPage");
        ArrayList<String> graphicPageArray = new ArrayList<String>();
        if (graphicPage != null) {
            // for (String s : graphicPage) {
            // p("graphicPage", s);
            // }
            graphicPageArray = new ArrayList<String>(Arrays.asList(graphicPage));
        }

        // A0-A10, LEGAL, LETTER, HALFLETTER, _11x17, LEDGER, NOTE, B0-B5, ARCH_A-ARCH_E, FLSA
        // and FLSE
        // the following shows a temp way to get a print page size
        Rectangle pageSize = PageSize.LETTER;
        String pageSizeParameter = req.getParameter("rxPageSize");
        if (pageSizeParameter != null) {
            if ("PageSize.HALFLETTER".equals(pageSizeParameter)) {
                pageSize = PageSize.HALFLETTER;
            } else if ("PageSize.A6".equals(pageSizeParameter)) {
                pageSize = PageSize.A6;
            } else if ("PageSize.A4".equals(pageSizeParameter)) {
                pageSize = PageSize.A4;
            }
        }
        /*
         * if ("PageSize.HALFLETTER".equals(props.getProperty(PAGESIZE))) { pageSize = PageSize.HALFLETTER; } else if ("PageSize.A6".equals(props.getProperty(PAGESIZE))) { pageSize = PageSize.A6; } else if
         * ("PageSize.A4".equals(props.getProperty(PAGESIZE))) { pageSize = PageSize.A4; }
         */
        // p("size of page ", props.getProperty(PAGESIZE));

        document.setPageSize(pageSize);
        // 285=left margin+width of box, 5f is space for looking nice
        document.setMargins(15, pageSize.getWidth() - 285f + 5f, 170, 60);// left, right, top , bottom

        writer = PdfWriter.getInstance(document, baosPDF);
        writer.setPageEvent(new EndPage(clinicName, clinicTel, clinicFax, patientPhone, patientCityPostal,
                patientAddress, patientName, patientDOB, sigDoctorName, rxDate, origPrintDate, numPrint,
                imgFile, patientHIN, patientChartNo, pracNo, locale));
        document.addTitle(title);
        document.addSubject("");
        document.addKeywords("pdf, itext");
        document.addCreator("OSCAR");
        document.addAuthor("");
        document.addHeader("Expires", "0");

        document.open();
        document.newPage();

        PdfContentByte cb = writer.getDirectContent();
        BaseFont bf; // = normFont;

        cb.setRGBColorStroke(0, 0, 255);
        // render prescriptions
        for (String rxStr : listRx) {
            bf = BaseFont.createFont(BaseFont.COURIER, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
            Paragraph p = new Paragraph(new Phrase(rxStr, new Font(bf, 10)));
            p.setKeepTogether(true);
            p.setSpacingBefore(5f);
            document.add(p);
        }
        // render additional notes
        if (additNotes != null && !additNotes.equals("")) {
            bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
            Paragraph p = new Paragraph(new Phrase(additNotes, new Font(bf, 10)));
            p.setKeepTogether(true);
            p.setSpacingBefore(10f);
            document.add(p);
        }
        // render optometristEyeParam
        if (req.getAttribute("optometristEyeParam") != null) {
            bf = BaseFont.createFont(BaseFont.COURIER, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
            Paragraph p = new Paragraph(
                    new Phrase("Eye " + (String) req.getAttribute("optometristEyeParam"), new Font(bf, 10)));
            p.setKeepTogether(true);
            p.setSpacingBefore(15f);
            document.add(p);
        }

        // render QrCode
        if (PrescriptionQrCodeUIBean.isPrescriptionQrCodeEnabledForCurrentProvider()) {
            Integer scriptId = Integer.parseInt(req.getParameter("scriptId"));
            byte[] qrCodeImage = PrescriptionQrCodeUIBean.getPrescriptionHl7QrCodeImage(scriptId);
            Image qrCode = Image.getInstance(qrCodeImage);
            document.add(qrCode);
        }

    } catch (DocumentException dex) {
        baosPDF.reset();
        throw dex;
    } catch (Exception e) {
        logger.error("Error", e);
    } finally {
        if (document != null) {
            document.close();
        }
        if (writer != null) {
            writer.close();
        }
    }
    logger.debug("***END in generatePDFDocumentBytes2 FrmCustomedPDFServlet.java***");
    return baosPDF;
}

From source file:questions.objects.NewPageColumns.java

public static void main(String[] args) {

    // step 1//w w w .j  a v a 2 s  .  c  o  m
    Document document = new Document(PageSize.A6);
    try {
        // step 2
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(RESULT));
        // step 3
        document.open();
        // step 4
        for (int i = 0; i < 25; i++)
            document.add(new Paragraph("Hello paragraph 1." + i));
        document.newPage();
        ColumnText column = new ColumnText(writer.getDirectContent());
        column.setSimpleColumn(PageSize.A6.getLeft(36), PageSize.A6.getBottom(36), PageSize.A6.getRight(36),
                PageSize.A6.getTop(36));
        for (int i = 0; i < 20; i++)
            column.addElement(new Paragraph("Hello column 1." + i));
        int status = column.go();
        while (ColumnText.hasMoreText(status)) {
            document.newPage();
            column.setYLine(PageSize.A6.getTop(36));
            status = column.go();
        }
        document.newPage();
        for (int i = 0; i < 10; i++)
            column.addElement(new Paragraph("Hello column 2." + i));
        status = column.go();
        while (ColumnText.hasMoreText(status)) {
            document.newPage();
            column.setYLine(PageSize.A6.getTop(36));
            status = column.go();
        }
        document.newPage();
        for (int i = 0; i < 5; i++)
            document.add(new Paragraph("Hello paragraph 2." + i));
    } catch (DocumentException de) {
        System.err.println(de.getMessage());
    } catch (IOException ioe) {
        System.err.println(ioe.getMessage());
    }
    // step 5
    document.close();
}