Example usage for com.itextpdf.text Chunk Chunk

List of usage examples for com.itextpdf.text Chunk Chunk

Introduction

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

Prototype

private Chunk(final Float tabInterval, final boolean isWhitespace) 

Source Link

Document

Creates a tab Chunk.

Usage

From source file:org.smap.sdal.managers.PDFTableManager.java

License:Open Source License

private void addKeyValuePair(Document document, String key, String value) throws DocumentException {
    Paragraph para = new Paragraph("", font);

    para.add(new Chunk(GeneralUtilityMethods.unesc(key), fontbold));
    para.add(new Chunk(GeneralUtilityMethods.unesc(value), font));

    document.add(para);//  w  ww. j  av  a2s  .c o m
}

From source file:org.smap.sdal.managers.PDFTableManager.java

License:Open Source License

private void addValue(Document document, String value, float indent) throws DocumentException {

    if (value != null && value.trim().length() > 0) {
        Paragraph para = new Paragraph("", font);
        para.setIndentationLeft(indent);
        para.add(new Chunk(GeneralUtilityMethods.unesc(value), font));
        document.add(para);//from w  ww. ja va2s  .c o  m
    }
}

From source file:PDF.CrearPDF_Ficha.java

public void generarPDF(ServletOutputStream sops, DatosPDF datos, String url) {

    try {/*from   ww w .  j  a v  a  2 s .co m*/

        Document documento = new Document();
        //            ByteArrayOutputStream baos = new ByteArrayOutputStream();
        PdfWriter writer = PdfWriter.getInstance(documento, sops);
        documento.open();

        Image itt_logo;
        try {
            itt_logo = Image.getInstance(url);
            Image Logo_itt = Image.getInstance(itt_logo);
            Logo_itt.setAbsolutePosition(50f, 698f);
            Logo_itt.scaleAbsolute(90, 100);
            documento.add(Logo_itt);
        } catch (BadElementException | IOException ex) {
            Logger.getLogger(CrearPDF_Ficha.class.getName()).log(Level.SEVERE, null, ex);
        }

        PdfContentByte rectangulo_info = writer.getDirectContentUnder();
        drawRectangle(rectangulo_info, 430, 648, 90, 100);
        Paragraph leyendaFoto = new Paragraph("\nFOTO:\n", FontFactory.getFont("arial", 14, Font.BOLD));
        leyendaFoto.setIndentationLeft(200f);
        Paragraph titulo = new Paragraph("INSTITUTO TECNOLGICO DE TOLUCA", FontFactory.getFont("arial", 14));
        titulo.setAlignment(Element.ALIGN_CENTER);

        Paragraph asunto = new Paragraph("FICHA DE EXAMEN", FontFactory.getFont("arial", 12));
        asunto.setAlignment(Element.ALIGN_CENTER);

        Chunk folio1 = new Chunk("FICHA PARA EL EXAMEN DE ADMISIN: ", FontFactory.getFont("arial", 10));
        Chunk folio2 = new Chunk(datos.getFicha(), FontFactory.getFont("arial", 10, Font.BOLD));

        Phrase fol = new Phrase();
        fol.add(folio1);
        fol.add(folio2);

        Paragraph noFicha = new Paragraph(fol);
        noFicha.setAlignment(Element.ALIGN_LEFT);

        Chunk nombre1 = new Chunk("NOMBRE DEL SOLICITANTE: ", FontFactory.getFont("arial", 10));
        Chunk nombre2 = new Chunk(datos.getNombre(), FontFactory.getFont("arial", 10, Font.BOLD));

        Phrase nom = new Phrase();
        nom.add(nombre1);
        nom.add(nombre2);

        Paragraph nombre = new Paragraph(nom);
        nombre.setAlignment(Element.ALIGN_LEFT);

        Chunk in1 = new Chunk("PROCESO PARA EL REGISTRO DE ASPIRANTES EN EL PERIODO: ",
                FontFactory.getFont("arial", 10));
        Chunk in2 = new Chunk(datos.getPeriodoConcursa().toUpperCase(),
                FontFactory.getFont("arial", 10, Font.BOLD));

        Phrase in = new Phrase();
        in.add(in1);
        in.add(in2);

        Paragraph instrucciones = new Paragraph(in);
        instrucciones.setAlignment(Element.ALIGN_LEFT);

        Chunk folCen1 = new Chunk("1.- NMERO DE FOLIO CENEVAL: ", FontFactory.getFont("arial", 10));
        Chunk folCen2 = new Chunk(datos.getFolioCENEVAL(), FontFactory.getFont("arial", 10, Font.BOLD));

        Phrase folC = new Phrase();
        folC.add(folCen1);
        folC.add(folCen2);

        Paragraph folioCENEVAL = new Paragraph(folC);
        folioCENEVAL.setAlignment(Element.ALIGN_LEFT);

        Chunk fechas1 = new Chunk("2.- LOS EX?MENES DE ADMISIN SE APLICAR?N LOS D?AS: ",
                FontFactory.getFont("arial", 10));
        Chunk fechas2 = new Chunk(datos.getFechaExamenCeneval() + " (" + datos.getLugarExamenCeneval() + ")",
                FontFactory.getFont("arial", 10, Font.BOLD));
        Chunk fechas3 = new Chunk(" Y ", FontFactory.getFont("arial", 10));
        Chunk fechas4 = new Chunk(datos.getFechaExamenMate() + " (" + datos.getLugarExamenMate() + ")",
                FontFactory.getFont("arial", 10, Font.BOLD));

        Phrase fechas = new Phrase();
        fechas.add(fechas1);
        fechas.add(fechas2);
        fechas.add(fechas3);
        fechas.add(fechas4);

        Paragraph fechaExamenes = new Paragraph(fechas);
        fechaExamenes.setAlignment(Element.ALIGN_LEFT);

        Phrase lugar = new Phrase();

        Paragraph lugarYhora = new Paragraph(lugar);
        lugarYhora.setAlignment(Element.ALIGN_LEFT);

        Chunk paginaPub1 = new Chunk(
                "3.- LA PUBLICACIN DE LOS RESULTADOS SER? NICAMENTE EN LA P?GINA WEB: ",
                FontFactory.getFont("arial", 10));

        Anchor url_itt = new Anchor(datos.getPagResultados());
        url_itt.setReference(datos.getPagResultados());

        Phrase pag = new Phrase();
        pag.add(paginaPub1);
        pag.add(url_itt);

        Paragraph pagWeb = new Paragraph(pag);

        Chunk diaPub1 = new Chunk("EL D?A: ", FontFactory.getFont("arial", 10));
        Chunk diaPub2 = new Chunk(convertir(datos.getDiaPublicacion() + "-"),
                FontFactory.getFont("arial", 10, Font.BOLD));

        Phrase dia = new Phrase();
        dia.add(diaPub1);
        dia.add(diaPub2);

        Paragraph diaResultados = new Paragraph(dia);
        diaResultados.setAlignment(Element.ALIGN_LEFT);

        Chunk notas = new Chunk("\nNOTAS:\n", FontFactory.getFont("arial", 14, Font.BOLD));

        Chunk uno = new Chunk("1.- ", FontFactory.getFont("arial", 10, Font.BOLD));

        Chunk guias = new Chunk("Guas de estudio:\n   - (CENEVAL) \n", FontFactory.getFont("arial", 10));

        Anchor url_guia_cen = new Anchor("     " + datos.getEstudioCeneval());
        // url_guia_cen.setReference(datos.getEstudioCeneval());

        Chunk ceneval_inter = new Chunk("\n   - (CENEVAL INTERACTIVA) \n", FontFactory.getFont("arial", 10));

        Anchor url_guia_cen_inter = new Anchor("     " + datos.getEstudioCenevalInt());
        url_guia_cen_inter.setReference(datos.getEstudioCenevalInt());

        Chunk tem_mate_itt = new Chunk("\n   - Temario de Matemticas (TECNOLGICO DE TOLUCA)\n\n",
                FontFactory.getFont("arial", 10));
        Chunk dos = new Chunk("2.- ", FontFactory.getFont("arial", 10, Font.BOLD));
        Chunk veri = new Chunk("Verifique que el nmero de folio de Ceneval de esta ficha, coincida con el",
                FontFactory.getFont("arial", 10));
        Chunk fol_ceneval = new Chunk(" FOLIO CENEVAL ", FontFactory.getFont("arial", 10, Font.BOLD));
        Chunk capturado = new Chunk("capturado en la informacin proporcionada por el Tecnlogico.\n\n",
                FontFactory.getFont("arial", 10));
        Chunk tres = new Chunk("3.- ", FontFactory.getFont("arial", 10, Font.BOLD));
        Chunk dia_exam = new Chunk(
                "El da del examen deber presentarse con el presente documento, pase de ingreso al examen(Ceneval), una identificacin con fotografa reciente(credencial escolar, IMSS, ISSSTE, ISSEMYM, licencia, pasaporte), lpiz del nmero 2 y goma.\n\n",
                FontFactory.getFont("arial", 10));
        Chunk cuatro = new Chunk("4.- ", FontFactory.getFont("arial", 10, Font.BOLD));
        Chunk curso = new Chunk(
                "Si curs sus estudios de secundaria o bachillerato en el extranjero deber presentar revalidacin de estudios correspondientes al momento de la inscripcin.\n",
                FontFactory.getFont("arial", 10));
        Chunk cinco = new Chunk("\n5.- ", FontFactory.getFont("arial", 10, Font.BOLD));
        Chunk examenes = new Chunk(
                "Los exmenes que se evaluarn son:       1) ADMISIN Y DIAGNSTICO.     2) MATEM?TICAS.",
                FontFactory.getFont("arial", 10));

        Phrase ulti = new Phrase();
        ulti.add(notas);
        ulti.add(uno);
        ulti.add(guias);
        ulti.add(url_guia_cen);
        ulti.add(ceneval_inter);
        ulti.add(url_guia_cen_inter);
        ulti.add(tem_mate_itt);
        ulti.add(dos);
        ulti.add(veri);
        ulti.add(fol_ceneval);
        ulti.add(capturado);
        ulti.add(tres);
        ulti.add(dia_exam);
        ulti.add(cuatro);
        ulti.add(curso);
        ulti.add(cinco);
        ulti.add(examenes);

        Paragraph ultimo = new Paragraph(ulti);
        ultimo.setAlignment(Element.ALIGN_LEFT);

        documento.addTitle("Ficha de Examen");
        documento.addSubject("Instituto Tecnolgico de Toluca");
        documento.addKeywords("Instituto Tecnolgico de Toluca");
        documento.addAuthor("Departamento de Servicios escolares");
        documento.addCreator("Departamento de Servicios escolares");
        documento.add(titulo);
        documento.add(asunto);
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));

        documento.add(noFicha);
        documento.add(nombre);
        documento.add(new Paragraph(" "));
        documento.add(instrucciones);
        documento.add(new Paragraph(" "));
        documento.add(folioCENEVAL);
        documento.add(fechaExamenes);
        documento.add(lugarYhora);
        documento.add(pagWeb);
        documento.add(diaResultados);
        documento.add(new Paragraph(" "));
        documento.add(ultimo);

        documento.close();
    } catch (DocumentException ex) {
        Logger.getLogger(CrearPDF_Ficha.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:psManage.StructSheet.java

public void createPdf(String mainTitle, String subTitle, String url, String userName,
        //String scanType,
        String comment,//from   w  w  w . j  a v  a  2 s .  c o m
        //String thisPassCode,
        String passCodeA, String passCodeB, String fileDir, Boolean noBarCodePrint)
        throws IOException, DocumentException, RuntimeException {
    Document document = null;
    try {
        // step 1
        document = new Document(PageSize.A4, 60, 50, 50, 35);
        // step 2
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(fileDir));
        // step 3
        document.open();
        // step 4
        PdfContentByte cb = writer.getDirectContent();
        /*
         Properties props = new Properties();
         String jarPath = System.getProperty("java.class.path");
         String dirPath = jarPath.substring(0, jarPath.lastIndexOf(File.separator)+1);
         FontFactory.registerDirectory("/res");
         FontFactory.register("ipag.ttf");
         Font ipaGothic = FontFactory.getFont("ipag", BaseFont.IDENTITY_H, 
         BaseFont.EMBEDDED, 10); //10 is the size
                
         InputStream is = getClass().getResourceAsStream("/res/ipag.ttf");
         */

        Properties props = new Properties();
        String jarPath = System.getProperty("java.class.path");
        String dirPath = jarPath.substring(0, jarPath.lastIndexOf(File.separator) + 1);
        System.out.println(jarPath);
        System.out.println(dirPath);
        System.out.println(System.getProperty("user.dir"));

        Font ipaGothic = new Font(BaseFont.createFont(System.getProperty("user.dir") + "\\res\\ipag.ttf",
                BaseFont.IDENTITY_H, BaseFont.EMBEDDED), 11);

        Font ipaGothic14 = new Font(BaseFont.createFont(System.getProperty("user.dir") + "\\res\\ipag.ttf",
                BaseFont.IDENTITY_H, BaseFont.EMBEDDED), 14);

        //?(2)
        PdfPTable pdfPTable = new PdfPTable(2);

        pdfPTable.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE);
        pdfPTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
        pdfPTable.getDefaultCell().setFixedHeight(150);

        pdfPTable.setWidthPercentage(100f);

        int pdfPTableWidth[] = { 10, 90 };
        pdfPTable.setWidths(pdfPTableWidth);

        PdfPCell cell_1_1 = new PdfPCell(new Paragraph("??", ipaGothic));
        cell_1_1.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell_1_1.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell_1_1.setFixedHeight(50);
        PdfPCell cell_1_2 = new PdfPCell(new Paragraph(mainTitle, ipaGothic));
        cell_1_2.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell_1_2.setHorizontalAlignment(Element.ALIGN_CENTER);

        PdfPCell cell_2_1 = new PdfPCell(new Paragraph("", ipaGothic));
        cell_2_1.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell_2_1.setHorizontalAlignment(Element.ALIGN_CENTER);
        PdfPCell cell_2_2 = new PdfPCell(new Paragraph(subTitle, ipaGothic));
        cell_2_2.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell_2_2.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell_2_2.setFixedHeight(50);
        pdfPTable.addCell(cell_1_1);
        pdfPTable.addCell(cell_1_2);
        pdfPTable.addCell(cell_2_1);
        pdfPTable.addCell(cell_2_2);

        PdfPCell cellUrlKey = new PdfPCell(new Paragraph("?", ipaGothic));
        cellUrlKey.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cellUrlKey.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellUrlKey.setRowspan(2);
        pdfPTable.addCell(cellUrlKey);

        PdfPCell cellUrlValue = new PdfPCell(new Paragraph(url, ipaGothic));
        Chunk chunk = new Chunk(url, ipaGothic); // ??????????????
        System.out.println("??" + chunk.getWidthPoint());
        cellUrlValue.setVerticalAlignment(Element.ALIGN_MIDDLE);
        if (chunk.getWidthPoint() > 410) { // ??????????
            cellUrlValue.setHorizontalAlignment(Element.ALIGN_LEFT);
        } else { // ?????????
            cellUrlValue.setHorizontalAlignment(Element.ALIGN_CENTER);
        }

        cellUrlValue.setFixedHeight(50);
        pdfPTable.addCell(cellUrlValue);

        if (url.length() != 0 && !noBarCodePrint) {
            /* ?
             BarcodeQRCode qr = new BarcodeQRCode(url, 50, 50, null);
             PdfPCell cellUrlValueQr = new PdfPCell(qr.getImage());
             cellUrlValueQr.setVerticalAlignment(Element.ALIGN_MIDDLE);
             cellUrlValueQr.setHorizontalAlignment(Element.ALIGN_CENTER);
             cellUrlValueQr.setFixedHeight(80);
             pdfPTable.addCell(cellUrlValueQr);
             */
            Image image = ZxingUti.getQRCode(url); //  SHIFT_JIS
            com.itextpdf.text.Image iTextImage = com.itextpdf.text.Image.getInstance(image, null);
            PdfPCell cell = new PdfPCell(iTextImage);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(100);
            pdfPTable.addCell(cell); //  SIFT_JIS
        } else {
            PdfPCell cellUrlValueQr = new PdfPCell(new Paragraph("", ipaGothic));
            cellUrlValueQr.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellUrlValueQr.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellUrlValueQr.setFixedHeight(80);
            pdfPTable.addCell(cellUrlValueQr);
        }

        PdfPCell cellUserNameKey = new PdfPCell(new Paragraph("", ipaGothic));
        cellUserNameKey.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cellUserNameKey.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellUserNameKey.setRowspan(2);
        pdfPTable.addCell(cellUserNameKey);

        PdfPCell cellUserNameValue = new PdfPCell(new Paragraph(userName, ipaGothic14));
        cellUserNameValue.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cellUserNameValue.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellUserNameValue.setFixedHeight(30);
        pdfPTable.addCell(cellUserNameValue);

        if (userName.length() != 0 && !noBarCodePrint) {
            Barcode128 code128 = new Barcode128();
            code128.setCode(userName);
            code128.setFont(ipaGothic.getBaseFont());
            code128.setBarHeight(40f);
            PdfPCell cellUserNameValueBc = new PdfPCell(code128.createImageWithBarcode(cb, null, null));
            cellUserNameValueBc.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellUserNameValueBc.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellUserNameValueBc.setFixedHeight(80);
            pdfPTable.addCell(cellUserNameValueBc);
        } else {
            PdfPCell cellUserNameValueBc = new PdfPCell(new Paragraph("---", ipaGothic));
            cellUserNameValueBc.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellUserNameValueBc.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellUserNameValueBc.setFixedHeight(80);
            pdfPTable.addCell(cellUserNameValueBc);
        }

        PdfPCell cellPassCodeKey = new PdfPCell(new Paragraph("?", ipaGothic));
        cellPassCodeKey.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cellPassCodeKey.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellPassCodeKey.setRowspan(3);
        pdfPTable.addCell(cellPassCodeKey);

        PdfPCell cellPassCodeValue = new PdfPCell(new Paragraph(passCodeA + passCodeB, ipaGothic14));
        cellPassCodeValue.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cellPassCodeValue.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellPassCodeValue.setFixedHeight(30);
        pdfPTable.addCell(cellPassCodeValue);

        if (passCodeA.length() != 0 && !noBarCodePrint) {
            Barcode128 code128 = new Barcode128();
            code128.setCode(passCodeA);
            code128.setFont(ipaGothic.getBaseFont());
            code128.setBarHeight(40f);
            PdfPCell cellPassCodeA_Bc = new PdfPCell(code128.createImageWithBarcode(cb, null, null));
            cellPassCodeA_Bc.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellPassCodeA_Bc.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellPassCodeA_Bc.setFixedHeight(80);
            pdfPTable.addCell(cellPassCodeA_Bc);
        } else {
            PdfPCell cellPassCodeA_Bc = new PdfPCell(new Paragraph("---", ipaGothic));
            cellPassCodeA_Bc.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellPassCodeA_Bc.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellPassCodeA_Bc.setFixedHeight(80);
            pdfPTable.addCell(cellPassCodeA_Bc);
        }

        if (passCodeB.length() != 0 && !noBarCodePrint) {
            Barcode128 code128 = new Barcode128();
            code128.setCode(passCodeB);
            code128.setFont(ipaGothic.getBaseFont());
            code128.setBarHeight(40f);
            PdfPCell cellPassCodeB_Bc = new PdfPCell(code128.createImageWithBarcode(cb, null, null));
            cellPassCodeB_Bc.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellPassCodeB_Bc.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellPassCodeB_Bc.setFixedHeight(80);
            pdfPTable.addCell(cellPassCodeB_Bc);
        } else {
            PdfPCell cellPassCodeB_Bc = new PdfPCell(new Paragraph("---", ipaGothic));
            cellPassCodeB_Bc.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellPassCodeB_Bc.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellPassCodeB_Bc.setFixedHeight(80);
            pdfPTable.addCell(cellPassCodeB_Bc);
        }

        PdfPCell cellCommentKey = new PdfPCell(new Paragraph("?", ipaGothic));
        cellCommentKey.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cellCommentKey.setHorizontalAlignment(Element.ALIGN_CENTER);
        pdfPTable.addCell(cellCommentKey);

        PdfPCell cellCommentValue = new PdfPCell(new Paragraph(comment, ipaGothic));
        cellCommentValue.setVerticalAlignment(Element.ALIGN_TOP);
        cellCommentValue.setHorizontalAlignment(Element.ALIGN_LEFT);
        cellCommentValue.setFixedHeight(150);
        pdfPTable.addCell(cellCommentValue);

        PdfPCell cellIssueKey = new PdfPCell(new Paragraph("", ipaGothic));
        cellIssueKey.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cellIssueKey.setHorizontalAlignment(Element.ALIGN_CENTER);
        pdfPTable.addCell(cellIssueKey);

        Calendar cal = Calendar.getInstance();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm");
        String strDate = sdf.format(cal.getTime());
        PdfPCell cellIssueValue = new PdfPCell(new Paragraph(strDate, ipaGothic));
        cellIssueValue.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cellIssueValue.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellIssueValue.setFixedHeight(20);
        pdfPTable.addCell(cellIssueValue);

        //??
        document.add(pdfPTable);
        /*
                
         // CODE 128
         document.add(new Paragraph("?? : " + mainTitle, ipaGothic));
         document.add(new Paragraph(" : " + subTitle, ipaGothic));
         document.add(new Paragraph("-------------------------------------------------------"));
         document.add(new Paragraph(" " + strDate));
         document.add(new Paragraph("-------------------------------------------------------"));
                
                
         BaseFont bf = BaseFont.createFont(BaseFont.COURIER, BaseFont.WINANSI, BaseFont.EMBEDDED);
         Font font = new Font(bf, 12);
         document.add(new Paragraph("", ipaGothic));
         document.add(new Paragraph(url, ipaGothic));
         code128.setCode(url);
         code128.setFont(bf);
         code128.setX(1);
         //document.add(code128.createImageWithBarcode(cb, null, null));
                
         document.add(new Paragraph("USER", ipaGothic));
         if (userName.length() != 0) {
         document.add(new Paragraph(userName, ipaGothic));
         code128.setCode(userName);
         code128.setFont(bf);
         code128.setBarHeight(40f);
         document.add(code128.createImageWithBarcode(cb, null, null));
         }
                
         document.add(new Paragraph("CODE", ipaGothic));
         if (passCode.length() != 0) {
         document.add(new Paragraph(passCode, ipaGothic));
         code128.setCode(passCode);
         code128.setFont(bf);
         document.add(code128.createImageWithBarcode(cb, null, null));
         }
                
         document.add(new Paragraph("?", ipaGothic));
         document.add(new Paragraph(comment, ipaGothic));
         */
        // step 5
        document.close();
    } catch (RuntimeException ex) {
        document.close();
        throw ex;

    }
}

