Example usage for com.itextpdf.text Chunk setUnderline

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

Introduction

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

Prototype

public Chunk setUnderline(final float thickness, final float yPosition) 

Source Link

Document

Sets an horizontal line that can be an underline or a strikethrough.

Usage

From source file:beans.ManagedBeanReportes.java

public void inventario() throws DocumentException, IOException {
    FacesContext facexcontext = FacesContext.getCurrentInstance();
    ValueExpression vex = facexcontext.getApplication().getExpressionFactory()
            .createValueExpression(facexcontext.getELContext(), "#{managedBeanLogin}", ManagedBeanLogin.class);
    ManagedBeanLogin beanLogin = (ManagedBeanLogin) vex.getValue(facexcontext.getELContext());

    FacesContext context = FacesContext.getCurrentInstance();

    Document document = new Document(PageSize.A4, 25, 25, 75, 25);//int marginLeft,   int marginRight,   int marginTop,   int marginBottom

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PdfWriter writer = PdfWriter.getInstance(document, baos);
    writer.setPageEvent(new ManagedBeanReportes.Watermark(""));
    if (!document.isOpen()) {
        document.open();/*from   w  w w.  j  ava 2  s .  co  m*/
    }

    try {

        ExternalContext extContext = FacesContext.getCurrentInstance().getExternalContext();
        //String imageUrl1 = extContext.getRealPath("//resources//images/logo0002.png");
        //Image welladigital = Image.getInstance(imageUrl1);
        //welladigital.setAbsolutePosition(377f, 760f);
        //welladigital.scalePercent(40);
        //document.add(welladigital);

        //crear tabla PARA NOMBRE DEL AO
        PdfPTable table = new PdfPTable(3);
        table.setWidthPercentage(100);
        table.setTotalWidth(450f);
        // table.setTotalWidth(540f);
        table.setLockedWidth(true);
        float[] headerWidths = { 120, 20, 310 };
        table.setWidths(headerWidths);
        table.getDefaultCell();

        SimpleDateFormat formato = new SimpleDateFormat("EEEE dd MMMM YYYY");
        StringBuilder cadena = new StringBuilder(formato.format(fecha_inicio));

        Chunk underline = new Chunk("FECHA DE INVENTARIO:" + cadena.toString().toUpperCase(), bigFont12);
        underline.setUnderline(0.2f, -2f); //0.1 thick, -2 y-location
        PdfPCell table5 = new PdfPCell(new Paragraph(underline));
        table5.setHorizontalAlignment(Paragraph.ALIGN_CENTER);
        table5.setColspan(3);
        table5.setBorder(Rectangle.NO_BORDER);
        table.addCell(table5);

        document.add(table);

        document.add(new Paragraph("\n", pequeFont));

        PdfPCell table2 = new PdfPCell();

        table2 = new PdfPCell(
                new Paragraph(beanLogin.getObjetoEmpleado().getTienda().getNombreTienda(), pequeFont));
        table2.setHorizontalAlignment(Paragraph.ALIGN_CENTER);
        table2.setColspan(3);
        table2.setBorder(Rectangle.NO_BORDER);
        table = new PdfPTable(3);
        table.setWidthPercentage(100);
        table.setTotalWidth(450f);
        table.setLockedWidth(true);
        table.setWidths(headerWidths);
        table.getDefaultCell();
        table.addCell(table2);
        document.add(table);

        document.add(new Paragraph("\n", pequeFont));

        document.add(traerSubtabla(beanLogin.getObjetoEmpleado().getTienda()));
        formato = new SimpleDateFormat("yyyy-MM-dd");
        cadena = new StringBuilder(formato.format(fecha_inicio));

        //document.add(traerSubtabla02(cadena.toString()));
        document.add(new Paragraph("\n", pequeFont));
        ExternalContext ctx = FacesContext.getCurrentInstance().getExternalContext();
        String ctxPath = ((ServletContext) ctx.getContext()).getContextPath();
        document.close();
        formato = new SimpleDateFormat("dd_MM_yyyy");
        cadena = new StringBuilder(formato.format(fecha_inicio));
        String fileName = cadena.toString();

        writePDFToResponse(context.getExternalContext(), baos, fileName);
        context.responseComplete();

    } catch (Exception de) {
        de.printStackTrace();
    }
}

From source file:com.carfinance.module.common.controller.DocumentDownloadController.java

/**
 * ???PDF/*  ww w .j av  a  2s.c  o  m*/
 * @param model
 * @param request
 * @param response
 */