From source file:py.com.palermo.imprimeetiquetas.web.ProductoController.java

public String createPdf() throws IOException, DocumentException {

    if (hayParaImprimir()) {

        HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance()
                .getExternalContext().getResponse();
        response.setContentType("application/x-pdf");
        response.setHeader("Content-Disposition", "attachment; filename=\"etiquetas.pdf\"");

        // step 1
        Document document = new Document(new Rectangle(86, 35));
        // step 2

        document.setMargins(0f, 0f, 0f, 0f);

        PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream());
        // step 3
        document.open();//from  ww w .  jav a 2 s .  c o  m

        // step 4
        PdfContentByte cb = writer.getDirectContent();

        for (ProductoCantidad p : productos) {
            if (p.getCantidad() > 0) {

                BarcodeEAN codeEAN = new BarcodeEAN();
                codeEAN.setCode(p.getCodigo());
                codeEAN.setCodeType(Barcode.EAN13);
                codeEAN.setBarHeight(10f);
                codeEAN.setX(0.7f);
                codeEAN.setSize(4f);

                NumberFormat nf = NumberFormat.getCurrencyInstance(new Locale("es", "py"));
                Font fontbold = FontFactory.getFont("Times-Roman", 5, Font.NORMAL);
                Chunk productTitle = new Chunk(p.getNombre() + "," + " " + nf.format(p.getPrecio()), fontbold);

                // EAN 13
                Paragraph pTitile = new Paragraph(productTitle);
                pTitile.setAlignment(Element.ALIGN_CENTER);
                pTitile.setLeading(0, 1);

                PdfPTable table = new PdfPTable(1);
                table.setPaddingTop(0f);

                table.setWidthPercentage(96);
                PdfPCell cell = new PdfPCell();
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setBorder(Rectangle.NO_BORDER);
                cell.addElement(codeEAN.createImageWithBarcode(cb, null, BaseColor.BLACK));

                table.addCell(cell);

                PdfPCell cell2 = new PdfPCell();
                cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell2.setBorder(Rectangle.NO_BORDER);
                cell2.addElement(pTitile);

                table.addCell(cell2);

                for (int i = 0; i < p.getCantidad(); i++) {
                    document.add(table);
                    document.newPage();
                }
            }
        }

        // step 5
        document.close();

        response.getOutputStream().flush();
        response.getOutputStream().close();
        FacesContext.getCurrentInstance().responseComplete();
    } else {
        FacesContext.getCurrentInstance().addMessage(null,
                new FacesMessage(FacesMessage.SEVERITY_ERROR, "No hay nada que imprimir", ""));
    }
    return null;
}

From source file:quanlyhoadon.PDFProcess.java

public boolean printPDF(String dest, Company company, Bill bill, LinhTinh lt) {
    try {//  w ww  .java2 s  .c  om
        BaseFont urName = BaseFont.createFont("font/Time_New_Roman.TTF", BaseFont.IDENTITY_H,
                BaseFont.EMBEDDED);
        Font nameFont = new Font(urName, 16, Font.BOLD);
        Font addFont = new Font(urName, 12);
        Font boldFont = new Font(urName, 14, Font.BOLD);
        Font contentFont = new Font(urName, 14);
        Font footFont = new Font(urName, 16);

        Document document = new Document(PageSize.A4.rotate());
        PdfWriter.getInstance(document, new FileOutputStream(dest));
        document.open();

        PdfPTable table = new PdfPTable(3);
        table.setWidthPercentage(100);
        table.setWidths(new float[] { 2, 6, 3 });

        //logo
        Image img = Image.getInstance("logo.jpg");
        img.scaleAbsolute(100, 100);
        PdfPCell cell = new PdfPCell(img);
        cell.setBorder(PdfPCell.NO_BORDER);

        //middle content
        String name = company.getName();
        String address = "\n\n?C: " + company.getAddress();
        String phone = "\n\n?T: " + company.getPhone();
        String hed = "\n\n     PHIU B?O GI?";

        Phrase mid = new Phrase();
        mid.add(new Chunk(name, nameFont));
        mid.add(new Chunk(address + phone, addFont));
        mid.add(new Chunk(hed, nameFont));

        PdfPCell midCell = new PdfPCell(mid);
        //      midCell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        midCell.setPaddingTop(15);
        midCell.setPaddingLeft(40);
        midCell.setPaddingRight(15);
        midCell.setPaddingBottom(15);
        midCell.setBorder(PdfPCell.NO_BORDER);

        // right content
        String soCt = "S CT: " + bill.getId();
        String date = "\n\nNgy: " + bill.getDate() + "\n\nKho : " + lt.getKho();

        Phrase right = new Phrase();
        right.add(new Chunk(soCt + date, addFont));
        PdfPCell rightCell = new PdfPCell(right);
        rightCell.setPadding(15);
        rightCell.setBorder(PdfPCell.NO_BORDER);

        table.addCell(cell);
        table.addCell(midCell);
        table.addCell(rightCell);

        document.add(table);

        Phrase p1 = new Phrase();
        p1.add(new Chunk("?n v: ", addFont));
        p1.add(new Chunk(lt.getDonVi(), boldFont));
        p1.add(new Chunk("\n?a Ch: \n", addFont));

        Paragraph pagra = new Paragraph(p1);
        pagra.setIndentationLeft(15);
        pagra.setSpacingBefore(10);
        pagra.setSpacingAfter(10);
        document.add(pagra);

        //table lt
        PdfPTable tablList = new PdfPTable(6);

        tablList.setWidthPercentage(100);
        tablList.setWidths(new float[] { 1, 5, 7, 2, 3, 4 });

        String title[] = { "STT", "M Hng", "Tn Hng", "SL", "?n Gi", "Thnh Ti?n" };
        for (int i = 0; i < title.length; ++i) {
            Phrase phr = new Phrase();
            phr.add(new Chunk(title[i], boldFont));
            PdfPCell p = new PdfPCell(phr);
            p.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            tablList.addCell(p);
        }
        //--- add content
        for (int i = 0; i < bill.getCount(); ++i) {
            Phrase[] phrase = new Phrase[6];
            PdfPCell[] pCell = new PdfPCell[6];

            for (int k = 0; k < 6; ++k) {
                phrase[k] = new Phrase();
            }
            phrase[0].add(new Chunk((i + 1) + "", contentFont));
            phrase[1].add(new Chunk(bill.getMaHangAt(i), contentFont));
            phrase[2].add(new Chunk(bill.getTenHangAt(i), contentFont));
            phrase[3].add(new Chunk(bill.getSoLuongAt(i) + "", contentFont));
            phrase[4].add(new Chunk(bill.getDonGiaAt(i) + "", contentFont));
            phrase[5].add(new Chunk(bill.getThanhTienAt(i) + "", contentFont));

            for (int j = 0; j < 6; ++j) {
                pCell[j] = new PdfPCell(phrase[j]);
                pCell[j].setHorizontalAlignment(PdfPCell.ALIGN_CENTER);

                tablList.addCell(pCell[j]);
            }
        }

        PdfPCell cell1 = new PdfPCell(new Phrase(new Chunk("Tng", boldFont)));
        cell1.setColspan(3);
        cell1.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        tablList.addCell(cell1);

        //
        PdfPCell cell2 = new PdfPCell(new Phrase(new Chunk("" + bill.getTong(), boldFont)));
        cell2.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        tablList.addCell(cell2);

        //
        PdfPCell cell3 = new PdfPCell(new Phrase(new Chunk("", boldFont)));
        cell3.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        tablList.addCell(cell3);

        //
        PdfPCell cell4 = new PdfPCell(new Phrase(new Chunk(String.format("%,d", bill.tongTien()), boldFont)));
        cell4.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        tablList.addCell(cell4);

        document.add(tablList);
        //-------------------in phuong thuc thanh toan
        Phrase p2 = new Phrase();
        p2.add(new Chunk("Phng thc thanh ton: ", contentFont));
        p2.add(new Chunk(lt.getThanhToan(), boldFont));
        p2.add(new Chunk("\nLu  mua hng min tr li. Vui lng gi phiu trong 7 ngy: ",
                contentFont));

        Paragraph pagra2 = new Paragraph(p2);
        pagra2.setSpacingBefore(5);
        pagra2.setSpacingAfter(5);
        document.add(pagra2);

        //---- footer content
        PdfPTable tblFoot = new PdfPTable(3);

        tblFoot.setWidthPercentage(100);
        tblFoot.setWidths(new float[] { 1, 1, 1 });

        PdfPCell leftFootCell = new PdfPCell(new Phrase(new Chunk("NGI LP ", footFont)));
        PdfPCell midFootCell = new PdfPCell(new Phrase(new Chunk("K TO?N ", footFont)));
        PdfPCell rightFootCell = new PdfPCell(new Phrase(new Chunk("TH TRNG ?N V ", footFont)));

        leftFootCell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        leftFootCell.setBorder(PdfPCell.NO_BORDER);
        midFootCell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        midFootCell.setBorder(PdfPCell.NO_BORDER);
        rightFootCell.setBorder(PdfPCell.NO_BORDER);
        rightFootCell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);

        tblFoot.addCell(leftFootCell);
        tblFoot.addCell(midFootCell);
        tblFoot.addCell(rightFootCell);

        document.add(tblFoot);

        //
        document.close();
        JOptionPane.showMessageDialog(null, "In hoadon.pdf thnh cng");
        return true;
    } catch (Exception e) {
        JOptionPane.showMessageDialog(null,
                "hoadon.pdf ang c m\nVui lng ng li. Sau  th li");
        e.printStackTrace();
        return false;
    }
}