@RequestMapping(value = "/pdfcontrace", method = RequestMethod.GET)
public void pdfContrace(Model model, HttpServletRequest request, HttpServletResponse response) {
    String contrace_id_str = request.getParameter("contrace_id");
    long contrace_type = Long.valueOf(request.getParameter("contrace_type"));//??1-2-?
    long vehicle_contrace_id = Long.valueOf(request.getParameter("vehicle_contrace_id"));

    String org_id = "";
    String contrace_no = "";
    String customer_name = "";
    String license_plate = "";
    String vehicle_model = "";
    String engine_no = "";
    String carframe_no = "";
    double guide_price = 0;
    String color = "";
    String begin_time = "";
    String end_time = "";
    String driving_user_name = "";
    String driving_user_license_no = "";
    String daily_price = "";
    String daily_available_km = "";
    String over_km_price = "";
    String over_hour_price = "";
    String month_price = "";
    String month_available_km = "";
    String pre_payment = "";
    String deposit = "";
    String monthly_day = "";
    String vehicle_id = "";

    if (contrace_type == 1) {
        VehicleContraceInfo vehicleContraceInfo = this.vehicleServiceManageService
                .getVehicleContraceInfoById(Long.valueOf(contrace_id_str));
        if (vehicleContraceInfo != null) {
            org_id = String.valueOf(vehicleContraceInfo.getOrg_id());
            contrace_no = vehicleContraceInfo.getContrace_no();
            customer_name = vehicleContraceInfo.getCustomer_name();

            //                List<VehicleContraceVehsInfo> vehsList = this.vehicleServiceManageService.getVehicleContraceVehsListByContraceId(vehicleContraceInfo.getId());
            //                if(vehsList != null) {
            //                    VehicleContraceVehsInfo vehsInfo = vehsList.get(0);
            VehicleContraceVehsInfo vehsInfo = this.vehicleServiceManageService
                    .getContraceVehicleByid(vehicle_contrace_id);
            VehicleInfo vehicleInfo = this.vehicleManageService.getVehicleInfoByid(vehsInfo.getVehicle_id());

            license_plate = vehicleInfo.getLicense_plate();
            vehicle_model = vehicleInfo.getModel();
            engine_no = vehicleInfo.getEngine_no();
            carframe_no = vehicleInfo.getCarframe_no();
            guide_price = vehicleInfo.getGuide_price();
            color = vehicleInfo.getColor();

            driving_user_name = vehsInfo.getDriving_user_name();
            driving_user_license_no = vehsInfo.getDriving_user_license_no();

            daily_price = vehicleInfo.getDaily_price() + "";
            vehicle_id = vehicleInfo.getId() + "";
            //                }

            begin_time = vehicleContraceInfo.getUse_begin();
            end_time = vehicleContraceInfo.getUse_end();

            daily_available_km = vehicleContraceInfo.getDaily_available_km() + "";
            over_km_price = vehicleContraceInfo.getOver_km_price() + "";
            over_hour_price = vehicleContraceInfo.getOver_hour_price() + "";
            month_price = vehicleContraceInfo.getMonth_price() + "";
            month_available_km = vehicleContraceInfo.getMonth_available_km() + "";
            pre_payment = vehicleContraceInfo.getPre_payment() + "";
            deposit = vehicleContraceInfo.getDeposit() + "";
            monthly_day = vehicleContraceInfo.getMonthly_day() + "";
        }
    } else if (contrace_type == 2) {
        PropertyContraceInfo propertyContraceInfo = this.vehicleServiceManageService
                .getPropertyContraceInfoById(Long.valueOf(contrace_id_str));
        if (propertyContraceInfo != null) {
            org_id = String.valueOf(propertyContraceInfo.getOrg_id());
            contrace_no = propertyContraceInfo.getContrace_no();
            customer_name = propertyContraceInfo.getCustomer_name();
        }
    }
    //1.ContentType
    response.setContentType("multipart/form-data");
    //2.????(??a.pdf)
    response.setHeader("Content-Disposition", "attachment;fileName=" + contrace_no + "_" + vehicle_id + ".pdf");

    Document pdfDoc = new Document(PageSize.A4, 50, 50, 50, 50);
    // ?? pdf ?
    try {
        BaseFont bfChinese = BaseFont.createFont("STSongStd-Light", "UniGB-UCS2-H", false);

        Font bold_fontChinese = new Font(bfChinese, 18, Font.BOLD, BaseColor.BLACK);
        Font normal_fontChinese = new Font(bfChinese, 12, Font.NORMAL, BaseColor.BLACK);
        Font normal_desc_fontChinese = new Font(bfChinese, 6, Font.NORMAL, BaseColor.BLACK);

        FileOutputStream pdfFile = new FileOutputStream(new File(
                appProps.get("normal.contrace.download.path") + contrace_no + "_" + vehicle_id + ".pdf"));
        // pdf ?
        Paragraph paragraph1 = new Paragraph("???", bold_fontChinese);
        paragraph1.setAlignment(Element.ALIGN_CENTER);

        Chunk customer_name_underline = new Chunk(customer_name);
        customer_name_underline.setUnderline(1f, 3f);

        Chunk license_plate_underline = new Chunk(license_plate);
        license_plate_underline.setUnderline(1f, 3f);

        Chunk vehicle_model_underline = new Chunk(vehicle_model);
        vehicle_model_underline.setUnderline(1f, 3f);

        Chunk engine_no_underline = new Chunk(engine_no);
        engine_no_underline.setUnderline(1f, 3f);

        Chunk carframe_no_underline = new Chunk(carframe_no);
        carframe_no_underline.setUnderline(1f, 3f);

        Chunk guide_price_underline = new Chunk(guide_price / 10000 + "");
        guide_price_underline.setUnderline(1f, 3f);

        Chunk color_underline = new Chunk(color);
        color_underline.setUnderline(1f, 3f);

        Chunk begin_time_underline = new Chunk(begin_time);
        begin_time_underline.setUnderline(1f, 3f);

        Chunk end_time_underline = new Chunk(end_time);
        end_time_underline.setUnderline(1f, 3f);

        Chunk driving_user_name_underline = new Chunk(
                driving_user_name == null ? "___/___" : driving_user_name);
        driving_user_name_underline.setUnderline(1f, 3f);

        Chunk driving_user_license_no_underline = new Chunk(
                driving_user_license_no == null ? "_____/_____" : driving_user_license_no);
        driving_user_license_no_underline.setUnderline(1f, 3f);

        Chunk daily_price_underline = new Chunk(daily_price);
        daily_price_underline.setUnderline(1f, 3f);

        Chunk daily_available_km_underline = new Chunk(daily_available_km);
        daily_available_km_underline.setUnderline(1f, 3f);

        Chunk over_km_price_underline = new Chunk(over_km_price);
        over_km_price_underline.setUnderline(1f, 3f);

        Chunk over_hour_price_underline = new Chunk(over_hour_price);
        over_hour_price_underline.setUnderline(1f, 3f);

        Chunk month_price_underline = new Chunk(month_price == null ? "_____/_____" : month_price);
        month_price_underline.setUnderline(1f, 3f);

        Chunk month_available_km_underline = new Chunk(
                month_available_km == null ? "_____/_____" : month_available_km);
        month_available_km_underline.setUnderline(1f, 3f);

        Chunk pre_payment_underline = new Chunk(pre_payment);
        pre_payment_underline.setUnderline(1f, 3f);

        Chunk deposit_underline = new Chunk(deposit);
        deposit_underline.setUnderline(1f, 3f);

        Chunk monthly_day_underline = new Chunk(monthly_day == null ? "___/___" : monthly_day);
        monthly_day_underline.setUnderline(1f, 3f);

        Paragraph paragraph2 = new Paragraph(
                "???    ???"
                        + contrace_no,
                normal_fontChinese);
        Paragraph paragraph3 = new Paragraph("" + customer_name_underline
                + " (    20____________", normal_fontChinese);
        Paragraph paragraph4 = new Paragraph(
                "??? ??????????",
                normal_fontChinese);
        Paragraph paragraph5 = new Paragraph("???____"
                + license_plate_underline + "____?____" + vehicle_model_underline
                + "________" + color_underline + "____??____" + engine_no_underline
                + "____?____" + carframe_no_underline + "____??____"
                + guide_price_underline + "____", normal_fontChinese);
        Paragraph paragraph6 = new Paragraph("?____" + begin_time_underline
                + "____?____" + end_time_underline + "____",
                normal_fontChinese);
        Paragraph paragraph7 = new Paragraph("??____"
                + driving_user_name_underline + "____??____" + driving_user_license_no_underline
                + "____?", normal_fontChinese);
        Paragraph paragraph8 = new Paragraph("????", normal_fontChinese);
        Paragraph paragraph9 = new Paragraph("1????____" + daily_price_underline
                + "____??____" + daily_available_km_underline
                + "____??____" + over_km_price_underline
                + "____??____" + over_hour_price_underline
                + "____??30????____"
                + month_price_underline + "____??____" + month_available_km_underline
                + "____30",
                normal_fontChinese);
        Paragraph paragraph10 = new Paragraph(
                "2??????8:00---20:00",
                normal_fontChinese);
        Paragraph paragraph11 = new Paragraph(
                "3??????",
                normal_fontChinese);
        Paragraph paragraph12 = new Paragraph(
                "4????____" + pre_payment_underline
                        + "____??____"
                        + monthly_day_underline + "____?",
                normal_fontChinese);
        Paragraph paragraph13 = new Paragraph("5???____"
                + deposit_underline
                + "____(???)???????",
                normal_fontChinese);
        Paragraph paragraph14 = new Paragraph(
                "6????1%????????",
                normal_fontChinese);
        Image image = Image.getInstance(appProps.get("normal.contrace.download.path") + "chekuang.jpg");

        Paragraph paragraph15 = new Paragraph("?", normal_desc_fontChinese);
        Paragraph paragraph16 = new Paragraph(
                "1?????????",
                normal_desc_fontChinese);
        Paragraph paragraph17 = new Paragraph(
                "2????5000?200",
                normal_desc_fontChinese);
        Paragraph paragraph18 = new Paragraph(
                "3????",
                normal_desc_fontChinese);
        Paragraph paragraph19 = new Paragraph(
                "4???????????????",
                normal_desc_fontChinese);
        Paragraph paragraph20 = new Paragraph(
                "5?????????",
                normal_desc_fontChinese);
        Paragraph paragraph21 = new Paragraph(
                "6????????????",
                normal_desc_fontChinese);
        Paragraph paragraph22 = new Paragraph("?", normal_desc_fontChinese);
        Paragraph paragraph23 = new Paragraph(
                "1???????",
                normal_desc_fontChinese);
        Paragraph paragraph24 = new Paragraph(
                "2?????????????????????????",
                normal_desc_fontChinese);
        Paragraph paragraph25 = new Paragraph(
                "3????????????????????????",
                normal_desc_fontChinese);
        Paragraph paragraph26 = new Paragraph(
                "4?????????????????",
                normal_desc_fontChinese);
        Paragraph paragraph27 = new Paragraph(
                "5????????????????????",
                normal_desc_fontChinese);
        Paragraph paragraph28 = new Paragraph(
                "6?????????????????????620%?30%??????????????????????",
                normal_desc_fontChinese);
        Paragraph paragraph29 = new Paragraph(
                "7???????????",
                normal_desc_fontChinese);
        Paragraph paragraph30 = new Paragraph(
                "8????????",
                normal_desc_fontChinese);

        Paragraph paragraph31 = new Paragraph(
                "9??????????????????????",
                normal_desc_fontChinese);
        Paragraph paragraph32 = new Paragraph(
                "10????????????",
                normal_desc_fontChinese);
        Paragraph paragraph33 = new Paragraph(
                "11???????????500-1000",
                normal_desc_fontChinese);
        Paragraph paragraph34 = new Paragraph(
                "12??????????",
                normal_desc_fontChinese);
        Paragraph paragraph35 = new Paragraph(
                "13?????_________________________________7??????????\n",
                normal_desc_fontChinese);
        Paragraph paragraph36 = new Paragraph(
                "14?????????????????",
                normal_desc_fontChinese);
        Paragraph paragraph37 = new Paragraph(
                "15?????????5000????????????????400?500100????",
                normal_desc_fontChinese);
        Paragraph paragraph38 = new Paragraph(
                "16???????????????????????????",
                normal_desc_fontChinese);
        Paragraph paragraph39 = new Paragraph("?", normal_desc_fontChinese);
        Paragraph paragraph40 = new Paragraph(
                "1??????????????",
                normal_desc_fontChinese);
        Paragraph paragraph41 = new Paragraph(
                "2????????????",
                normal_desc_fontChinese);
        Paragraph paragraph42 = new Paragraph(
                "3????",
                normal_desc_fontChinese);
        Paragraph paragraph43 = new Paragraph(
                "4??????????50%?????????",
                normal_desc_fontChinese);
        Paragraph paragraph44 = new Paragraph(
                "5???????????????????",
                normal_desc_fontChinese);
        Paragraph paragraph45 = new Paragraph(
                "6???????????????",
                normal_desc_fontChinese);
        Paragraph paragraph46 = new Paragraph(
                "7?????????50%",
                normal_desc_fontChinese);
        Paragraph paragraph47 = new Paragraph(
                "8???7????????????",
                normal_desc_fontChinese);
        Paragraph paragraph48 = new Paragraph(
                "9???_____/?40??8????_____??",
                normal_desc_fontChinese);
        Paragraph paragraph49 = new Paragraph(
                "10?????___?????",
                normal_desc_fontChinese);
        Paragraph paragraph50 = new Paragraph(
                "11????",
                normal_desc_fontChinese);
        Paragraph paragraph51 = new Paragraph("??", normal_desc_fontChinese);
        Paragraph paragraph52 = new Paragraph(
                "1?????????20%????",
                normal_desc_fontChinese);
        Paragraph paragraph53 = new Paragraph(
                "2???????????????????",
                normal_desc_fontChinese);
        Paragraph paragraph54 = new Paragraph(
                "?????___________________\n",
                normal_desc_fontChinese);
        Paragraph paragraph55 = new Paragraph(
                "???????????????",
                normal_desc_fontChinese);
        Paragraph paragraph56 = new Paragraph(
                "???????",
                normal_desc_fontChinese);
        Paragraph paragraph57 = new Paragraph("?????????",
                normal_desc_fontChinese);
        Paragraph paragraph58 = new Paragraph(
                "???                     ?",
                normal_desc_fontChinese);
        Paragraph paragraph59 = new Paragraph(
                "                                           ???                            ??",
                normal_desc_fontChinese);

        //  Document ?File  PdfWriter ?
        PdfWriter.getInstance(pdfDoc, pdfFile);
        pdfDoc.open(); //  Document 

        // ??
        pdfDoc.add(paragraph1);
        pdfDoc.add(new Chunk("\n\n"));
        pdfDoc.add(paragraph2);
        pdfDoc.add(paragraph3);
        pdfDoc.add(paragraph4);
        pdfDoc.add(paragraph5);
        pdfDoc.add(paragraph6);
        pdfDoc.add(paragraph7);
        pdfDoc.add(paragraph8);
        pdfDoc.add(paragraph9);
        pdfDoc.add(paragraph10);
        pdfDoc.add(paragraph11);
        pdfDoc.add(paragraph12);
        pdfDoc.add(paragraph13);
        pdfDoc.add(paragraph14);
        pdfDoc.add(image);

        pdfDoc.newPage();
        pdfDoc.add(paragraph15);
        pdfDoc.add(paragraph16);
        pdfDoc.add(paragraph17);
        pdfDoc.add(paragraph18);
        pdfDoc.add(paragraph19);
        pdfDoc.add(paragraph20);
        pdfDoc.add(paragraph21);
        pdfDoc.add(paragraph22);
        pdfDoc.add(paragraph23);
        pdfDoc.add(paragraph24);
        pdfDoc.add(paragraph25);
        pdfDoc.add(paragraph26);
        pdfDoc.add(paragraph27);
        pdfDoc.add(paragraph28);
        pdfDoc.add(paragraph29);
        pdfDoc.add(paragraph30);
        pdfDoc.add(paragraph31);
        pdfDoc.add(paragraph32);
        pdfDoc.add(paragraph33);
        pdfDoc.add(paragraph34);
        pdfDoc.add(paragraph35);
        pdfDoc.add(paragraph36);
        pdfDoc.add(paragraph37);
        pdfDoc.add(paragraph38);
        pdfDoc.add(paragraph39);
        pdfDoc.add(paragraph40);
        pdfDoc.add(paragraph41);
        pdfDoc.add(paragraph42);
        pdfDoc.add(paragraph43);
        pdfDoc.add(paragraph44);
        pdfDoc.add(paragraph45);
        pdfDoc.add(paragraph46);
        pdfDoc.add(paragraph47);
        pdfDoc.add(paragraph48);
        pdfDoc.add(paragraph49);
        pdfDoc.add(paragraph50);
        pdfDoc.add(paragraph51);
        pdfDoc.add(paragraph52);
        pdfDoc.add(paragraph53);
        pdfDoc.add(paragraph54);
        pdfDoc.add(paragraph55);
        pdfDoc.add(paragraph56);
        pdfDoc.add(paragraph57);
        pdfDoc.add(paragraph58);
        pdfDoc.add(paragraph59);

        pdfDoc.close();

        ServletOutputStream out;
        //File(?download.pdf)
        File file = new File(
                appProps.get("normal.contrace.download.path") + contrace_no + "_" + vehicle_id + ".pdf");

        try {
            FileInputStream inputStream = new FileInputStream(file);
            //3.response?ServletOutputStream(out)
            out = response.getOutputStream();
            int b = 0;
            byte[] buffer = new byte[512];
            while (b != -1) {
                b = inputStream.read(buffer);
                //4.?(out)
                out.write(buffer, 0, b);
            }
            inputStream.close();
            out.close();
            out.flush();
        } catch (IOException e) {
            e.printStackTrace();
        }
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:eeebees.PDFGen.java

public static void main(String[] args) {

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

        OutputStream file = new FileOutputStream(new File("D:\\PDF_Java4s.pdf"));
        Document document = new Document();
        PdfWriter.getInstance(document, file);

        //Inserting Image in PDF
        //Image image = Image.getInstance ("src/pdf/java4s.png");
        //image.scaleAbsolute(120f, 60f);//image width,height    

        //Inserting Table in PDF
        PdfPTable table = new PdfPTable(3);

        PdfPCell cell = new PdfPCell(new Paragraph("Java4s.com"));

        cell.setColspan(3);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setPadding(10.0f);
        cell.setBackgroundColor(new BaseColor(140, 221, 8));

        table.addCell(cell);

        table.addCell("Name");
        table.addCell("Address");
        table.addCell("Country");
        table.addCell("Java4s");
        table.addCell("NC");
        table.addCell("United States");
        table.setSpacingBefore(30.0f); // Space Before table starts, like margin-top in CSS
        table.setSpacingAfter(30.0f); // Space After table starts, like margin-Bottom in CSS                                          

        //Inserting List in PDF
        List list = new List(true, 30);
        list.add(new ListItem("Java4s"));
        list.add(new ListItem("Php4s"));
        list.add(new ListItem("Some Thing..."));

        //Text formating in PDF
        Chunk chunk = new Chunk("Welecome To Java4s Programming Blog...");
        chunk.setUnderline(+1f, -2f);//1st co-ordinate is for line width,2nd is space between
        Chunk chunk1 = new Chunk("Php4s.com");
        chunk1.setUnderline(+4f, -8f);
        chunk1.setBackground(new BaseColor(17, 46, 193));

        //Now Insert Every Thing Into PDF Document
        document.open();//PDF document opened........                   

        //document.add(image);

        document.add(Chunk.NEWLINE); //Something like in HTML :-)

        document.add(new Paragraph("Dear Java4s.com"));
        document.add(new Paragraph("Document Generated On - " + new Date().toString()));

        document.add(table);

        document.add(chunk);
        document.add(chunk1);

        document.add(Chunk.NEWLINE); //Something like in HTML :-)                                

        document.newPage(); //Opened new page
        document.add(list); //In the new page we are going to add list

        document.close();

        file.close();

        System.out.println("Pdf created successfully..");

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

From source file:org.openmrs.module.laboratorymanagement.db.hibernate.LaboratoryDAOimpl.java

License:Open Source License

public void exportPatientReportToPDF(HttpServletRequest request, HttpServletResponse response,
        Map<ConceptName, List<Object[]>> mappedLabExam, String filename, String title, int patientId)
        throws DocumentException, IOException {

    Document document = new Document();
    Patient patient = Context.getPatientService().getPatient(patientId);
    // List<PatientBill> patientBills =
    // (List<PatientBill>)request.getAttribute("reportedPatientBillsPrint");

    /*//w  ww.j  a v  a2  s. c o  m
     * PatientBill pb = null;
     * 
     * pb = Context.getService(BillingService.class).getPatientBill(
     * Integer.parseInt(request.getParameter("patientBills")));
     */
    /*
     * String filename = pb.getBeneficiary().getPatient().getPersonName()
     * .toString().replace(" ", "_"); filename =
     * pb.getBeneficiary().getPolicyIdNumber().replace(" ", "_") + "_" +
     * filename + ".pdf";
     */
    response.setContentType("application/pdf");
    response.setHeader("Content-Disposition", "report"); // file name

    PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream());
    writer.setBoxSize("art", new Rectangle(0, 0, 2382, 3369));
    writer.setBoxSize("art", PageSize.A4);

    HeaderFooterMgt event = new HeaderFooterMgt();
    writer.setPageEvent(event);

    document.open();
    document.setPageSize(PageSize.A4);
    // document.setPageSize(new Rectangle(0, 0, 2382, 3369));

    document.addAuthor(Context.getAuthenticatedUser().getPersonName().toString());// the name of the author

    FontSelector fontTitle = new FontSelector();
    fontTitle.addFont(new Font(FontFamily.COURIER, 10.0f, Font.ITALIC));

    // Report title
    Chunk chk = new Chunk("Printed on : " + (new SimpleDateFormat("dd-MMM-yyyy").format(new Date())));
    chk.setFont(new Font(FontFamily.COURIER, 10.0f, Font.BOLD));
    Paragraph todayDate = new Paragraph();
    todayDate.setAlignment(Element.ALIGN_RIGHT);
    todayDate.add(chk);
    document.add(todayDate);
    document.add(fontTitle.process("REPUBLIQUE DU RWANDA\n"));
    document.add(fontTitle.process("POLICE NATIONALE\n"));
    document.add(fontTitle.process("KACYIRU POLICE HOSPITAL\n"));
    document.add(fontTitle.process("B.P. 6183 KIGALI\n"));
    document.add(fontTitle.process("Tl : 584897\n"));
    document.add(fontTitle.process("E-mail : medical@police.gov.rw"));
    // End Report title

    document.add(new Paragraph("\n"));
    chk = new Chunk("Laboratory results");
    chk.setFont(new Font(FontFamily.COURIER, 10.0f, Font.BOLD));
    chk.setUnderline(0.2f, -2f);
    Paragraph pa = new Paragraph();
    pa.add(chk);
    pa.setAlignment(Element.ALIGN_CENTER);
    document.add(pa);
    document.add(new Paragraph("\n"));

    document.add(fontTitle.process("Family Name: " + patient.getFamilyName() + "\n"));
    document.add(fontTitle.process("Given name: " + patient.getGivenName() + "\n"));
    document.add(fontTitle.process("Age: " + patient.getAge() + "\n"));

    // title row
    FontSelector fontTitleSelector = new FontSelector();
    fontTitleSelector.addFont(new Font(FontFamily.COURIER, 9, Font.ITALIC));
    // Table of identification;
    PdfPTable table = null;
    table = new PdfPTable(2);
    table.setWidthPercentage(100f);

    // tableHeader.addCell(table);

    // document.add(tableHeader);

    document.add(new Paragraph("\n"));

    // Table of lab report items;
    float[] colsWidth = { 6f, 3f, 6f };
    table = new PdfPTable(colsWidth);
    table.setWidthPercentage(100f);
    BaseColor bckGroundTitle = new BaseColor(170, 170, 170);
    BaseColor bckGroundTitl = new BaseColor(Color.yellow);

    // table Header
    PdfPCell cell = new PdfPCell(fontTitleSelector.process("Exam"));

    cell.setBackgroundColor(bckGroundTitle);

    table.addCell(cell);

    cell = new PdfPCell(fontTitleSelector.process("Result"));
    cell.setBackgroundColor(bckGroundTitle);

    table.addCell(cell);

    cell = new PdfPCell(fontTitleSelector.process("Normal Range"));
    cell.setBackgroundColor(bckGroundTitle);
    table.addCell(cell);
    /*
     * cell = new PdfPCell(fontTitleSelector.process("Date "));
     * cell.setBackgroundColor(bckGroundTitle); table.addCell(cell);
     */

    // normal row
    FontSelector fontselector = new FontSelector();
    fontselector.addFont(new Font(FontFamily.COURIER, 8, Font.NORMAL));

    // empty row
    FontSelector fontTotals = new FontSelector();
    fontTotals.addFont(new Font(FontFamily.COURIER, 9, Font.BOLD));

    // ===========================================================
    for (ConceptName cptName : mappedLabExam.keySet()) {

        cell = new PdfPCell(fontTitleSelector.process("" + cptName));
        cell.setBackgroundColor(bckGroundTitl);

        table.addCell(cell);
        cell = new PdfPCell(fontTitleSelector.process(""));
        table.addCell(cell);
        cell = new PdfPCell(fontTitleSelector.process(""));
        table.addCell(cell);

        List<Object[]> labExamHistory = mappedLabExam.get(cptName);
        for (Object[] labExam : labExamHistory) {
            // table Header
            // Object[] labe = listOflabtest.get(i);
            Obs ob = (Obs) labExam[0];
            cell = new PdfPCell(fontTitleSelector.process("" + ob.getConcept().getName()));

            table.addCell(cell);
            if (ob.getConcept().getDatatype().isNumeric()) {
                cell = new PdfPCell(fontTitleSelector.process("" + ob.getValueNumeric()));
                table.addCell(cell);

            }

            if (ob.getConcept().getDatatype().isCoded()) {
                cell = new PdfPCell(fontTitleSelector.process("" + ob.getValueCoded().getName()));
                table.addCell(cell);

            }

            if (ob.getConcept().getDatatype().isText()) {
                cell = new PdfPCell(fontTitleSelector.process("" + ob.getValueText()));
                table.addCell(cell);

            }

            cell = new PdfPCell(fontTitleSelector.process("" + (labExam[1] != null ? labExam[1] : "-")));
            table.addCell(cell);

            fontselector.addFont(new Font(FontFamily.COURIER, 8, Font.NORMAL));

            // empty row
            // FontSelector fontTotals = new FontSelector();
            fontTotals.addFont(new Font(FontFamily.COURIER, 9, Font.BOLD));

        }

    }

    cell = new PdfPCell(fontTitleSelector.process("Names, Signature et Stamp of Lab Chief\n"
            //+ Context.getAuthenticatedUser().getPersonName()));
            + Context.getUserService().getUser(140).getPersonName()));

    cell.setBorder(Rectangle.NO_BORDER);
    table.addCell(cell);
    // ================================================================
    table.addCell(cell);

    document.add(table);

    // Table of signatures;
    table = new PdfPTable(2);
    table.setWidthPercentage(100f);

    cell = new PdfPCell(fontTitleSelector.process(" "));

    cell.setBorder(Rectangle.NO_BORDER);
    table.addCell(cell);

    cell = new PdfPCell(fontTitleSelector.process(
            "Names, Signature and  Stamp of Provider\n" + Context.getAuthenticatedUser().getPersonName()));
    cell.setBorder(Rectangle.NO_BORDER);
    table.addCell(cell);
    document.add(table);
    document.close();

    document.close();
}

From source file:Servlets.ReportsServlet.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods./*from w w w.  j  a  va2s .c o m*/
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    try {

        Paragraph pp;
        Paragraph palaglapgh, signParagraph, dateParagrapgh;
        Chunk chk;
        Paragraph underText;
        Chunk chuk1;
        Chunk chuk2;
        Paragraph regionText;
        String x;
        ResultSet dir;
        Paragraph regionTexts;
        String repLot;
        repLot = request.getParameter("report");

        String repNum = request.getParameter("ITLot");
        Paragraph newDate;
        response.setContentType("application/pdf");
        OutputStream out = response.getOutputStream();

        //Create document for pdf
        Document doc = new Document();

        //PDF writer to write into document
        PdfWriter docwriter = null;

        DecimalFormat df = new DecimalFormat("0.00");

        switch (repLot) {
        default:

            break;
        case "IT Report":

            //Copied code start from here
            try {
                // //file path
                //String path = "docs/" + "Name";
                docwriter = PdfWriter.getInstance(doc, out);
            } catch (DocumentException ex) {
                Logger.getLogger(PDFDemo.class.getName()).log(Level.SEVERE, null, ex);
            }

            //document header attributes
            doc.addAuthor("CHED CU");
            doc.addCreationDate();
            doc.addProducer();
            doc.addCreator("Grant Monitor");
            doc.addTitle(repLot);
            doc.setPageSize(PageSize.A4.rotate()); //This sets page size to A4 and orientation to Landscape
            //doc.setPageSize(PageSize.A4);
            doc.setMargins(20f, 20f, 10f, 10f);

            //open document
            doc.open();

            //Creating a paragraphs and chunks
            pp = new Paragraph("Cocoa Health And Extension Division", forTitle);
            pp.setAlignment(Element.ALIGN_CENTER);

            palaglapgh = new Paragraph("(Cocobod)", bfBold12);
            palaglapgh.setAlignment(Element.ALIGN_CENTER);

            signParagraph = new Paragraph("Sign: ..............", bfBold12);
            signParagraph.setAlignment(Element.ALIGN_LEFT);

            dateParagrapgh = new Paragraph("Date: ...........", bfBold12);

            chk = new Chunk("From GIS Office, Accra", bfBold12);
            chk.setUnderline(.1f, -2f); // 0.1 thickness and -2 position
            underText = new Paragraph(chk);
            underText.setAlignment(Element.ALIGN_CENTER);

            chuk1 = new Chunk("Lot No:", forTitle2);
            chuk1.setUnderline(.1f, -2f);
            chuk2 = new Chunk(repNum.toUpperCase(), forTitle2);

            regionText = new Paragraph(repLot, forTitle2);
            regionText.setAlignment(Element.ALIGN_CENTER);
            x = "";
            dir = manager.PDFdemos(repNum);
            try {
                if (dir.next()) {
                    x = dir.getString(12);

                }
            } catch (SQLException ex) {
                Logger.getLogger(PDFDemo.class.getName()).log(Level.SEVERE, null, ex);
            }

            regionTexts = new Paragraph(x, forTitle2);
            regionText.setAlignment(Element.ALIGN_CENTER);
            //add the PDF table to the paragraph
            //palaglapgh.add(table);
            //Table Generation block
            regionText.add(reports(repNum, repLot, .25f));

            //SECTION TO ADD ELEMENTS TO PDF
            // add the paragraph to the document
            doc.add(pp);
            //doc.add(Chunk.NEWLINE);       //Adds a new blank line
            doc.add(palaglapgh);
            doc.add(underText);

            doc.add(chuk1);
            doc.add(chuk2);

            //Current Date and time insertion
            newDate = new Paragraph(date, bf12);
            newDate.setAlignment(Element.ALIGN_RIGHT);
            doc.add(newDate);
            doc.add(regionTexts);
            doc.add(regionText);

            doc.add(Chunk.NEWLINE); //Adds a new blank line
            doc.add(Chunk.NEWLINE);

            doc.add(signParagraph);
            doc.add(dateParagrapgh);

            //close the document
            doc.close();

            //close the writer
            docwriter.close();

            out.close();

            break;

        case "TR Report":

            //Copied code start from here
            try {
                // //file path
                //String path = "docs/" + "Name";
                docwriter = PdfWriter.getInstance(doc, out);
            } catch (DocumentException ex) {
                Logger.getLogger(PDFDemo.class.getName()).log(Level.SEVERE, null, ex);
            }

            //document header attributes
            doc.addAuthor("CHED CU");
            doc.addCreationDate();
            doc.addProducer();
            doc.addCreator("Grant Monitor");
            doc.addTitle(repLot);
            //doc.setPageSize(PageSize.A4.rotate());      //This sets page size to A4 and orientation to Landscape
            doc.setPageSize(PageSize.A4);
            doc.setMargins(30f, 30f, 20f, 20f);

            //open document
            doc.open();

            //Creating a paragraphs and chunks
            pp = new Paragraph("Cocoa Health And Extension Division", forTitle);
            pp.setAlignment(Element.ALIGN_CENTER);

            palaglapgh = new Paragraph("(Cocobod)", bfBold12);
            palaglapgh.setAlignment(Element.ALIGN_CENTER);

            signParagraph = new Paragraph("Sign: ..............", bfBold12);
            signParagraph.setAlignment(Element.ALIGN_LEFT);

            dateParagrapgh = new Paragraph("Date: ...........", bfBold12);

            chk = new Chunk("From GIS Office, Accra", bfBold12);
            chk.setUnderline(.1f, -2f); // 0.1 thickness and -2 position
            underText = new Paragraph(chk);
            underText.setAlignment(Element.ALIGN_CENTER);

            chuk1 = new Chunk("Lot No:", forTitle2);
            chuk1.setUnderline(.1f, -2f); // 0.1 thickness and -2 position
            chuk2 = new Chunk(repNum.toUpperCase(), forTitle2);

            regionText = new Paragraph(repLot, forTitle2);
            regionText.setAlignment(Element.ALIGN_CENTER);

            x = "";
            dir = manager.PDFdemos(repNum);
            try {
                if (dir.next()) {
                    x = dir.getString(12);

                }
            } catch (SQLException ex) {
                Logger.getLogger(PDFDemo.class.getName()).log(Level.SEVERE, null, ex);
            }

            regionTexts = new Paragraph(x, forTitle2);
            regionText.setAlignment(Element.ALIGN_CENTER);
            //add the PDF table to the paragraph
            //palaglapgh.add(table);
            //Table Generation block
            regionText.add(reports(repNum, repLot, .1f));

            //SECTION TO ADD ELEMENTS TO PDF
            // add the paragraph to the document
            doc.add(pp);
            //doc.add(Chunk.NEWLINE);       //Adds a new blank line
            doc.add(palaglapgh);
            doc.add(underText);

            doc.add(chuk1);
            doc.add(chuk2);

            //Current Date and time insertion
            newDate = new Paragraph(date, bf12);
            newDate.setAlignment(Element.ALIGN_RIGHT);
            doc.add(newDate);
            doc.add(regionTexts);
            doc.add(regionText);

            doc.add(Chunk.NEWLINE); //Adds a new blank line
            doc.add(Chunk.NEWLINE);

            doc.add(signParagraph);
            doc.add(dateParagrapgh);

            //close the document
            doc.close();

            //close the writer
            docwriter.close();

            out.close();

            break;

        case "RP Report":

            //Copied code start from here
            try {
                // //file path
                //String path = "docs/" + "Name";
                docwriter = PdfWriter.getInstance(doc, out);
            } catch (DocumentException ex) {
                Logger.getLogger(PDFDemo.class.getName()).log(Level.SEVERE, null, ex);
            }

            //document header attributes
            doc.addAuthor("CHED CU");
            doc.addCreationDate();
            doc.addProducer();
            doc.addCreator("Grant Monitor");
            doc.addTitle(repLot);
            doc.setPageSize(PageSize.A4.rotate()); //This sets page size to A4 and orientation to Landscape
            //doc.setPageSize(PageSize.A4);
            doc.setMargins(30f, 30f, 20f, 20f);

            //open document
            doc.open();

            //Creating a paragraphs and chunks
            pp = new Paragraph("Cocoa Health And Extension Division", forTitle);
            pp.setAlignment(Element.ALIGN_CENTER);

            palaglapgh = new Paragraph("(Cocobod)", bfBold12);
            palaglapgh.setAlignment(Element.ALIGN_CENTER);

            signParagraph = new Paragraph("Sign: ..............", bfBold12);
            signParagraph.setAlignment(Element.ALIGN_LEFT);

            dateParagrapgh = new Paragraph("Date: ...........", bfBold12);

            chk = new Chunk("From GIS Office, Accra", bfBold12);
            chk.setUnderline(.1f, -2f); // 0.1 thickness and -2 position
            underText = new Paragraph(chk);
            underText.setAlignment(Element.ALIGN_CENTER);

            chuk1 = new Chunk("RP Lot No:", forTitle2);
            chuk1.setUnderline(.1f, -2f);
            chuk2 = new Chunk(repNum.toUpperCase(), forTitle2);

            regionText = new Paragraph(repLot, forTitle2);
            regionText.setAlignment(Element.ALIGN_CENTER);
            x = "";
            dir = manager.PDFreplants(repNum);
            try {
                if (dir.next()) {
                    x = dir.getString(22);

                }
            } catch (SQLException ex) {
                Logger.getLogger(PDFDemo.class.getName()).log(Level.SEVERE, null, ex);
            }

            regionTexts = new Paragraph(x, forTitle2);
            regionText.setAlignment(Element.ALIGN_CENTER);
            //add the PDF table to the paragraph
            //palaglapgh.add(table);
            //Table Generation block
            regionText.add(RPreport(repNum));

            //SECTION TO ADD ELEMENTS TO PDF
            // add the paragraph to the document
            doc.add(pp);
            //doc.add(Chunk.NEWLINE);       //Adds a new blank line
            doc.add(palaglapgh);
            doc.add(underText);

            doc.add(chuk1);
            doc.add(chuk2);

            //Current Date and time insertion
            newDate = new Paragraph(date, bf12);
            newDate.setAlignment(Element.ALIGN_RIGHT);
            doc.add(newDate);
            doc.add(regionTexts);
            doc.add(regionText);

            doc.add(Chunk.NEWLINE); //Adds a new blank line
            doc.add(Chunk.NEWLINE);

            doc.add(signParagraph);
            doc.add(dateParagrapgh);

            //close the document
            doc.close();

            //close the writer
            docwriter.close();

            out.close();

            break;

        case "Rehab Report":

            //Copied code start from here
            try {
                // //file path
                //String path = "docs/" + "Name";
                docwriter = PdfWriter.getInstance(doc, out);
            } catch (DocumentException ex) {
                Logger.getLogger(PDFDemo.class.getName()).log(Level.SEVERE, null, ex);
            }

            //document header attributes
            doc.addAuthor("CHED CU");
            doc.addCreationDate();
            doc.addProducer();
            doc.addCreator("Grant Monitor");
            doc.addTitle(repLot);
            doc.setPageSize(PageSize.A4.rotate()); //This sets page size to A4 and orientation to Landscape
            //doc.setPageSize(PageSize.A4);
            doc.setMargins(5f, 5f, 3f, 3f);

            //open document
            doc.open();

            //Creating a paragraphs and chunks
            pp = new Paragraph("Cocoa Health And Extension Division", forTitle);
            pp.setAlignment(Element.ALIGN_CENTER);

            palaglapgh = new Paragraph("(Cocobod)", bfBold12);
            palaglapgh.setAlignment(Element.ALIGN_CENTER);

            signParagraph = new Paragraph("Sign: ..............", bfBold12);
            signParagraph.setAlignment(Element.ALIGN_LEFT);

            dateParagrapgh = new Paragraph("Date: ...........", bfBold12);

            chk = new Chunk("Component 1 Rehabilitation Tree Removal Cost From GIS Office, Accra", bfBold12);
            chk.setUnderline(.1f, -2f); // 0.1 thickness and -2 position
            underText = new Paragraph(chk);
            underText.setAlignment(Element.ALIGN_CENTER);

            chuk1 = new Chunk("RP Lot No:", bfBold12);
            chuk1.setUnderline(.1f, -2f);
            chuk2 = new Chunk(repNum, bfBold12);

            regionText = new Paragraph(repLot, forTitle2);
            regionText.setAlignment(Element.ALIGN_CENTER);
            x = "";
            dir = manager.PDFRehab(repNum);//SHOULD BE CHANGED!!!!
            try {
                if (dir.next()) {
                    x = dir.getString(21);

                }
            } catch (SQLException ex) {
                Logger.getLogger(PDFDemo.class.getName()).log(Level.SEVERE, null, ex);
            }

            regionTexts = new Paragraph(x, forTitle2);
            regionText.setAlignment(Element.ALIGN_CENTER);
            //add the PDF table to the paragraph
            //palaglapgh.add(table);
            //Table Generation block
            regionText.add(reports(repNum));

            //SECTION TO ADD ELEMENTS TO PDF
            // add the paragraph to the document
            doc.add(pp);
            //doc.add(Chunk.NEWLINE);       //Adds a new blank line
            doc.add(palaglapgh);
            doc.add(underText);

            doc.add(chuk1);
            doc.add(chuk2);

            //Current Date and time insertion
            newDate = new Paragraph(date, bf12);
            newDate.setAlignment(Element.ALIGN_RIGHT);
            doc.add(newDate);
            doc.add(regionTexts);
            doc.add(regionText);

            doc.add(Chunk.NEWLINE); //Adds a new blank line
            doc.add(Chunk.NEWLINE);

            doc.add(signParagraph);
            doc.add(dateParagrapgh);

            //close the document
            doc.close();

            //close the writer
            docwriter.close();

            out.close();

            //Copied CODES
            break;

        }

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

}

From source file:Utility.PDFDemo.java

public void cretePDF(String name, String rpor) throws FileNotFoundException {

    try {//from w  w  w .j a  v a  2  s .  c  om

        //Create document for pdf
        Document doc = new Document();

        //PDF writer to write into document
        PdfWriter docwriter = null;

        DecimalFormat df = new DecimalFormat("0.00");

        try {
            // //file path
            //String path = "docs/" + name;
            docwriter = PdfWriter.getInstance(doc, new FileOutputStream(rpor + ".pdf"));
        } catch (DocumentException ex) {
            Logger.getLogger(PDFDemo.class.getName()).log(Level.SEVERE, null, ex);
        }

        //document header attributes
        doc.addAuthor("CHED CU");
        doc.addCreationDate();
        doc.addProducer();
        doc.addCreator("Grant Monitor");
        doc.addTitle(rpor);
        doc.setPageSize(PageSize.A4.rotate()); //This sets page size to A4 and orientation to Landscape
        //doc.setPageSize(PageSize.A4);
        doc.setMargins(30f, 30f, 20f, 20f);

        //open document
        doc.open();

        //Creating a paragraphs and chunks
        Paragraph pp = new Paragraph("Cocoa Health And Extension", forTitle);
        pp.setAlignment(Element.ALIGN_CENTER);

        Paragraph palaglapgh = new Paragraph("(Cocobod)", bfBold12);
        palaglapgh.setAlignment(Element.ALIGN_CENTER);

        Chunk chk = new Chunk("From GIS Office, Accra", bfBold12);
        chk.setUnderline(.1f, -2f); // 0.1 thickness and -2 position
        Paragraph underText = new Paragraph(chk);
        underText.setAlignment(Element.ALIGN_CENTER);

        Chunk chuk1 = new Chunk("Lot No:", bfBold12);
        chuk1.setUnderline(.1f, -2f);
        Chunk chuk2 = new Chunk(name, bfBold12);

        Paragraph regionText = new Paragraph(rpor, bfBold12);
        regionText.setAlignment(Element.ALIGN_CENTER);
        String rporx = "";
        //            ResultSet dir = manager.PDFdemos(name);
        //            try {
        //                if (dir.next()) {
        //                    rporx = dir.getString(12);
        //
        //                }
        //            } catch (SQLException ex) {
        //                Logger.getLogger(PDFDemo.class.getName()).log(Level.SEVERE, null, ex);
        //            }

        Paragraph regionTexts = new Paragraph(rporx, bfBold12);
        regionText.setAlignment(Element.ALIGN_CENTER);
        //add the PDF table to the paragraph
        //palaglapgh.add(table);
        //Table Generation block
        regionText.add(reports());

        //SECTION TO ADD ELEMENTS TO PDF
        // add the paragraph to the document
        doc.add(pp);
        //doc.add(Chunk.NEWLINE);       //Adds a new blank line
        doc.add(palaglapgh);
        doc.add(underText);

        doc.add(chuk1);
        doc.add(chuk2);

        //Current Date and time insertion
        Paragraph newDate = new Paragraph(new Date().toString(), bf12);
        newDate.setAlignment(Element.ALIGN_RIGHT);
        doc.add(newDate);
        doc.add(regionTexts);
        doc.add(regionText);

        //close the document
        doc.close();

        //close the writer
        docwriter.close();

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

}

From source file:zeugnis.ZeugnisPDF.java

/**
* Erzeugt das Zeugnis PDF in einem definierten Ordner
* @throws IOException//www .  ja v  a2  s .c o  m
* @throws DocumentException
* @throws SQLException 
*/
public void CreatePDF() throws IOException, DocumentException, SQLException {
    float pad = 6.0f;

    // Einige Strings fr die Ausgabe...
    String Schuljahr = "Schuljahr " + Integer.toString(schuljahr) + "/" + Integer.toString(schuljahr + 1);
    String Halbjahr;
    if (halbjahr == 1) {
        Halbjahr = "1. Halbjahr";
    } else {
        Halbjahr = "1. und 2. Halbjahr";
    }
    String Klasse = "Klasse " + klasse;

    String Tage = "Versumte Unterrichtstage im " + Halbjahr + ": " + String.valueOf(fehltage)
            + " davon unentschuldigt: " + String.valueOf(fehltageohne);
    String Unterschriften1 = "________________________________________\n\n Klassenlehrerin / Klassenlehrer";
    String Unterschriften2 = "________________________________________\n\n Schulleiterin / Schulleiter";
    String Unterschriften3 = "________________________________________\n\n Unterschrift einer/eines Erziehungsberechtigten";
    String DatumLine = "________________________________________\n\n Ausstellungsort und Datum";

    //    String Datum = "Datum: " + currDate;
    String Datum = currDate;

    String AundS = "Arbeits- und Sozialverhalten";
    String ATitle = "Arbeitsverhalten\n\n" + vorname + "...";
    String STitle = "Sozialverhalten\n\n" + vorname + "...";
    String Selten = "selten";
    String Wechselnd = "wechselnd";
    String Ueberwiegend = "berwiegend";

    String Erklaerungen = "Erklrungen";
    String BewertungsstufenAS = "Bewertungsstufen fr das Arbeits- und Sozialverhalten:";
    String Symbole = "Symbolerluterungen fr die Unterrichtsfcher:";

    String Sym0 = "Das Thema wurde noch nicht bearbeitet";
    String Sym1 = "Die Kompetenz ist in Anstzen vorhanden";
    String Sym2 = "Die Kompetenz ist grundlegend gesichert";
    String Sym3 = "Die Kompetenz ist weitgehend gesichert";
    String Sym4 = "Die Kompetenz ist gesichert";

    String deutschS = "Deutsch ";
    String matheS = "Mathematik ";
    String sachunterrichtS = "Sachunterricht ";
    String musikS = "Musik ";
    String religionS = "Religion ";
    String kunstS = "Kunst ";
    String sportS = "Sport ";
    String textilS = "Textiles Gestalten ";
    String werkenS = "Werken ";
    String englischS = "Englisch ";

    //        String jStufe   = "Jahrgangsstufe "+ Gui.getSClass().substring(0, 1);
    String jStufe = "";
    String sz = "Sprechen und Zuhren\n\n" + vorname + "...";
    String sch = "Schreiben\n\n" + vorname + "...";
    String les = "Lesen - mit Texten und Medien umgehen\n\n" + vorname + "...";
    String sp = "Sprache und Sprachgebrauch untersuchen\n\n" + vorname + "...";
    String zo = "Zahlen und Operationen\n\n" + vorname + "...";
    String gm = "Gren und Messen\n\n" + vorname + "...";
    String rf = "Raum und Form\n\n" + vorname + "...";
    String su = vorname + "...";

    // Ausgabedokument erzeugen
    Document doc = new Document(PageSize.A4, 50, 50, 20, 30);
    PdfWriter writer = PdfWriter.getInstance(doc, new FileOutputStream(file));

    // Fr header und footer
    TableHeader event = new TableHeader();
    event.setHeader("");
    writer.setPageEvent(event);

    doc.open();
    // Logo
    //        URL url = this.getClass().getResource("pics/GSBrelingen.jpg");
    URL url = this.getClass().getResource("pics/GSKopfLogo300.png");
    Image img = Image.getInstance(url);
    double moremargin = doc.getPageSize().getWidth() * 0.0;
    float scaler = ((doc.getPageSize().getWidth() - doc.leftMargin() - doc.rightMargin() - (float) moremargin)
            / img.getWidth()) * 100;
    img.scalePercent(scaler * 0.7f);

    // Seite 1 *************************************************************
    // Tablestruktur aufbauen...
    PdfPTable table1 = new PdfPTable(new float[] { 36, 28, 36 });
    table1.setWidthPercentage(100);

    PdfPCell cell1Logo;
    cell1Logo = new PdfPCell(img);
    cell1Logo.setColspan(3);
    cell1Logo.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell1Logo.setBorder(Rectangle.NO_BORDER);

    // Adresse
    PdfPCell cell1Adresse;
    cell1Adresse = new PdfPCell(new Phrase(
            "Grundschule Brelingen  Schulstrae 10  30900 Wedemark  GS.Brelingen@Wedemark.de",
            SMALL_FONT));
    cell1Adresse.setColspan(3);
    cell1Adresse.setFixedHeight(30f);
    cell1Adresse.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell1Adresse.setBorder(Rectangle.NO_BORDER);

    //Zeugnis
    PdfPCell cell1Zeugnis;
    cell1Zeugnis = new PdfPCell(new Phrase("Zeugnis", BIG_FONT));
    cell1Zeugnis.setColspan(3);
    cell1Zeugnis.setFixedHeight(40f);
    cell1Zeugnis.setVerticalAlignment(Element.ALIGN_BOTTOM);
    cell1Zeugnis.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell1Zeugnis.setBorder(Rectangle.NO_BORDER);

    //Schuljahr
    PdfPCell cell1Schuljahr;
    cell1Schuljahr = new PdfPCell(new Phrase(Schuljahr, BIGGER_FONT));
    cell1Schuljahr.setFixedHeight(30f);
    cell1Schuljahr.setVerticalAlignment(Element.ALIGN_BOTTOM);
    cell1Schuljahr.setHorizontalAlignment(Element.ALIGN_LEFT);
    cell1Schuljahr.setBorder(Rectangle.NO_BORDER);

    //Halbjahr
    PdfPCell cell1Halbjahr;
    cell1Halbjahr = new PdfPCell(new Phrase(Halbjahr, BIGGER_FONT));
    cell1Halbjahr.setFixedHeight(30f);
    cell1Halbjahr.setVerticalAlignment(Element.ALIGN_BOTTOM);
    cell1Halbjahr.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell1Halbjahr.setBorder(Rectangle.NO_BORDER);

    //Klasse
    PdfPCell cell1Klasse;
    cell1Klasse = new PdfPCell(new Phrase(Klasse, BIGGER_FONT));
    cell1Klasse.setFixedHeight(30f);
    cell1Klasse.setVerticalAlignment(Element.ALIGN_BOTTOM);
    cell1Klasse.setHorizontalAlignment(Element.ALIGN_RIGHT);
    cell1Klasse.setBorder(Rectangle.NO_BORDER);

    //Name
    PdfPCell cell1Name;
    cell1Name = new PdfPCell(new Phrase(vorname + " " + name, NAME_FONT));
    cell1Name.setColspan(3);
    cell1Name.setFixedHeight(40f);
    cell1Name.setVerticalAlignment(Element.ALIGN_BOTTOM);
    cell1Name.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell1Name.setBorder(Rectangle.NO_BORDER);

    //Geboren
    PdfPCell cell1Geboren;
    cell1Geboren = new PdfPCell(new Phrase("geboren am " + gebdatum + " in " + gebort, NORMAL_FONT));
    cell1Geboren.setColspan(3);
    cell1Geboren.setFixedHeight(20f);
    cell1Geboren.setVerticalAlignment(Element.ALIGN_TOP);
    cell1Geboren.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell1Geboren.setBorder(Rectangle.NO_BORDER);

    //Tage
    PdfPCell cell1Tage;
    cell1Tage = new PdfPCell(new Phrase(Tage, SMALL_FONT));
    cell1Tage.setColspan(3);
    cell1Tage.setFixedHeight(50f);
    cell1Tage.setVerticalAlignment(Element.ALIGN_TOP);
    cell1Tage.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell1Tage.setBorder(Rectangle.NO_BORDER);

    //Lernentwicklung
    Paragraph lern = new Paragraph();
    Paragraph bem = new Paragraph();
    PdfPTable table = new PdfPTable(1);
    Phrase lernTitle = new Phrase(lernentwicklungTitle, SMALLBOLDITALIC2_FONT);
    Phrase bemTitle = new Phrase(bemerkungenTitle, SMALLBOLDITALIC2_FONT);
    Phrase lernText = new Phrase(lernentwicklung, SMALL2_FONT);
    Phrase bemText = new Phrase(bemerkungen, SMALL2_FONT);
    if (lernentwicklung.isEmpty()) {
        ;
    } else {
        lern.add(lernTitle);
    }
    if (bemerkungen.isEmpty()) {
        ;
    } else {
        bem.add(bemTitle);
    }
    lern.add(lernText);
    bem.add(bemText);
    PdfPCell le = new PdfPCell(lern);
    PdfPCell be = new PdfPCell(bem);

    le.setVerticalAlignment(Element.ALIGN_TOP);
    be.setVerticalAlignment(Element.ALIGN_BOTTOM);
    le.setBorder(Rectangle.NO_BORDER);
    be.setBorder(Rectangle.NO_BORDER);
    table.addCell(le);
    table.addCell(be);
    PdfPCell cell1Lernentwicklung;
    cell1Lernentwicklung = new PdfPCell(table);
    cell1Lernentwicklung.setColspan(3);
    cell1Lernentwicklung.setHorizontalAlignment(Element.ALIGN_LEFT);
    cell1Lernentwicklung.setFixedHeight(350f);
    cell1Lernentwicklung.setPadding(pad);
    //        cell1Lernentwicklung.setBorder(Rectangle.NO_BORDER);

    // Unterschriften
    PdfPCell cell1Unterschriften1;
    cell1Unterschriften1 = new PdfPCell(new Phrase(Unterschriften1, MICRO_FONT));
    //cell1Unterschriften.setColspan(3);
    cell1Unterschriften1.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell1Unterschriften1.setVerticalAlignment(Element.ALIGN_BOTTOM);
    cell1Unterschriften1.setFixedHeight(70f);
    cell1Unterschriften1.setBorder(Rectangle.NO_BORDER);

    PdfPCell cell1Empty;
    cell1Empty = new PdfPCell(new Phrase("", SMALL_FONT));
    //cell1Unterschriften.setColspan(3);
    cell1Empty.setFixedHeight(70f);
    cell1Empty.setBorder(Rectangle.NO_BORDER);

    PdfPCell cell1Unterschriften2;
    cell1Unterschriften2 = new PdfPCell(new Phrase(Unterschriften2, MICRO_FONT));
    //cell1Unterschriften2.setColspan(2);
    cell1Unterschriften2.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell1Unterschriften2.setVerticalAlignment(Element.ALIGN_BOTTOM);
    cell1Unterschriften2.setFixedHeight(70f);
    cell1Unterschriften2.setBorder(Rectangle.NO_BORDER);

    PdfPCell cell1Datum;
    if (Gui.isOverwriteDateSelected()) {
        if (Gui.getOverwriteDate().isEmpty()) {
            Datum = "     ......................";
        } else {
            Datum = Gui.getOverwriteDate();
        }
    }
    Phrase p1 = new Phrase("Brelingen, den " + Datum + "\n", SMALL_FONT);
    Phrase p2 = new Phrase(DatumLine, MICRO_FONT);
    Paragraph par1 = new Paragraph(p1);
    par1.add(p2);
    cell1Datum = new PdfPCell(par1);
    //cell1Datum.addElement(p1);
    //cell1Datum.addElement(p2);
    //cell1Unterschriften.setColspan(3);
    cell1Datum.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell1Datum.setVerticalAlignment(Element.ALIGN_BOTTOM);
    cell1Datum.setFixedHeight(60f);
    cell1Datum.setBorder(Rectangle.NO_BORDER);

    PdfPCell cell1Gesehen;
    cell1Gesehen = new PdfPCell(new Phrase("", NORMAL_FONT));
    cell1Gesehen.setHorizontalAlignment(Element.ALIGN_RIGHT);
    cell1Gesehen.setVerticalAlignment(Element.ALIGN_CENTER);
    //cell1Unterschriften.setColspan(3);
    cell1Gesehen.setFixedHeight(60f);
    cell1Gesehen.setBorder(Rectangle.NO_BORDER);

    PdfPCell cell1Unterschriften3;
    Phrase p3 = new Phrase("gesehen:                                             \u00a0\n", TINY_FONT);
    Phrase p4 = new Phrase(Unterschriften3, MICRO_FONT);
    Paragraph par2 = new Paragraph(p3);
    par2.add(p4);
    cell1Unterschriften3 = new PdfPCell(par2);
    //cell1Unterschriften3.setColspan(2);
    cell1Unterschriften3.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell1Unterschriften3.setVerticalAlignment(Element.ALIGN_BOTTOM);
    cell1Unterschriften3.setFixedHeight(60f);
    cell1Unterschriften3.setBorder(Rectangle.NO_BORDER);

    table1.addCell(cell1Logo);
    table1.addCell(cell1Adresse);
    table1.addCell(cell1Zeugnis);
    table1.addCell(cell1Schuljahr);
    table1.addCell(cell1Halbjahr);
    table1.addCell(cell1Klasse);
    table1.addCell(cell1Name);
    table1.addCell(cell1Geboren);
    table1.addCell(cell1Tage);
    table1.addCell(cell1Lernentwicklung);
    table1.addCell(cell1Unterschriften1);
    table1.addCell(cell1Empty);
    table1.addCell(cell1Unterschriften2);
    table1.addCell(cell1Datum);
    table1.addCell(cell1Gesehen);
    table1.addCell(cell1Unterschriften3);

    doc.add(table1);

    doc.newPage();

    // Seite 2 *************************************************************
    String head = vorname + " " + name + ", geboren am " + gebdatum;
    event.setHeader(head);
    // Tablestruktur aufbauen...
    pad = 3.0f;
    PdfPTable table2 = new PdfPTable(4);
    table2.setWidths(new float[] { 58, 14, 14, 14 });
    table2.setWidthPercentage(100);

    PdfPCell cell2Header = emptyLine(4, 10f);
    PdfPCell cell2AundS = new PdfPCell(title1(AundS, 4, 35f));
    PdfPCell cell2ATitle = new PdfPCell(title2(ATitle, 1, 50f, pad));

    PdfPCell cell2Selten = new PdfPCell(seweue(Selten, pad));
    PdfPCell cell2Wechselnd = new PdfPCell(seweue(Wechselnd, pad));
    PdfPCell cell2Ueberwiegend = new PdfPCell(seweue(Ueberwiegend, pad));

    table2.addCell(cell2Header);
    table2.addCell(cell2AundS);
    table2.addCell(cell2ATitle);
    table2.addCell(cell2Selten);
    table2.addCell(cell2Wechselnd);
    table2.addCell(cell2Ueberwiegend);

    table2 = asVerhalten(table2, aVerhalten, pad);

    PdfPCell cell2KommentarA;
    cell2KommentarA = new PdfPCell(new Paragraph(textArbeit, TINYITALIC_FONT));
    cell2KommentarA.setColspan(4);
    cell2KommentarA.setBorder(Rectangle.LEFT | Rectangle.RIGHT);
    cell2KommentarA.setPadding(pad);
    cell2KommentarA.setHorizontalAlignment(Element.ALIGN_LEFT);
    table2.addCell(cell2KommentarA);

    PdfPCell cell2BewertungA;
    if (vorname.endsWith("s") || vorname.endsWith("x") || vorname.endsWith("z")) {
        cell2BewertungA = new PdfPCell(
                new Phrase(vorname + "' Arbeitsverhalten " + noteArbeitString, NORMAL_FONT));
    } else {
        cell2BewertungA = new PdfPCell(
                new Phrase(vorname + "s Arbeitsverhalten " + noteArbeitString, NORMAL_FONT));
    }
    cell2BewertungA.setColspan(4);
    cell2BewertungA.setVerticalAlignment(Element.ALIGN_MIDDLE);
    //cell2BewertungA.setFixedHeight(45f);
    cell2BewertungA.setPadding(pad);
    cell2BewertungA.setHorizontalAlignment(Element.ALIGN_LEFT);
    cell2BewertungA.setBorder(Rectangle.LEFT | Rectangle.BOTTOM | Rectangle.RIGHT);
    table2.addCell(cell2BewertungA);

    table2.addCell(emptyLine(4, 15f));

    PdfPCell cell2STitle = new PdfPCell(title2(STitle, 1, 50f, pad));

    table2.addCell(cell2STitle);
    table2.addCell(cell2Selten);
    table2.addCell(cell2Wechselnd);
    table2.addCell(cell2Ueberwiegend);

    table2 = asVerhalten(table2, sVerhalten, pad);

    PdfPCell cell2KommentarS;
    cell2KommentarS = new PdfPCell(new Paragraph(textSozial, TINYITALIC_FONT));
    cell2KommentarS.setColspan(4);
    cell2KommentarS.setBorder(Rectangle.LEFT | Rectangle.RIGHT);
    cell2KommentarS.setPadding(pad);
    cell2KommentarS.setHorizontalAlignment(Element.ALIGN_LEFT);
    table2.addCell(cell2KommentarS);

    PdfPCell cell2BewertungS;
    if (vorname.endsWith("s") || vorname.endsWith("x") || vorname.endsWith("z")) {
        cell2BewertungS = new PdfPCell(
                new Phrase(vorname + "' Sozialverhalten " + noteSozialString, NORMAL_FONT));
    } else {
        cell2BewertungS = new PdfPCell(
                new Phrase(vorname + "s Sozialverhalten " + noteSozialString, NORMAL_FONT));
    }
    cell2BewertungS.setColspan(4);
    cell2BewertungS.setVerticalAlignment(Element.ALIGN_MIDDLE);
    //cell2BewertungA.setFixedHeight(45f);
    cell2BewertungS.setPadding(pad);
    cell2BewertungS.setHorizontalAlignment(Element.ALIGN_LEFT);
    cell2BewertungS.setBorder(Rectangle.LEFT | Rectangle.BOTTOM | Rectangle.RIGHT);
    table2.addCell(cell2BewertungS);

    table2.addCell(emptyLine(4, 15f));

    // Tablestruktur aufbauen...
    // Legende...
    PdfPTable table2a = new PdfPTable(4);
    table2a.setWidths(new float[] { 3, 50, 8, 44 });
    table2a.setWidthPercentage(100);

    PdfPCell cell2Erklaerungen;
    Chunk chunk1 = new Chunk(Erklaerungen, NORMAL_FONT);
    chunk1.setUnderline(1.5f, -1);
    cell2Erklaerungen = new PdfPCell((new Phrase(chunk1)));
    cell2Erklaerungen.setColspan(4);
    cell2Erklaerungen.setFixedHeight(20f);
    cell2Erklaerungen.setVerticalAlignment(Element.ALIGN_TOP);
    cell2Erklaerungen.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell2Erklaerungen.setBorder(Rectangle.NO_BORDER);
    table2a.addCell(cell2Erklaerungen);

    PdfPCell cell2BewertungsstufenAS;
    cell2BewertungsstufenAS = new PdfPCell(new Phrase(BewertungsstufenAS, SMALL_BOLD_FONT));
    cell2BewertungsstufenAS.setColspan(2);
    cell2BewertungsstufenAS.setVerticalAlignment(Element.ALIGN_TOP);
    cell2BewertungsstufenAS.setHorizontalAlignment(Element.ALIGN_LEFT);
    cell2BewertungsstufenAS.setBorder(Rectangle.NO_BORDER);
    table2a.addCell(cell2BewertungsstufenAS);

    PdfPCell cell2Symbole;
    cell2Symbole = new PdfPCell(new Phrase(Symbole, SMALL_BOLD_FONT));
    cell2Symbole.setColspan(2);
    cell2Symbole.setVerticalAlignment(Element.ALIGN_TOP);
    cell2Symbole.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell2Symbole.setBorder(Rectangle.NO_BORDER);
    table2a.addCell(cell2Symbole);

    float height = 20.0f;
    PdfPCell cell2Bewertungsstufen1;
    PdfPCell cell2Item;

    cell2Item = new PdfPCell(new Phrase(""));
    cell2Bewertungsstufen1 = new PdfPCell(new Phrase("\"" + asBewertungen[0] + "\"", SMALL_FONT));
    //cell2Bewertungsstufen1.setColspan(2);
    cell2Bewertungsstufen1.setMinimumHeight(height);
    cell2Bewertungsstufen1.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell2Bewertungsstufen1.setHorizontalAlignment(Element.ALIGN_LEFT);
    cell2Bewertungsstufen1.setBorder(Rectangle.NO_BORDER);
    cell2Item.setBorder(Rectangle.NO_BORDER);
    table2a.addCell(cell2Item);
    table2a.addCell(cell2Bewertungsstufen1);

    //        PdfPCell cell2Sym0img;
    //        cell2Sym0img = new PdfPCell(new Phrase("--",SMALL_FONT));
    //        //cell2Bewertungsstufen1.setColspan(1);
    //        cell2Sym0img.setVerticalAlignment(Element.ALIGN_MIDDLE);
    //        cell2Sym0img.setHorizontalAlignment(Element.ALIGN_RIGHT);
    //        cell2Sym0img.setBorder(Rectangle.NO_BORDER);
    //        table2a.addCell(cell2Sym0img);

    table2a.addCell(kreisViertel(0, pad, Element.ALIGN_RIGHT, Element.ALIGN_TOP, Rectangle.NO_BORDER));

    PdfPCell cell2Sym0;
    cell2Sym0 = new PdfPCell(new Phrase(Sym0, SMALL_FONT));
    //cell2Bewertungsstufen1.setColspan(1);
    cell2Sym0.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell2Sym0.setHorizontalAlignment(Element.ALIGN_LEFT);
    cell2Sym0.setBorder(Rectangle.NO_BORDER);
    table2a.addCell(cell2Sym0);

    PdfPCell cell2Bewertungsstufen2;
    cell2Bewertungsstufen2 = new PdfPCell(new Phrase("\"" + asBewertungen[1] + "\"", SMALL_FONT));
    //cell2Bewertungsstufen2.setColspan(2);
    cell2Bewertungsstufen2.setMinimumHeight(height);
    cell2Bewertungsstufen2.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell2Bewertungsstufen2.setHorizontalAlignment(Element.ALIGN_LEFT);
    cell2Bewertungsstufen2.setBorder(Rectangle.NO_BORDER);
    cell2Item.setBorder(Rectangle.NO_BORDER);
    table2a.addCell(cell2Item);
    table2a.addCell(cell2Bewertungsstufen2);

    table2a.addCell(kreisViertel(1, pad, Element.ALIGN_RIGHT, Element.ALIGN_TOP, Rectangle.NO_BORDER));

    PdfPCell cell2Sym1;
    cell2Sym1 = new PdfPCell(new Phrase(Sym1, SMALL_FONT));
    //cell2Bewertungsstufen1.setColspan(1);
    cell2Sym1.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell2Sym1.setHorizontalAlignment(Element.ALIGN_LEFT);
    cell2Sym1.setBorder(Rectangle.NO_BORDER);
    table2a.addCell(cell2Sym1);

    PdfPCell cell2Bewertungsstufen3;
    cell2Bewertungsstufen3 = new PdfPCell(new Phrase("\"" + asBewertungen[2] + "\"", SMALL_FONT));
    //cell2Bewertungsstufen3.setColspan(2);
    cell2Bewertungsstufen3.setMinimumHeight(height);
    cell2Bewertungsstufen3.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell2Bewertungsstufen3.setHorizontalAlignment(Element.ALIGN_LEFT);
    cell2Bewertungsstufen3.setBorder(Rectangle.NO_BORDER);
    table2a.addCell(cell2Item);
    table2a.addCell(cell2Bewertungsstufen3);

    table2a.addCell(kreisViertel(2, pad, Element.ALIGN_RIGHT, Element.ALIGN_TOP, Rectangle.NO_BORDER));

    PdfPCell cell2Sym2;
    cell2Sym2 = new PdfPCell(new Phrase(Sym2, SMALL_FONT));
    //cell2Bewertungsstufen1.setColspan(1);
    cell2Sym2.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell2Sym2.setHorizontalAlignment(Element.ALIGN_LEFT);
    cell2Sym2.setBorder(Rectangle.NO_BORDER);
    table2a.addCell(cell2Sym2);

    PdfPCell cell2Bewertungsstufen4;
    cell2Bewertungsstufen4 = new PdfPCell(new Phrase("\"" + asBewertungen[3] + "\"", SMALL_FONT));
    //cell2Bewertungsstufen4.setColspan(2);
    cell2Bewertungsstufen4.setMinimumHeight(height);
    cell2Bewertungsstufen4.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell2Bewertungsstufen4.setHorizontalAlignment(Element.ALIGN_LEFT);
    cell2Bewertungsstufen4.setBorder(Rectangle.NO_BORDER);
    table2a.addCell(cell2Item);
    table2a.addCell(cell2Bewertungsstufen4);

    table2a.addCell(kreisViertel(3, pad, Element.ALIGN_RIGHT, Element.ALIGN_TOP, Rectangle.NO_BORDER));

    PdfPCell cell2Sym3;
    cell2Sym3 = new PdfPCell(new Phrase(Sym3, SMALL_FONT));
    //cell2Bewertungsstufen1.setColspan(1);
    cell2Sym3.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell2Sym3.setHorizontalAlignment(Element.ALIGN_LEFT);
    cell2Sym3.setBorder(Rectangle.NO_BORDER);
    table2a.addCell(cell2Sym3);

    PdfPCell cell2Bewertungsstufen5;
    cell2Bewertungsstufen5 = new PdfPCell(new Phrase("\"" + asBewertungen[4] + "\"", SMALL_FONT));
    //cell2Bewertungsstufen5.setColspan(2);
    cell2Bewertungsstufen5.setMinimumHeight(height);
    cell2Bewertungsstufen5.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell2Bewertungsstufen5.setHorizontalAlignment(Element.ALIGN_LEFT);
    cell2Bewertungsstufen5.setBorder(Rectangle.NO_BORDER);
    table2a.addCell(cell2Item);
    table2a.addCell(cell2Bewertungsstufen5);

    table2a.addCell(kreisViertel(4, pad, Element.ALIGN_RIGHT, Element.ALIGN_TOP, Rectangle.NO_BORDER));

    PdfPCell cell2Sym4;
    cell2Sym4 = new PdfPCell(new Phrase(Sym4, SMALL_FONT));
    //cell2Bewertungsstufen1.setColspan(1);
    cell2Sym4.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell2Sym4.setHorizontalAlignment(Element.ALIGN_LEFT);
    cell2Sym4.setBorder(Rectangle.NO_BORDER);
    table2a.addCell(cell2Sym4);

    doc.add(table2);
    doc.add(table2a);

    doc.newPage();

    // Seite 3 *************************************************************
    // Tablestruktur aufbauen...
    pad = 3f;
    PdfPTable table3 = new PdfPTable(6);
    table3.setWidths(new float[] { 60, 8, 8, 8, 8, 8 });
    table3.setWidthPercentage(100);

    PdfPCell cell3Header = emptyLine(6, 10f);
    PdfPCell cell3Deutsch;
    cell3Deutsch = new PdfPCell(new Phrase(deutschS + jStufe, NORMAL_BOLD_FONT));
    cell3Deutsch.setColspan(6);
    cell3Deutsch.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell3Deutsch.setFixedHeight(35f);
    cell3Deutsch.setHorizontalAlignment(Element.ALIGN_LEFT);
    cell3Deutsch.setBorder(Rectangle.NO_BORDER);

    // Sprechen und Zuhren 
    PdfPCell cell3sz;
    cell3sz = new PdfPCell(new Phrase(sz, NORMAL_FONT));
    //cell2ATitle.setColspan(4);
    cell3sz.setVerticalAlignment(Element.ALIGN_TOP);
    cell3sz.setFixedHeight(50f);
    cell3sz.setPadding(pad);
    cell3sz.setHorizontalAlignment(Element.ALIGN_LEFT);
    //cell2ATitle.setBorder(Rectangle.NO_BORDER);

    PdfPCell cell3Leer;
    //        cell3Leer = new PdfPCell(new Phrase("--",TINY_FONT));
    cell3Leer = new PdfPCell(kreisViertel(0, pad, Element.ALIGN_RIGHT, Element.ALIGN_TOP, Rectangle.BOX));
    //cell2ATitle.setColspan(4);
    cell3Leer.setVerticalAlignment(Element.ALIGN_MIDDLE);
    //cell2ATitle.setFixedHeight(30f);
    cell3Leer.setPadding(pad);
    cell3Leer.setHorizontalAlignment(Element.ALIGN_CENTER);
    //cell2ATitle.setBorder(Rectangle.NO_BORDER);

    table3.addCell(cell3Header);
    table3.addCell(cell3Deutsch);
    table3.addCell(cell3sz);
    table3.addCell(cell3Leer);
    table3.addCell(kreisViertel(1, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
    table3.addCell(kreisViertel(2, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
    table3.addCell(kreisViertel(3, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
    table3.addCell(kreisViertel(4, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));

    table3 = lernbereiche(table3, sprechenZL, pad);

    // Schreiben 
    PdfPCell cell3EmptyLine;
    cell3EmptyLine = new PdfPCell(new Phrase("", NORMAL_BOLD_FONT));
    cell3EmptyLine.setColspan(6);
    cell3EmptyLine.setFixedHeight(15f);
    cell3EmptyLine.setBorder(Rectangle.NO_BORDER);

    cell3sz = new PdfPCell(new Phrase(sch, NORMAL_FONT));
    cell3sz.setVerticalAlignment(Element.ALIGN_TOP);
    cell3sz.setFixedHeight(50f);
    cell3sz.setPadding(pad);
    cell3sz.setHorizontalAlignment(Element.ALIGN_LEFT);

    //        cell3Leer = new PdfPCell(new Phrase("--",TINY_FONT));
    cell3Leer = new PdfPCell(kreisViertel(0, pad, Element.ALIGN_RIGHT, Element.ALIGN_TOP, Rectangle.BOX));
    cell3Leer.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell3Leer.setPadding(pad);
    cell3Leer.setHorizontalAlignment(Element.ALIGN_CENTER);

    table3.addCell(cell3EmptyLine);
    table3.addCell(cell3sz);
    table3.addCell(cell3Leer);
    table3.addCell(kreisViertel(1, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
    table3.addCell(kreisViertel(2, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
    table3.addCell(kreisViertel(3, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
    table3.addCell(kreisViertel(4, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));

    table3 = lernbereiche(table3, schreibenZL, pad);

    // Lesen - mit Texten und Medien umgehen
    cell3EmptyLine = new PdfPCell(new Phrase("", NORMAL_BOLD_FONT));
    cell3EmptyLine.setColspan(6);
    cell3EmptyLine.setFixedHeight(15f);
    cell3EmptyLine.setBorder(Rectangle.NO_BORDER);

    cell3sz = new PdfPCell(new Phrase(les, NORMAL_FONT));
    cell3sz.setVerticalAlignment(Element.ALIGN_TOP);
    cell3sz.setFixedHeight(50f);
    cell3sz.setPadding(pad);
    cell3sz.setHorizontalAlignment(Element.ALIGN_LEFT);

    //        cell3Leer = new PdfPCell(new Phrase("--",TINY_FONT));
    cell3Leer = new PdfPCell(kreisViertel(0, pad, Element.ALIGN_RIGHT, Element.ALIGN_TOP, Rectangle.BOX));
    cell3Leer.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell3Leer.setPadding(pad);
    cell3Leer.setHorizontalAlignment(Element.ALIGN_CENTER);

    table3.addCell(cell3EmptyLine);
    table3.addCell(cell3sz);
    table3.addCell(cell3Leer);
    table3.addCell(kreisViertel(1, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
    table3.addCell(kreisViertel(2, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
    table3.addCell(kreisViertel(3, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
    table3.addCell(kreisViertel(4, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));

    table3 = lernbereiche(table3, lesenZL, pad);

    // Sprache und Sprachgebrauch untersuchen
    cell3EmptyLine = new PdfPCell(new Phrase("", NORMAL_BOLD_FONT));
    cell3EmptyLine.setColspan(6);
    cell3EmptyLine.setFixedHeight(15f);
    cell3EmptyLine.setBorder(Rectangle.NO_BORDER);

    cell3sz = new PdfPCell(new Phrase(sp, NORMAL_FONT));
    cell3sz.setVerticalAlignment(Element.ALIGN_TOP);
    cell3sz.setFixedHeight(50f);
    cell3sz.setPadding(pad);
    cell3sz.setHorizontalAlignment(Element.ALIGN_LEFT);

    //        cell3Leer = new PdfPCell(new Phrase("--",TINY_FONT));
    cell3Leer = new PdfPCell(kreisViertel(0, pad, Element.ALIGN_RIGHT, Element.ALIGN_TOP, Rectangle.BOX));
    cell3Leer.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell3Leer.setPadding(pad);
    cell3Leer.setHorizontalAlignment(Element.ALIGN_CENTER);

    table3.addCell(cell3EmptyLine);
    table3.addCell(cell3sz);
    table3.addCell(cell3Leer);
    table3.addCell(kreisViertel(1, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
    table3.addCell(kreisViertel(2, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
    table3.addCell(kreisViertel(3, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
    table3.addCell(kreisViertel(4, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));

    table3 = lernbereiche(table3, sprachZL, pad);

    doc.add(table3);
    doc.newPage();

    // Seite 4 *************************************************************
    // Tablestruktur aufbauen...
    pad = 3f;
    PdfPTable table4 = new PdfPTable(6);
    table4.setWidths(new float[] { 60, 8, 8, 8, 8, 8 });
    table4.setWidthPercentage(100);

    PdfPCell cell4Header = emptyLine(6, 10f);

    PdfPCell cell4Mathe;
    cell4Mathe = new PdfPCell(new Phrase(matheS + jStufe, NORMAL_BOLD_FONT));
    cell4Mathe.setColspan(6);
    cell4Mathe.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell4Mathe.setFixedHeight(35f);
    cell4Mathe.setHorizontalAlignment(Element.ALIGN_LEFT);
    cell4Mathe.setBorder(Rectangle.NO_BORDER);

    // Zahlen und Operationen 
    PdfPCell cell4zo;
    cell4zo = new PdfPCell(new Phrase(zo, NORMAL_FONT));
    //cell2ATitle.setColspan(4);
    cell4zo.setVerticalAlignment(Element.ALIGN_TOP);
    cell4zo.setFixedHeight(50f);
    cell4zo.setPadding(pad);
    cell4zo.setHorizontalAlignment(Element.ALIGN_LEFT);
    //cell2ATitle.setBorder(Rectangle.NO_BORDER);

    PdfPCell cell4Leer;
    //        cell4Leer = new PdfPCell(new Phrase("--",TINY_FONT));
    cell4Leer = new PdfPCell(kreisViertel(0, pad, Element.ALIGN_RIGHT, Element.ALIGN_TOP, Rectangle.BOX));
    //cell2ATitle.setColspan(4);
    cell4Leer.setVerticalAlignment(Element.ALIGN_MIDDLE);
    //cell2ATitle.setFixedHeight(30f);
    cell4Leer.setPadding(pad);
    cell4Leer.setHorizontalAlignment(Element.ALIGN_CENTER);
    //cell2ATitle.setBorder(Rectangle.NO_BORDER);

    table4.addCell(cell4Header);
    table4.addCell(cell4Mathe);
    table4.addCell(cell4zo);
    table4.addCell(cell4Leer);
    table4.addCell(kreisViertel(1, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
    table4.addCell(kreisViertel(2, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
    table4.addCell(kreisViertel(3, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
    table4.addCell(kreisViertel(4, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));

    table4 = lernbereiche(table4, zahlenZL, pad);

    PdfPCell cell4EmptyLine;
    cell4EmptyLine = new PdfPCell(new Phrase("", NORMAL_BOLD_FONT));
    cell4EmptyLine.setColspan(6);
    cell4EmptyLine.setFixedHeight(15f);
    cell4EmptyLine.setBorder(Rectangle.NO_BORDER);

    // Gren und Messen
    PdfPCell cell4gm;
    cell4gm = new PdfPCell(new Phrase(gm, NORMAL_FONT));
    //cell2ATitle.setColspan(4);
    cell4gm.setVerticalAlignment(Element.ALIGN_TOP);
    cell4gm.setFixedHeight(50f);
    cell4gm.setPadding(pad);
    cell4gm.setHorizontalAlignment(Element.ALIGN_LEFT);
    //cell2ATitle.setBorder(Rectangle.NO_BORDER);

    //        cell4Leer = new PdfPCell(new Phrase("--",TINY_FONT));
    cell4Leer = new PdfPCell(kreisViertel(0, pad, Element.ALIGN_RIGHT, Element.ALIGN_TOP, Rectangle.BOX));
    cell4Leer.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell4Leer.setPadding(pad);
    cell4Leer.setHorizontalAlignment(Element.ALIGN_CENTER);

    table4.addCell(cell4EmptyLine);
    table4.addCell(cell4gm);
    table4.addCell(cell4Leer);
    table4.addCell(kreisViertel(1, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
    table4.addCell(kreisViertel(2, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
    table4.addCell(kreisViertel(3, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
    table4.addCell(kreisViertel(4, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));

    table4 = lernbereiche(table4, groessenZL, pad);

    // Raum und Form

    PdfPCell cell4rf;
    cell4rf = new PdfPCell(new Phrase(rf, NORMAL_FONT));
    cell4rf.setVerticalAlignment(Element.ALIGN_TOP);
    cell4rf.setFixedHeight(50f);
    cell4rf.setPadding(pad);
    cell4rf.setHorizontalAlignment(Element.ALIGN_LEFT);

    //        cell4Leer = new PdfPCell(new Phrase("--",TINY_FONT));
    cell4Leer = new PdfPCell(kreisViertel(0, pad, Element.ALIGN_RIGHT, Element.ALIGN_TOP, Rectangle.BOX));
    cell4Leer.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell4Leer.setPadding(pad);
    cell4Leer.setHorizontalAlignment(Element.ALIGN_CENTER);

    table4.addCell(emptyLine(6, 15f));
    table4.addCell(cell4rf);
    table4.addCell(cell4Leer);
    table4.addCell(kreisViertel(1, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
    table4.addCell(kreisViertel(2, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
    table4.addCell(kreisViertel(3, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
    table4.addCell(kreisViertel(4, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));

    table4 = lernbereiche(table4, raumZL, pad);

    doc.add(table4);
    doc.newPage();

    // *****************************************************************************************************
    if (Gui.getSClass().substring(0, 1).endsWith("1") || Gui.getSClass().substring(0, 1).endsWith("2")) {

        // Seite 5 *************************************************************
        // Tablestruktur aufbauen...
        pad = 3f;
        PdfPTable table5 = new PdfPTable(6);
        table5.setWidths(new float[] { 60, 8, 8, 8, 8, 8 });
        table5.setWidthPercentage(100);

        PdfPCell cell5Header = emptyLine(6, 10f);

        // *********************************************************************
        // Sachunterricht
        // *********************************************************************
        PdfPCell cell5Sachunterricht;
        cell5Sachunterricht = new PdfPCell(new Phrase(sachunterrichtS + jStufe, NORMAL_BOLD_FONT));
        cell5Sachunterricht.setColspan(6);
        cell5Sachunterricht.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell5Sachunterricht.setFixedHeight(35f);
        cell5Sachunterricht.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell5Sachunterricht.setBorder(Rectangle.NO_BORDER);

        PdfPCell cell5su;
        cell5su = new PdfPCell(new Phrase(su, NORMAL_FONT));
        cell5su.setVerticalAlignment(Element.ALIGN_TOP);
        cell5su.setFixedHeight(30f);
        cell5su.setPadding(pad);
        cell5su.setHorizontalAlignment(Element.ALIGN_LEFT);

        PdfPCell cell5Leer;
        cell5Leer = new PdfPCell(kreisViertel(0, pad, Element.ALIGN_RIGHT, Element.ALIGN_TOP, Rectangle.BOX));
        cell5Leer.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell5Leer.setPadding(pad);
        cell5Leer.setHorizontalAlignment(Element.ALIGN_CENTER);

        table5.addCell(cell5Header);
        table5.addCell(cell5Sachunterricht);
        table5.addCell(cell5su);
        table5.addCell(cell5Leer);
        table5.addCell(kreisViertel(1, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
        table5.addCell(kreisViertel(2, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
        table5.addCell(kreisViertel(3, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
        table5.addCell(kreisViertel(4, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));

        table5 = lernbereiche(table5, sachunterrichtZL, pad);

        table5.addCell(emptyLine(6, 15f));

        // *********************************************************************
        // Sport
        // *********************************************************************
        PdfPCell cell5Sport;
        cell5Sport = new PdfPCell(new Phrase(sportS + jStufe, NORMAL_BOLD_FONT));
        cell5Sport.setColspan(6);
        cell5Sport.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell5Sport.setFixedHeight(35f);
        cell5Sport.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell5Sport.setBorder(Rectangle.NO_BORDER);

        table5.addCell(cell5Sport);
        table5.addCell(cell5su);
        table5.addCell(cell5Leer);
        table5.addCell(kreisViertel(1, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
        table5.addCell(kreisViertel(2, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
        table5.addCell(kreisViertel(3, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
        table5.addCell(kreisViertel(4, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));

        table5 = lernbereiche(table5, sportZL, pad);

        table5.addCell(emptyLine(6, 15f));

        // *********************************************************************
        // Religion
        // *********************************************************************
        PdfPCell cell5Religion;
        cell5Religion = new PdfPCell(new Phrase(religionS + jStufe, NORMAL_BOLD_FONT));
        cell5Religion.setColspan(6);
        cell5Religion.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell5Religion.setFixedHeight(35f);
        cell5Religion.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell5Religion.setBorder(Rectangle.NO_BORDER);

        cell5su = new PdfPCell(new Phrase(su, NORMAL_FONT));
        cell5su.setVerticalAlignment(Element.ALIGN_TOP);
        cell5su.setFixedHeight(30f);
        cell5su.setPadding(pad);
        cell5su.setHorizontalAlignment(Element.ALIGN_LEFT);

        cell5Leer = new PdfPCell(kreisViertel(0, pad, Element.ALIGN_RIGHT, Element.ALIGN_TOP, Rectangle.BOX));
        cell5Leer.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell5Leer.setPadding(pad);
        cell5Leer.setHorizontalAlignment(Element.ALIGN_CENTER);

        table5.addCell(cell5Religion);
        table5.addCell(cell5su);
        table5.addCell(cell5Leer);
        table5.addCell(kreisViertel(1, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
        table5.addCell(kreisViertel(2, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
        table5.addCell(kreisViertel(3, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
        table5.addCell(kreisViertel(4, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));

        table5 = lernbereiche(table5, religionZL, pad);

        table5.addCell(emptyLine(6, 15f));

        // *********************************************************************
        // Musik
        // *********************************************************************
        PdfPCell cell5Musik;
        cell5Musik = new PdfPCell(new Phrase(musikS + jStufe, NORMAL_BOLD_FONT));
        cell5Musik.setColspan(6);
        cell5Musik.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell5Musik.setFixedHeight(35f);
        cell5Musik.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell5Musik.setBorder(Rectangle.NO_BORDER);

        cell5su = new PdfPCell(new Phrase(su, NORMAL_FONT));
        cell5su.setVerticalAlignment(Element.ALIGN_TOP);
        cell5su.setFixedHeight(30f);
        cell5su.setPadding(pad);
        cell5su.setHorizontalAlignment(Element.ALIGN_LEFT);

        cell5Leer = new PdfPCell(kreisViertel(0, pad, Element.ALIGN_RIGHT, Element.ALIGN_TOP, Rectangle.BOX));
        cell5Leer.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell5Leer.setPadding(pad);
        cell5Leer.setHorizontalAlignment(Element.ALIGN_CENTER);

        table5.addCell(cell5Musik);
        table5.addCell(cell5su);
        table5.addCell(cell5Leer);
        table5.addCell(kreisViertel(1, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
        table5.addCell(kreisViertel(2, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
        table5.addCell(kreisViertel(3, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
        table5.addCell(kreisViertel(4, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));

        table5 = lernbereiche(table5, musikZL, pad);

        table5.addCell(emptyLine(6, 15f));

        // *********************************************************************
        // Kunst
        // *********************************************************************
        PdfPCell cell5Kunst;
        cell5Kunst = new PdfPCell(new Phrase(kunstS + jStufe, NORMAL_BOLD_FONT));
        cell5Kunst.setColspan(6);
        cell5Kunst.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell5Kunst.setFixedHeight(35f);
        cell5Kunst.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell5Kunst.setBorder(Rectangle.NO_BORDER);

        table5.addCell(cell5Kunst);
        table5.addCell(cell5su);
        table5.addCell(cell5Leer);
        table5.addCell(kreisViertel(1, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
        table5.addCell(kreisViertel(2, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
        table5.addCell(kreisViertel(3, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
        table5.addCell(kreisViertel(4, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));

        table5 = lernbereiche(table5, kunstZL, pad);

        table5.addCell(emptyLine(6, 15f));

        doc.add(table5); // Ende Seite 5 fr 1. und 2. Klasse
    } else { // Anfang Seite 5 fr 3. und 4. Klasse
        // Seite 5a *************************************************************
        doc.newPage(); // Tablestruktur aufbauen...
        pad = 3f;
        PdfPTable table5a = new PdfPTable(6);
        table5a.setWidths(new float[] { 60, 8, 8, 8, 8, 8 });
        table5a.setWidthPercentage(100);

        PdfPCell cell5Header = emptyLine(6, 10f);

        // *********************************************************************
        // Sachunterricht
        // *********************************************************************
        PdfPCell cell5Sachunterricht;
        cell5Sachunterricht = new PdfPCell(new Phrase(sachunterrichtS + jStufe, NORMAL_BOLD_FONT));
        cell5Sachunterricht.setColspan(6);
        cell5Sachunterricht.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell5Sachunterricht.setFixedHeight(35f);
        cell5Sachunterricht.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell5Sachunterricht.setBorder(Rectangle.NO_BORDER);

        PdfPCell cell5su;
        cell5su = new PdfPCell(new Phrase(su, NORMAL_FONT));
        cell5su.setVerticalAlignment(Element.ALIGN_TOP);
        cell5su.setFixedHeight(30f);
        cell5su.setPadding(pad);
        cell5su.setHorizontalAlignment(Element.ALIGN_LEFT);

        PdfPCell cell5Leer;
        cell5Leer = new PdfPCell(kreisViertel(0, pad, Element.ALIGN_RIGHT, Element.ALIGN_TOP, Rectangle.BOX));
        cell5Leer.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell5Leer.setPadding(pad);
        cell5Leer.setHorizontalAlignment(Element.ALIGN_CENTER);

        table5a.addCell(cell5Header);
        table5a.addCell(cell5Sachunterricht);
        table5a.addCell(cell5su);
        table5a.addCell(cell5Leer);
        table5a.addCell(kreisViertel(1, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
        table5a.addCell(kreisViertel(2, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
        table5a.addCell(kreisViertel(3, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
        table5a.addCell(kreisViertel(4, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));

        table5a = lernbereiche(table5a, sachunterrichtZL, pad);

        table5a.addCell(emptyLine(6, 15f));

        // *********************************************************************
        // Englisch
        // *********************************************************************
        PdfPCell cell5Englisch;
        cell5Englisch = new PdfPCell(new Phrase(englischS + jStufe, NORMAL_BOLD_FONT));
        cell5Englisch.setColspan(6);
        cell5Englisch.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell5Englisch.setFixedHeight(35f);
        cell5Englisch.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell5Englisch.setBorder(Rectangle.NO_BORDER);

        table5a.addCell(cell5Englisch);
        table5a.addCell(cell5su);
        table5a.addCell(cell5Leer);
        table5a.addCell(kreisViertel(1, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
        table5a.addCell(kreisViertel(2, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
        table5a.addCell(kreisViertel(3, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
        table5a.addCell(kreisViertel(4, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));

        table5a = lernbereiche(table5a, englischZL, pad);

        table5a.addCell(emptyLine(6, 15f));

        // *********************************************************************
        // Sport
        // *********************************************************************
        PdfPCell cell5Sport;
        cell5Sport = new PdfPCell(new Phrase(sportS + jStufe, NORMAL_BOLD_FONT));
        cell5Sport.setColspan(6);
        cell5Sport.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell5Sport.setFixedHeight(35f);
        cell5Sport.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell5Sport.setBorder(Rectangle.NO_BORDER);

        table5a.addCell(cell5Sport);
        table5a.addCell(cell5su);
        table5a.addCell(cell5Leer);
        table5a.addCell(kreisViertel(1, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
        table5a.addCell(kreisViertel(2, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
        table5a.addCell(kreisViertel(3, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
        table5a.addCell(kreisViertel(4, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));

        table5a = lernbereiche(table5a, sportZL, pad);

        table5a.addCell(emptyLine(6, 15f));

        doc.add(table5a);

        // Seite 6 *************************************************************
        doc.newPage();
        // Tablestruktur aufbauen...
        PdfPTable table6 = new PdfPTable(6);
        pad = 3f;
        table6.setWidths(new float[] { 60, 8, 8, 8, 8, 8 });
        table6.setWidthPercentage(100);

        PdfPCell cell6Header = emptyLine(6, 10f);

        // *********************************************************************
        // Religion
        // *********************************************************************
        PdfPCell cell6Religion;
        cell6Religion = new PdfPCell(new Phrase(religionS + jStufe, NORMAL_BOLD_FONT));
        cell6Religion.setColspan(6);
        cell6Religion.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell6Religion.setFixedHeight(35f);
        cell6Religion.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell6Religion.setBorder(Rectangle.NO_BORDER);

        PdfPCell cell6su;
        cell6su = new PdfPCell(new Phrase(su, NORMAL_FONT));
        cell6su.setVerticalAlignment(Element.ALIGN_TOP);
        cell6su.setFixedHeight(30f);
        cell6su.setPadding(pad);
        cell6su.setHorizontalAlignment(Element.ALIGN_LEFT);

        PdfPCell cell6Leer;
        cell6Leer = new PdfPCell(kreisViertel(0, pad, Element.ALIGN_RIGHT, Element.ALIGN_TOP, Rectangle.BOX));
        cell6Leer.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell6Leer.setPadding(pad);
        cell6Leer.setHorizontalAlignment(Element.ALIGN_CENTER);

        table6.addCell(cell6Religion);
        table6.addCell(cell6su);
        table6.addCell(cell6Leer);
        table6.addCell(kreisViertel(1, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
        table6.addCell(kreisViertel(2, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
        table6.addCell(kreisViertel(3, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
        table6.addCell(kreisViertel(4, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));

        table6 = lernbereiche(table6, religionZL, pad);

        table6.addCell(emptyLine(6, 15f));

        // *********************************************************************
        // Musik
        // *********************************************************************
        PdfPCell cell6Musik;
        cell6Musik = new PdfPCell(new Phrase(musikS + jStufe, NORMAL_BOLD_FONT));
        cell6Musik.setColspan(6);
        cell6Musik.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell6Musik.setFixedHeight(35f);
        cell6Musik.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell6Musik.setBorder(Rectangle.NO_BORDER);

        cell6su = new PdfPCell(new Phrase(su, NORMAL_FONT));
        cell6su.setVerticalAlignment(Element.ALIGN_TOP);
        cell6su.setFixedHeight(30f);
        cell6su.setPadding(pad);
        cell6su.setHorizontalAlignment(Element.ALIGN_LEFT);

        cell6Leer = new PdfPCell(kreisViertel(0, pad, Element.ALIGN_RIGHT, Element.ALIGN_TOP, Rectangle.BOX));
        cell6Leer.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell6Leer.setPadding(pad);
        cell6Leer.setHorizontalAlignment(Element.ALIGN_CENTER);

        table6.addCell(cell6Musik);
        table6.addCell(cell6su);
        table6.addCell(cell6Leer);
        table6.addCell(kreisViertel(1, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
        table6.addCell(kreisViertel(2, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
        table6.addCell(kreisViertel(3, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
        table6.addCell(kreisViertel(4, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));

        table6 = lernbereiche(table6, musikZL, pad);

        table6.addCell(emptyLine(6, 15f));

        // *********************************************************************
        // Kunst
        // *********************************************************************
        PdfPCell cell6Kunst;
        cell6Kunst = new PdfPCell(new Phrase(kunstS + jStufe, NORMAL_BOLD_FONT));
        cell6Kunst.setColspan(6);
        cell6Kunst.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell6Kunst.setFixedHeight(35f);
        cell6Kunst.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell6Kunst.setBorder(Rectangle.NO_BORDER);

        table6.addCell(cell6Kunst);
        table6.addCell(cell6su);
        table6.addCell(cell6Leer);
        table6.addCell(kreisViertel(1, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
        table6.addCell(kreisViertel(2, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
        table6.addCell(kreisViertel(3, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
        table6.addCell(kreisViertel(4, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));

        table6 = lernbereiche(table6, kunstZL, pad);

        table6.addCell(emptyLine(6, 15f));

        doc.add(table6);
        // Seite 7 *************************************************************
        doc.newPage();
        // Tablestruktur aufbauen...
        PdfPTable table7 = new PdfPTable(6);
        pad = 3f;
        table7.setWidths(new float[] { 60, 8, 8, 8, 8, 8 });
        table7.setWidthPercentage(100);

        PdfPCell cell7Header = emptyLine(6, 10f);

        table7.addCell(cell7Header);

        PdfPCell cell7su;
        cell7su = new PdfPCell(new Phrase(su, NORMAL_FONT));
        cell7su.setVerticalAlignment(Element.ALIGN_TOP);
        cell7su.setFixedHeight(30f);
        cell7su.setPadding(pad);
        cell7su.setHorizontalAlignment(Element.ALIGN_LEFT);

        PdfPCell cell7Leer;
        cell7Leer = new PdfPCell(kreisViertel(0, pad, Element.ALIGN_RIGHT, Element.ALIGN_TOP, Rectangle.BOX));
        cell7Leer.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell7Leer.setPadding(pad);
        cell7Leer.setHorizontalAlignment(Element.ALIGN_CENTER);

        // *********************************************************************
        // Textil
        // *********************************************************************
        PdfPCell cell7Textil;
        cell7Textil = new PdfPCell(new Phrase(textilS + jStufe, NORMAL_BOLD_FONT));
        cell7Textil.setColspan(6);
        cell7Textil.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell7Textil.setFixedHeight(35f);
        cell7Textil.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell7Textil.setBorder(Rectangle.NO_BORDER);

        table7.addCell(cell7Textil);
        table7.addCell(cell7su);
        table7.addCell(cell7Leer);
        table7.addCell(kreisViertel(1, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
        table7.addCell(kreisViertel(2, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
        table7.addCell(kreisViertel(3, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
        table7.addCell(kreisViertel(4, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));

        table7 = lernbereiche(table7, textilZL, pad);

        table7.addCell(emptyLine(6, 15f));

        // *********************************************************************
        // Werken
        // *********************************************************************
        PdfPCell cell7Werken;
        cell7Werken = new PdfPCell(new Phrase(werkenS + jStufe, NORMAL_BOLD_FONT));
        cell7Werken.setColspan(6);
        cell7Werken.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell7Werken.setFixedHeight(35f);
        cell7Werken.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell7Werken.setBorder(Rectangle.NO_BORDER);

        table7.addCell(cell7Werken);
        table7.addCell(cell7su);
        table7.addCell(cell7Leer);
        table7.addCell(kreisViertel(1, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
        table7.addCell(kreisViertel(2, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
        table7.addCell(kreisViertel(3, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));
        table7.addCell(kreisViertel(4, pad, Element.ALIGN_CENTER, Element.ALIGN_MIDDLE, Rectangle.BOX));

        table7 = lernbereiche(table7, werkenZL, pad);

        table7.addCell(emptyLine(6, 15f));

        doc.add(table7);
    }
    doc.addTitle("Zeugnis");
    doc.addAuthor("Grundschule Brelingen");
    doc.addCreationDate();
    doc.addSubject("Zeugnis");
    doc.close();
    writer.close();
}