From source file:ResumeBuilder.resumeGenerator.java

void createResume() throws IOException {
    Document resume = new Document();
    try {/* www.j a va 2s.  c  om*/

        PdfWriter.getInstance(resume, new FileOutputStream("resume.pdf"));
        resume.open();
        LineSeparator line;
        line = new LineSeparator();
        Font f = new Font();
        resume.add(Chunk.NEWLINE);
        String space = "";
        Font font2 = new Font(Font.FontFamily.HELVETICA, 18, Font.BOLD | Font.UNDERLINE);
        resume.add(new Paragraph("RESUME", font2));
        Paragraph name = new Paragraph((String) details.get("Name"));
        name.setAlignment(Paragraph.ALIGN_LEFT);
        resume.add(name);
        Paragraph email = new Paragraph((String) details.get("Email"));
        email.setAlignment(Paragraph.ALIGN_RIGHT);
        resume.add(email);
        Paragraph contact = new Paragraph((String) details.get("ContactNumber"));
        contact.setAlignment(Paragraph.ALIGN_RIGHT);
        resume.add(contact);
        resume.add(Chunk.NEWLINE);
        resume.add(line);
        resume.add(Chunk.NEWLINE);
        Font font1 = new Font(Font.FontFamily.HELVETICA, 13, Font.BOLD | Font.UNDERLINE);
        resume.add(new Chunk("Qulaification ", font1));
        resume.add(Chunk.NEWLINE);
        PdfPTable table = new PdfPTable(3);
        PdfPCell cell1 = new PdfPCell(new Paragraph("College"));
        PdfPCell cell2 = new PdfPCell(new Paragraph("Percentage"));
        PdfPCell cell3 = new PdfPCell(new Paragraph("Date"));
        PdfPCell cell4;
        cell4 = new PdfPCell(new Paragraph((String) details.get("SchoolX")));
        resume.add(cell4);
        resume.add(Chunk.NEWLINE);
        PdfPCell cell5 = new PdfPCell(new Paragraph((String) details.get("PercentageX")));
        resume.add(cell5);
        PdfPCell cell6;
        cell6 = new PdfPCell(new Paragraph((String) details.get("Date X")));
        resume.add(cell6);
        PdfPCell cell7;
        cell7 = new PdfPCell(new Paragraph((String) details.get("SchoolXII")));
        resume.add(cell7);
        resume.add(Chunk.NEWLINE);
        PdfPCell cell8 = new PdfPCell(new Paragraph((String) details.get("PercentageXII")));
        resume.add(cell8);
        PdfPCell cell9;
        cell9 = new PdfPCell(new Paragraph((String) details.get("Date XII")));
        resume.add(cell9);
        table.addCell(cell1);
        table.addCell(cell2);
        table.addCell(cell3);
        table.addCell(cell4);
        table.addCell(cell5);
        table.addCell(cell6);
        table.addCell(cell7);
        table.addCell(cell8);
        table.addCell(cell9);
        resume.add(table);
        resume.add(Chunk.NEWLINE);
        Font font3;
        font3 = new Font(Font.FontFamily.HELVETICA, 13, Font.BOLD | Font.UNDERLINE);
        resume.add(new Chunk("Graduation and PostGraduation ", font1));
        //resume.add(Chunk.NEWLINE);
        PdfPTable table1;
        table1 = new PdfPTable(4);
        PdfPCell cell10 = new PdfPCell(new Paragraph(" College"));
        PdfPCell cell11 = new PdfPCell(new Paragraph("University"));
        PdfPCell cell12 = new PdfPCell(new Paragraph("CGPA"));
        PdfPCell cell13 = new PdfPCell(new Paragraph("DATE"));
        PdfPCell cell14;
        cell14 = new PdfPCell(new Paragraph((String) details.get("GraduationCollege")));
        resume.add(cell14);
        resume.add(Chunk.NEWLINE);
        PdfPCell cell15 = new PdfPCell(new Paragraph((String) details.get("GraduateUniversity")));
        resume.add(cell15);
        resume.add(Chunk.NEWLINE);
        PdfPCell cell16 = new PdfPCell(new Paragraph((String) details.get("GraduationCGPA")));
        resume.add(cell16);
        PdfPCell cell17;
        cell17 = new PdfPCell(new Paragraph((String) details.get("Graduation date")));
        resume.add(cell7);
        PdfPCell cell18;
        cell18 = new PdfPCell(new Paragraph((String) details.get("PostGraduationCollege")));
        resume.add(cell8);
        resume.add(Chunk.NEWLINE);
        PdfPCell cell19;
        cell19 = new PdfPCell(new Paragraph((String) details.get("PostGraduateUniversity")));
        resume.add(cell19);
        PdfPCell cell20;
        cell20 = new PdfPCell(new Paragraph((String) details.get("PostGraduateCGPA")));
        resume.add(cell20);
        PdfPCell cell21;
        cell21 = new PdfPCell(new Paragraph((String) details.get("Post Graduation date")));
        resume.add(cell21);
        table1.addCell(cell10);
        table1.addCell(cell11);
        table1.addCell(cell12);
        table1.addCell(cell13);
        table1.addCell(cell14);
        table1.addCell(cell15);
        table1.addCell(cell16);
        table1.addCell(cell17);
        table1.addCell(cell18);
        table1.addCell(cell19);
        table1.addCell(cell20);
        table1.addCell(cell21);
        resume.add(table1);
        Font font4;
        font4 = new Font(Font.FontFamily.HELVETICA, 13, Font.BOLD | Font.UNDERLINE);
        resume.add(new Chunk("Skills", font1));
        resume.add(Chunk.NEWLINE);
        resume.add(Chunk.NEWLINE);
        Paragraph name1;
        name1 = new Paragraph((String) details.get("Skills"));
        name1.setIndentationLeft(50);
        resume.add(name1);
        Font font5;
        font5 = new Font(Font.FontFamily.HELVETICA, 13, Font.BOLD | Font.UNDERLINE);
        resume.add(new Chunk("Projects", font1));
        resume.add(Chunk.NEWLINE);
        Paragraph name2;
        name2 = new Paragraph((String) details.get("ProjectName1"));
        name2.setIndentationLeft(50);
        resume.add(name2);
        resume.add(Chunk.NEWLINE);
        Paragraph name3;
        name3 = new Paragraph((String) details.get("projectDescription1"));
        name3.setIndentationLeft(50);
        resume.add(name3);
        resume.add(Chunk.NEWLINE);
        Paragraph name4;
        name4 = new Paragraph((String) details.get("ProjectName2"));
        name4.setIndentationLeft(50);
        resume.add(name4);
        resume.add(Chunk.NEWLINE);
        Paragraph name5;
        name5 = new Paragraph((String) details.get("projectDescription2"));
        name5.setIndentationLeft(50);
        resume.add(name5);
        resume.add(Chunk.NEWLINE);
        Paragraph name6;
        name6 = new Paragraph((String) details.get("ProjectName3"));
        name6.setIndentationLeft(50);
        resume.add(name6);
        Paragraph name7;
        name7 = new Paragraph((String) details.get("projectDescription3"));
        name7.setIndentationLeft(50);
        resume.add(name7);
        resume.add(Chunk.NEWLINE);
        Paragraph name8;
        name8 = new Paragraph((String) details.get("ProjectName4"));
        name8.setIndentationLeft(50);
        resume.add(name8);
        Paragraph name9;
        name9 = new Paragraph((String) details.get("projectDescription4"));
        name9.setIndentationLeft(50);
        resume.add(name9);
        resume.close();

    } catch (DocumentException | FileNotFoundException e) {
        System.out.println(e.getMessage());
    }
    File file = new File("resume.pdf");
    Desktop.getDesktop().open(file);

}

From source file:ro.ldir.chartpackage.GarbagePackageBuilder.java

License:Open Source License

public void writePDF(OutputStream out)
        throws DocumentException, MalformedURLException, XPathExpressionException, IOException {
    BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, "Cp1250", BaseFont.NOT_EMBEDDED);
    final Font hfFont = new Font(bf, 8, Font.NORMAL, BaseColor.GRAY);

    Document document = new Document(PageSize.A4, 50, 50, 50, 50);
    PdfWriter writer = PdfWriter.getInstance(document, out);
    writer.setBoxSize("art", new Rectangle(36, 54, 559, 788));

    writer.setPageEvent(new PdfPageEventHelper() {
        private int page = 0;

        @Override//from w  ww  . ja va 2  s .com
        public void onEndPage(PdfWriter writer, Document arg1) {
            page++;
            Rectangle rect = writer.getBoxSize("art");
            ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_CENTER,
                    new Phrase("Pachet mormane - \u00a9 Let's Do It, Romania!", hfFont),
                    (rect.getLeft() + rect.getRight()) / 2, rect.getTop() + 18, 0);
            ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_CENTER,
                    new Phrase("- " + page + " -", hfFont), (rect.getLeft() + rect.getRight()) / 2,
                    rect.getBottom() - 18, 0);
        }
    });

    document.open();
    document.addAuthor("Let's Do It, Romania!");
    document.addTitle("Pachet mormane");
    document.addCreationDate();

    Font titleFont = new Font(bf, 24, Font.BOLD);
    Font noteFont = new Font(bf, 12, Font.NORMAL, BaseColor.RED);
    Font headerFont = new Font(bf, 12, Font.BOLD);
    Font normalFont = new Font(bf, 11);
    Font defFont = new Font(bf, 11, Font.BOLD);
    Paragraph par;
    int page = 0;

    for (Garbage garbage : garbages) {
        par = new Paragraph();
        par.setAlignment(Element.ALIGN_CENTER);
        par.add(new Chunk("Morman " + garbage.getGarbageId() + "\n", titleFont));
        par.add(new Chunk("Citi\u0163i cu aten\u0163ie!", noteFont));
        document.add(par);

        par = new Paragraph();
        par.setSpacingBefore(20);
        par.add(new Chunk("1. Date generale\n", headerFont));
        par.add(new Chunk("Jude\u0163ul: ", defFont));
        par.add(new Chunk(garbage.getCounty().getName() + "\n", normalFont));
        par.add(new Chunk("Comuna: ", defFont));
        par.add(new Chunk(garbage.getTown().getName() + "\n", normalFont));
        if (garbage.getChartedArea() != null) {
            par.add(new Chunk("Zona cartare: ", defFont));
            par.add(new Chunk(garbage.getChartedArea().getName() + "\n", normalFont));
        }
        par.add(new Chunk("Pozi\u0163ie: ", defFont));
        par.add(new Chunk(garbage.getY() + ", " + garbage.getX() + "\n", normalFont));
        par.add(new Chunk("Descriere:\n", defFont));
        par.add(new Phrase(garbage.getDescription() + "\n", normalFont));
        par.add(new Chunk("Componen\u0163\u0103 gunoi:\n", defFont));
        List list = new List();
        list.add(new ListItem(
                new Chunk("Procent plastic: " + garbage.getPercentagePlastic() + "%", normalFont)));
        list.add(new ListItem(
                new Chunk("Procent sticl\u0103: " + garbage.getPercentageGlass() + "%", normalFont)));
        list.add(new ListItem(new Chunk("Procent metale: " + garbage.getPercentageMetal() + "%", normalFont)));
        list.add(new ListItem(
                new Chunk("Procent nereciclabile: " + garbage.getPercentageWaste() + "%", normalFont)));
        par.add(list);
        document.add(par);

        par = new Paragraph();
        par.setSpacingBefore(20);
        par.add(new Chunk("2. Indica\u0163ii rutiere\n", headerFont));
        Image img = Image.getInstance(getImage(garbage));
        img.scaleToFit((float) (PageSize.A4.getWidth() * .75), (float) (PageSize.A4.getHeight() * .75));
        img.setAlignment(Element.ALIGN_CENTER);
        par.add(img);
        document.add(par);

        if (page < garbages.size() - 1)
            document.newPage();
        page++;
    }

    document.close();
}

From source file:se.billes.pdf.renderer.model.text.Phrase.java

License:Open Source License

public void onRender(com.itextpdf.text.Paragraph paragraph) {
    Font font = new Font(getBaseFont(), getFontSize());
    font.setColor(getBaseColor());/*from  w  w w .  j  ava2s.  com*/
    if (getStyle() != null)
        font.setStyle(getStyle());
    String text = getText();
    if (text.length() == 0)
        text = " ";
    text = text.replace("&gt;", ">");
    text = text.replace("&lt;", "<");

    Chunk chunk = new Chunk(text, font);
    if (getParagraph().getHyphenationAuto() != null) {
        chunk.setHyphenation(getParagraph().getHyphenationAuto());
    }
    chunk.setTextRise(getTextRise());
    chunk.setSkew(getSkewAlpha(), getSkewBeta());
    paragraph.add(chunk);
}

From source file:se.inera.intyg.rehabstod.service.export.pdf.PdfExportServiceImpl.java

License:Open Source License

private Element getFilterDesc(PrintSjukfallRequest printRequest, RehabstodUser user) {

    // Fritext/*from ww  w  .  j av a 2  s.com*/
    Paragraph valdFritext = new Paragraph(FILTER_TITLE_FRITEXTFILTER, PdfExportConstants.FRONTPAGE_H3);
    valdFritext.add(
            new Paragraph(StringUtil.isNullOrEmpty(printRequest.getFritext()) ? "-" : printRequest.getFritext(),
                    PdfExportConstants.FRONTPAGE_NORMAL));

    // Visa Patientuppgifter
    Paragraph visaPatientUppgifter = new Paragraph(FILTER_TITLE_VISAPATIENTUPPGIFTER,
            PdfExportConstants.FRONTPAGE_H3);
    visaPatientUppgifter.add(
            new Phrase(printRequest.isShowPatientId() ? " Ja" : " Nej", PdfExportConstants.FRONTPAGE_NORMAL));

    // lder
    Paragraph valdAlder = new Paragraph(FILTER_TITLE_VALD_ALDER, PdfExportConstants.FRONTPAGE_H3);
    Paragraph alderVarden = new Paragraph();
    alderVarden.add(new Chunk("Mellan ", PdfExportConstants.FRONTPAGE_NORMAL));
    alderVarden.add(new Chunk(String.valueOf(printRequest.getAldersIntervall().getMin()),
            PdfExportConstants.FRONTPAGE_NORMAL_BOLD));
    alderVarden.add(new Chunk(" och ", PdfExportConstants.FRONTPAGE_NORMAL));
    alderVarden.add(new Chunk(String.valueOf(printRequest.getAldersIntervall().getMax()),
            PdfExportConstants.FRONTPAGE_NORMAL_BOLD));
    alderVarden.add(new Chunk(" r.", PdfExportConstants.FRONTPAGE_NORMAL));
    valdAlder.add(alderVarden);

    // Diagnoser
    Paragraph valdaDiagnoser = new Paragraph(FILTER_TITLE_VALDA_DIAGNOSER, PdfExportConstants.FRONTPAGE_H3);
    com.itextpdf.text.List diagnosLista = new com.itextpdf.text.List(com.itextpdf.text.List.UNORDERED);
    if (printRequest.getDiagnosGrupper() != null) {
        printRequest.getDiagnosGrupper().forEach(dg -> diagnosLista
                .add(new ListItem(getDiagnosKapitelDisplayValue(dg), PdfExportConstants.FRONTPAGE_NORMAL)));
    } else {
        diagnosLista.add(new ListItem(SELECTION_VALUE_ALLA, PdfExportConstants.FRONTPAGE_NORMAL));
    }
    valdaDiagnoser.add(diagnosLista);

    // Slutdddatum
    Paragraph valdSlutdatum = new Paragraph(FILTER_TITLE_VALD_SLUTDATUM, PdfExportConstants.FRONTPAGE_H3);
    Paragraph slutdatumVarden = new Paragraph(getFilterDate(printRequest.getSlutdatumIntervall()),
            PdfExportConstants.FRONTPAGE_NORMAL);
    valdSlutdatum.add(slutdatumVarden);

    // Sjukskrivningslangd
    Paragraph valdSjukskrivninglangd = new Paragraph(FILTER_TITLE_VALD_SJUKSKRIVNINGSLANGD,
            PdfExportConstants.FRONTPAGE_H3);
    Paragraph sjukskrivningslangdVarden = new Paragraph();
    sjukskrivningslangdVarden.add(new Chunk("Mellan ", PdfExportConstants.FRONTPAGE_NORMAL));
    sjukskrivningslangdVarden.add(new Chunk(String.valueOf(printRequest.getLangdIntervall().getMin()),
            PdfExportConstants.FRONTPAGE_NORMAL_BOLD));
    sjukskrivningslangdVarden.add(new Chunk(" och ", PdfExportConstants.FRONTPAGE_NORMAL));
    sjukskrivningslangdVarden.add(new Chunk(String.valueOf(printRequest.getLangdIntervall().getMax()),
            PdfExportConstants.FRONTPAGE_NORMAL_BOLD));
    sjukskrivningslangdVarden.add(new Chunk(" dagar.", PdfExportConstants.FRONTPAGE_NORMAL));
    valdSjukskrivninglangd.add(sjukskrivningslangdVarden);

    // Lakare
    Paragraph valdaLakare = new Paragraph(FILTER_TITLE_VALDA_LAKARE, PdfExportConstants.FRONTPAGE_H3);
    com.itextpdf.text.List lakarLista = new com.itextpdf.text.List(com.itextpdf.text.List.UNORDERED);
    if (printRequest.getLakare() != null) {

        printRequest.getLakare()
                .forEach(dg -> lakarLista.add(new ListItem(dg, PdfExportConstants.FRONTPAGE_NORMAL)));
    } else {
        lakarLista
                .add(new ListItem(user.getUrval() == Urval.ISSUED_BY_ME ? user.getNamn() : SELECTION_VALUE_ALLA,
                        PdfExportConstants.FRONTPAGE_NORMAL));
    }
    valdaLakare.add(lakarLista);

    // Lagg ihop undergrupperna till filter
    Paragraph filter = new Paragraph(VALDA_FILTER, PdfExportConstants.FRONTPAGE_H2);
    filter.add(valdFritext);
    filter.add(visaPatientUppgifter);
    filter.add(valdAlder);
    filter.add(valdaDiagnoser);
    filter.add(valdSlutdatum);
    filter.add(valdSjukskrivninglangd);
    filter.add(valdaLakare);

    return filter;
}