Example usage for com.itextpdf.text Image getWidth

List of usage examples for com.itextpdf.text Image getWidth

Introduction

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

Prototype

public float getWidth() 

Source Link

Document

Returns the width of the rectangle.

Usage

From source file:Login.ventas.fproyectos.java

public void fondos(Document documento, PdfContentByte canvas) {
    try {/*ww  w  .  ja v  a  2 s  . co m*/
        Image imghead = Image.getInstance(usuario.getDireccion() + "/plantilla.jpg");
        imghead.setAbsolutePosition(0, 0);
        imghead.setAlignment(Image.ALIGN_CENTER);
        float scaler = ((documento.getPageSize().getWidth() - documento.leftMargin() - documento.rightMargin())
                / imghead.getWidth()) * 100;
        imghead.scalePercent(scaler);
        PdfTemplate tp = canvas.createTemplate(PageSize.A4.getWidth(), PageSize.A4.getHeight()); //el rea destinada para el encabezado
        tp.addImage(imghead);
        x = (int) imghead.getWidth();
        y = (int) imghead.getHeight();
        canvas.addTemplate(tp, 0, 0);//posicin del tmplate derecha y abajo
    } catch (IOException | DocumentException io) {

    }
}

From source file:org.alfresco.extension.pdftoolkit.repo.action.executer.PDFWatermarkActionExecuter.java

License:Apache License

/**
 * Applies an image watermark/*  w ww  .j  a  va2  s .  c om*/
 * 
 * @param reader
 * @param writer
 * @param options
 * @throws Exception
 */
private void imageAction(Action ruleAction, NodeRef actionedUponNodeRef, NodeRef watermarkNodeRef,
        ContentReader actionedUponContentReader, ContentReader watermarkContentReader,
        Map<String, Object> options) {

    PdfStamper stamp = null;
    File tempDir = null;
    ContentWriter writer = null;

    try {
        // get a temp file to stash the watermarked PDF in before moving to
        // repo
        File alfTempDir = TempFileProvider.getTempDir();
        tempDir = new File(alfTempDir.getPath() + File.separatorChar + actionedUponNodeRef.getId());
        tempDir.mkdir();
        File file = new File(tempDir,
                serviceRegistry.getFileFolderService().getFileInfo(actionedUponNodeRef).getName());

        // get the PDF input stream and create a reader for iText
        PdfReader reader = new PdfReader(actionedUponContentReader.getContentInputStream());
        stamp = new PdfStamper(reader, new FileOutputStream(file));
        PdfContentByte pcb;

        // get a com.itextpdf.text.Image object via java.imageio.ImageIO
        Image img = Image.getInstance(ImageIO.read(watermarkContentReader.getContentInputStream()), null);

        // get the PDF pages and position
        String pages = (String) options.get(PARAM_PAGE);
        String position = (String) options.get(PARAM_POSITION);
        String depth = (String) options.get(PARAM_WATERMARK_DEPTH);

        // image requires absolute positioning or an exception will be
        // thrown
        // set image position according to parameter. Use
        // PdfReader.getPageSizeWithRotation
        // to get the canvas size for alignment.
        img.setAbsolutePosition(100f, 100f);

        // stamp each page
        int numpages = reader.getNumberOfPages();
        for (int i = 1; i <= numpages; i++) {
            Rectangle r = reader.getPageSizeWithRotation(i);
            // set stamp position
            if (position.equals(POSITION_BOTTOMLEFT)) {
                img.setAbsolutePosition(0, 0);
            } else if (position.equals(POSITION_BOTTOMRIGHT)) {
                img.setAbsolutePosition(r.getWidth() - img.getWidth(), 0);
            } else if (position.equals(POSITION_TOPLEFT)) {
                img.setAbsolutePosition(0, r.getHeight() - img.getHeight());
            } else if (position.equals(POSITION_TOPRIGHT)) {
                img.setAbsolutePosition(r.getWidth() - img.getWidth(), r.getHeight() - img.getHeight());
            } else if (position.equals(POSITION_CENTER)) {
                img.setAbsolutePosition(getCenterX(r, img), getCenterY(r, img));
            }

            // if this is an under-text stamp, use getUnderContent.
            // if this is an over-text stamp, usse getOverContent.
            if (depth.equals(DEPTH_OVER)) {
                pcb = stamp.getOverContent(i);
            } else {
                pcb = stamp.getUnderContent(i);
            }

            // only apply stamp to requested pages
            if (checkPage(pages, i, numpages)) {
                pcb.addImage(img);
            }
        }

        stamp.close();

        // Get a writer and prep it for putting it back into the repo
        //can't use BasePDFActionExecuter.getWriter here need the nodeRef of the destination
        NodeRef destinationNode = createDestinationNode(file.getName(),
                (NodeRef) ruleAction.getParameterValue(PARAM_DESTINATION_FOLDER), actionedUponNodeRef);
        writer = serviceRegistry.getContentService().getWriter(destinationNode, ContentModel.PROP_CONTENT,
                true);

        writer.setEncoding(actionedUponContentReader.getEncoding());
        writer.setMimetype(FILE_MIMETYPE);

        // Put it in the repo
        writer.putContent(file);

        // delete the temp file
        file.delete();
    } catch (IOException e) {
        throw new AlfrescoRuntimeException(e.getMessage(), e);
    } catch (DocumentException e) {
        throw new AlfrescoRuntimeException(e.getMessage(), e);
    } finally {
        if (tempDir != null) {
            try {
                tempDir.delete();
            } catch (Exception ex) {
                throw new AlfrescoRuntimeException(ex.getMessage(), ex);
            }
        }

        if (stamp != null) {
            try {
                stamp.close();
            } catch (Exception ex) {
                throw new AlfrescoRuntimeException(ex.getMessage(), ex);
            }
        }
    }
}

From source file:org.durel.mydooble.ImageItem.java

License:Open Source License

@Override
public void toPDF(PDF out, int i) {
    super.toPDF(out, i);

    try {/*from   w ww .  j av a  2  s . c  o  m*/
        Image img = Image.getInstance(image);
        img.setDpi(288, 288);
        img.setInterpolation(true);
        float ih = (float) (img.getHeight());
        float iw = (float) (img.getWidth());
        if (ih > h || iw > w) {
            float xratio = iw / w;
            float yratio = ih / h;
            float ratio = Math.max(xratio, yratio);
            log.info("ih: " + ih + " - iw: " + iw + " - xratio: " + xratio + " - yratio: " + yratio
                    + " - ratio: " + ratio + " --> " + (int) (iw / ratio) + "x" + (int) (ih / ratio));
            img.scalePercent(100 / ratio);
        }

        PdfContentByte cb = out.writer.getDirectContent();
        float x = bx + (c * (w + m)) + m;
        float y = by + (r * (h + m)) + m;
        img.setAbsolutePosition(x, y);
        cb.addImage(img);
    } catch (DocumentException e) {
        e.printStackTrace();
    } catch (MalformedURLException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:pdfcreator.PDFCreator.java

License:Open Source License

@SuppressWarnings("static-access")
protected void createPdf(String filename, String[] images) throws Exception {
    Document doc = new Document();
    PdfWriter writer;/*from   w w  w. j a v  a2s  .c o m*/

    if (pdfxConformance.equals("PDFA1A")) {
        writer = PdfAWriter.getInstance(doc, new FileOutputStream(filename), PdfAConformanceLevel.PDF_A_1A);
    } else if (pdfxConformance.equals("PDFA1B")) {
        writer = PdfAWriter.getInstance(doc, new FileOutputStream(filename), PdfAConformanceLevel.PDF_A_1B);
    } else if (pdfxConformance.equals("PDFA2A")) {
        writer = PdfAWriter.getInstance(doc, new FileOutputStream(filename), PdfAConformanceLevel.PDF_A_2A);
    } else if (pdfxConformance.equals("PDFA2B")) {
        writer = PdfAWriter.getInstance(doc, new FileOutputStream(filename), PdfAConformanceLevel.PDF_A_2B);
    } else if (pdfxConformance.equals("PDFA3A")) {
        writer = PdfAWriter.getInstance(doc, new FileOutputStream(filename), PdfAConformanceLevel.PDF_A_3A);
    } else if (pdfxConformance.equals("PDFA3B")) {
        writer = PdfAWriter.getInstance(doc, new FileOutputStream(filename), PdfAConformanceLevel.PDF_A_3B);
    } else {
        writer = PdfWriter.getInstance(doc, new FileOutputStream(filename));
    }

    if (pdfVersion.equals("1.4")) {
        writer.setPdfVersion(PdfWriter.VERSION_1_4);
    } else if (pdfVersion.equals("1.5")) {
        writer.setPdfVersion(PdfWriter.VERSION_1_5);
    } else if (pdfVersion.equals("1.6")) {
        writer.setPdfVersion(PdfWriter.VERSION_1_6);
    } else if (pdfVersion.equals("1.7")) {
        writer.setPdfVersion(PdfWriter.VERSION_1_7);
    } else {
        writer.setPdfVersion(PdfWriter.VERSION_1_4);
    }

    verbose(filename + ": open");

    doc.addCreationDate();
    doc.addCreator(creator);

    if (title != null) {
        doc.addTitle(title);
    }

    for (int i = 0; i < images.length; i++) {
        verbose(" +" + images[i]);

        Image img = Image.getInstance(images[i]);

        doc.setPageSize(new Rectangle(img.getWidth(), img.getHeight()));
        doc.setMargins(0, 0, 0, 0);

        if (doc.isOpen()) {
            doc.newPage();
        } else {
            doc.open();
        }

        doc.add(img);

        doc.newPage();
    }

    ICC_Profile icc = getImageColorProfile(images[0]);

    if (icc == null) {
        System.err.println("warning: no color profile available in " + images[0] + " using " + profileName);
        icc = getDefaultColorProfile();
    }

    writer.setOutputIntents("Custom", "", null, null, icc);

    writer.createXmpMetadata();

    doc.close();

    verbose(filename + ": close");
}

From source file:pdfextract.ExtractInfo.java

public void extractImagesInfo() {
    try {/*from w  w  w  .  j  av a 2 s. com*/
        PdfReader chartReader = new PdfReader("vv.pdf");
        for (int i = 0; i < chartReader.getXrefSize(); i++) {
            PdfObject pdfobj = chartReader.getPdfObject(i);
            if (pdfobj != null && pdfobj.isStream()) {
                PdfStream stream = (PdfStream) pdfobj;
                PdfObject pdfsubtype = stream.get(PdfName.SUBTYPE);
                //System.out.println("Stream subType: " + pdfsubtype); 
                if (pdfsubtype != null && pdfsubtype.toString().equals(PdfName.IMAGE.toString())) {
                    byte[] image = PdfReader.getStreamBytesRaw((PRStream) stream);
                    Image imageObject = Image.getInstance(image);
                    System.out.println("Resolution" + imageObject.getDpiX());
                    System.out.println("Height" + imageObject.getHeight());
                    System.out.println("Width" + imageObject.getWidth());

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

}

From source file:pl.marcinmilkowski.hocrtopdf.Main.java

License:Open Source License

/**
 * @param args/*from ww w . j a va2s. c  o  m*/
 */
public static void main(String[] args) {
    try {
        if (args.length < 1 || args[0] == "--help" || args[0] == "-h") {
            System.out.print("Usage: java pl.marcinmilkowski.hocrtopdf.Main INPUTURL.html OUTPUTURL.pdf\n"
                    + "\n" + "Converts hOCR files into PDF\n" + "\n"
                    + "Example: java pl.marcinmilkowski.hocrtopdf.Main hocr.html output.pdf\n");
            if (args.length < 1)
                System.exit(-1);
            else
                System.exit(0);
        }
        URL inputHOCRFile = null;
        FileOutputStream outputPDFStream = null;
        try {
            File file = new File(args[0]);
            inputHOCRFile = file.toURI().toURL();
        } catch (MalformedURLException e) {
            System.out.println("The first parameter has to be a valid file.");
            System.out.println("We got an error: " + e.getMessage());
            System.exit(-1);
        }
        try {
            outputPDFStream = new FileOutputStream(args[1]);
        } catch (FileNotFoundException e) {
            System.out.println("The second parameter has to be a valid URL");
            System.exit(-1);
        }

        // The resolution of a PDF file (using iText) is 72pt per inch
        float pointsPerInch = 72.0f;

        // Using the jericho library to parse the HTML file
        Source source = new Source(inputHOCRFile);

        int pageCounter = 1;

        Document pdfDocument = null;
        PdfWriter pdfWriter = null;
        PdfContentByte cb = null;
        RandomAccessFileOrArray ra = null;

        // Find the tag of class ocr_page in order to load the scanned image
        StartTag pageTag = source.getNextStartTag(0, "class", OCRPAGE);
        while (pageTag != null) {
            int prevPos = pageTag.getEnd();
            Pattern imagePattern = Pattern.compile("image\\s+([^;]+)");
            Matcher imageMatcher = imagePattern.matcher(pageTag.getElement().getAttributeValue("title"));
            if (!imageMatcher.find()) {
                System.out.println("Could not find a tag of class \"ocr_page\", aborting.");
                System.exit(-1);
            }
            // Load the image
            Image pageImage = null;
            try {
                File file = new File(imageMatcher.group(1));
                pageImage = Image.getInstance(file.toURI().toURL());
            } catch (MalformedURLException e) {
                System.out.println("Could not load the scanned image from: " + "file://" + imageMatcher.group(1)
                        + ", aborting.");
                System.exit(-1);
            }
            if (pageImage.getOriginalType() == Image.ORIGINAL_TIFF) { // this might
                                                                      // be
                                                                      // multipage
                                                                      // tiff!
                File file = new File(imageMatcher.group(1));
                if (pageCounter == 1 || ra == null) {
                    ra = new RandomAccessFileOrArray(file.toURI().toURL());
                }
                int nPages = TiffImage.getNumberOfPages(ra);
                if (nPages > 0 && pageCounter <= nPages) {
                    pageImage = TiffImage.getTiffImage(ra, pageCounter);
                }
            }
            int dpiX = pageImage.getDpiX();
            if (dpiX == 0) { // for images that don't set the resolution we assume
                             // 300 dpi
                dpiX = 300;
            }
            int dpiY = pageImage.getDpiY();
            if (dpiY == 0) { // as above for dpiX
                dpiY = 300;
            }
            float dotsPerPointX = dpiX / pointsPerInch;
            float dotsPerPointY = dpiY / pointsPerInch;
            float pageImagePixelHeight = pageImage.getHeight();
            if (pdfDocument == null) {
                pdfDocument = new Document(new Rectangle(pageImage.getWidth() / dotsPerPointX,
                        pageImage.getHeight() / dotsPerPointY));
                pdfWriter = PdfWriter.getInstance(pdfDocument, outputPDFStream);
                pdfDocument.open();
                // Put the text behind the picture (reverse for debugging)
                // cb = pdfWriter.getDirectContentUnder();
                cb = pdfWriter.getDirectContent();
            } else {
                pdfDocument.setPageSize(new Rectangle(pageImage.getWidth() / dotsPerPointX,
                        pageImage.getHeight() / dotsPerPointY));
                pdfDocument.newPage();
            }
            // first define a standard font for our text
            BaseFont base = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.EMBEDDED);
            Font defaultFont = new Font(base, 8);
            // FontFactory.getFont(FontFactory.HELVETICA, 8, Font.BOLD,
            // CMYKColor.BLACK);

            cb.setHorizontalScaling(1.0f);

            pageImage.scaleToFit(pageImage.getWidth() / dotsPerPointX, pageImage.getHeight() / dotsPerPointY);
            pageImage.setAbsolutePosition(0, 0);
            // Put the image in front of the text (reverse for debugging)
            // pdfWriter.getDirectContent().addImage(pageImage);
            pdfWriter.getDirectContentUnder().addImage(pageImage);

            // In order to place text behind the recognised text snippets we are
            // interested in the bbox property
            Pattern bboxPattern = Pattern.compile("bbox(\\s+\\d+){4}");
            // This pattern separates the coordinates of the bbox property
            Pattern bboxCoordinatePattern = Pattern.compile("(\\d+)\\s+(\\d+)\\s+(\\d+)\\s+(\\d+)");
            // Only tags of the ocr_line class are interesting
            StartTag ocrTag = source.getNextStartTag(prevPos, "class", OCRPAGEORLINE);
            while (ocrTag != null) {
                prevPos = ocrTag.getEnd();
                if ("ocrx_word".equalsIgnoreCase(ocrTag.getAttributeValue("class"))) {
                    net.htmlparser.jericho.Element lineElement = ocrTag.getElement();
                    Matcher bboxMatcher = bboxPattern.matcher(lineElement.getAttributeValue("title"));
                    if (bboxMatcher.find()) {
                        // We found a tag of the ocr_line class containing a bbox property
                        Matcher bboxCoordinateMatcher = bboxCoordinatePattern.matcher(bboxMatcher.group());
                        bboxCoordinateMatcher.find();
                        int[] coordinates = { Integer.parseInt((bboxCoordinateMatcher.group(1))),
                                Integer.parseInt((bboxCoordinateMatcher.group(2))),
                                Integer.parseInt((bboxCoordinateMatcher.group(3))),
                                Integer.parseInt((bboxCoordinateMatcher.group(4))) };
                        String line = lineElement.getContent().getTextExtractor().toString();
                        float bboxWidthPt = (coordinates[2] - coordinates[0]) / dotsPerPointX;
                        float bboxHeightPt = (coordinates[3] - coordinates[1]) / dotsPerPointY;

                        // Put the text into the PDF
                        cb.beginText();
                        // Comment the next line to debug the PDF output (visible Text)
                        cb.setTextRenderingMode(PdfContentByte.TEXT_RENDER_MODE_INVISIBLE);
                        // height
                        cb.setFontAndSize(defaultFont.getBaseFont(), Math.max(Math.round(bboxHeightPt), 1));
                        // width
                        cb.setHorizontalScaling(bboxWidthPt / cb.getEffectiveStringWidth(line, false));
                        cb.moveText((coordinates[0] / dotsPerPointX),
                                ((pageImagePixelHeight - coordinates[3]) / dotsPerPointY));
                        cb.showText(line);
                        cb.endText();
                        cb.setHorizontalScaling(1.0f);
                    }
                } else {
                    if ("ocr_page".equalsIgnoreCase(ocrTag.getAttributeValue("class"))) {
                        pageCounter++;
                        pageTag = ocrTag;
                        break;
                    }
                }
                ocrTag = source.getNextStartTag(prevPos, "class", OCRPAGEORLINE);
            }
            if (ocrTag == null) {
                pdfDocument.close();
                break;
            }
        }
    } catch (DocumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:server.kartu.tik.iText.java

public String createPDF(String tanggal, ArrayList kegiatan, String divisi) {
    ArrayList<Kegiatan> list = new ArrayList<>(kegiatan);

    String output = System.getProperty("user.dir") + "\\src\\data\\pdf\\" + tanggal + " " + getNamalengkap()
            + "-" + getTglnoktp() + ".pdf";

    String namaDivisi = "";
    switch (divisi) {
    case "1":
        namaDivisi = "Ekonomi";
        break;// w w  w  .  ja v a2  s  . co m
    case "2":
        namaDivisi = "Politik";
        break;
    case "3":
        namaDivisi = "Sosial Budaya";
        break;
    case "4":
        namaDivisi = "Keamanan";
        break;
    }

    Document document = new Document(PageSize.A4);
    try {
        PdfWriter.getInstance(document, new FileOutputStream(output));

        document.open();

        //------------------------------------------------------------------------------------- TITLE
        PdfPTable title = new PdfPTable(1);
        title.setWidthPercentage(100);
        Font f = new Font(FontFamily.HELVETICA, 14, Font.NORMAL, GrayColor.GRAYWHITE);
        PdfPCell celltitle = new PdfPCell(new Phrase("KARTU TIK (" + namaDivisi + ")", f));
        celltitle.setMinimumHeight(20);
        celltitle.setBackgroundColor(GrayColor.GRAYBLACK);
        celltitle.setHorizontalAlignment(Element.ALIGN_CENTER);
        celltitle.setColspan(3);
        title.addCell(celltitle);
        document.add(title);
        //-------------------------------------------------------------------------------------- END

        //------------------------------------------------------------------------------------- NAMA + ALIAS
        float[] columnWidths = { 8, 2 };
        PdfPTable tabel1 = new PdfPTable(columnWidths);
        tabel1.setWidthPercentage(100);

        PdfPTable innerTable1 = new PdfPTable(1);
        innerTable1.setWidthPercentage(100);
        PdfPTable innerTable2 = new PdfPTable(1);
        innerTable2.setWidthPercentage(100);
        PdfPCell cell;
        innerTable1.addCell(
                "1.  a. Nama Lengkap : " + getNamalengkap() + " \n\n     b. Alias : " + getAlias() + " \n\n");
        innerTable1.addCell("2.  Kebangsaan \n     a. Tgl. No. KTP : " + getTglnoktp()
                + " \n\n     b. Tgl. No. Pasport : " + getTglnopasport() + "\n\n");
        innerTable1.addCell("3.  Agama : " + getAgama());
        cell = new PdfPCell(innerTable1);
        cell.setMinimumHeight(135);
        tabel1.addCell(cell);
        if (getUrlfoto().equalsIgnoreCase("") || getUrlfoto().isEmpty() || getUrlfoto() == null) {

        } else {
            Image image = Image.getInstance(getUrlfoto());
            cell = new PdfPCell(image, false);
            if (image.getWidth() < 90) {
                cell.setPaddingLeft(8);
            } else {
                cell.setPaddingLeft(3);
            }
        }
        cell.setMinimumHeight(135);
        tabel1.addCell(cell);
        cell = new PdfPCell();
        cell.setColspan(14);
        tabel1.addCell(cell);

        document.add(tabel1);
        //------------------------------------------------------------------------------------- NAMA + ALIAS END

        //------------------------------------------------------------------------------------- TGL LAHIR + TEMPAT
        PdfPTable tabel4 = new PdfPTable(1);
        tabel4.setWidthPercentage(100);

        Paragraph pTglLahirnTempat = new Paragraph();
        pTglLahirnTempat.add("4.  a. Tgl. Lahir/ Umur : " + getTgllahir());
        pTglLahirnTempat.add("\n\n     b. Tempat Lahir     : " + getTempatlahir());
        pTglLahirnTempat.setLeading(0, 1);

        PdfPCell cTglLahirnTempat = new PdfPCell();
        cTglLahirnTempat.setMinimumHeight(45);
        cTglLahirnTempat.addElement(pTglLahirnTempat);
        tabel4.addCell(cTglLahirnTempat);

        document.add(tabel4);
        //------------------------------------------------------------------------------------- TGL LAHIR + TEMPAT END

        //------------------------------------------------------------------------------------- ALAMAT + PINDAHAN
        PdfPTable tabel5 = new PdfPTable(1);
        tabel5.setWidthPercentage(100);

        Paragraph pAlamat = new Paragraph();
        pAlamat.add("5.  Alamat : ");
        pAlamat.add(alamat);
        pAlamat.setLeading(0, 1);

        PdfPCell cAlamat = new PdfPCell();
        cAlamat.setMinimumHeight(18);
        cAlamat.addElement(pAlamat);
        tabel5.addCell(cAlamat);
        document.add(tabel5);

        PdfPTable tabel51 = new PdfPTable(1);
        tabel51.setWidthPercentage(100);

        Paragraph pAlamatUbah = new Paragraph();
        pAlamatUbah.add("6.  Perubahan Alamat :");
        pAlamatUbah.add("\n\n    1. ");
        pAlamatUbah.add("\n\n    2. ");
        pAlamatUbah.add("\n\n    3. ");
        pAlamatUbah.add("\n\n");
        pAlamatUbah.setLeading(0, 1);

        PdfPCell cAlamatUbah = new PdfPCell();
        cAlamatUbah.addElement(pAlamatUbah);
        tabel51.addCell(cAlamatUbah);
        document.add(tabel51);
        //------------------------------------------------------------------------------------- ALAMAT + PINDAHAN END

        //------------------------------------------------------------------------------------- KEDUDUKAN KELUARGA
        PdfPTable tabel6 = new PdfPTable(1);
        tabel6.setWidthPercentage(100);

        Paragraph pKedudukanKeluarga = new Paragraph();
        pKedudukanKeluarga.add("7.  Kedudukan dalam Keluarga : ");
        pKedudukanKeluarga.setLeading(0, 1);

        PdfPCell cKedudukanKeluarga = new PdfPCell();
        cKedudukanKeluarga.setMinimumHeight(20);
        cKedudukanKeluarga.addElement(pKedudukanKeluarga);
        tabel6.addCell(cKedudukanKeluarga);
        document.add(tabel6);

        PdfPTable tabel61 = new PdfPTable(1);
        tabel61.setWidthPercentage(100);

        Paragraph pNamaBapakIbu = new Paragraph();
        pNamaBapakIbu.add("8.  a.  Nama Bapak : ");
        pNamaBapakIbu.add("\n\n          Nama Ibu      : ");
        pNamaBapakIbu.add("\n\n     b.  Alamat : ");
        pNamaBapakIbu.setLeading(0, 1);

        PdfPCell cNamaBapakIbu = new PdfPCell();
        cNamaBapakIbu.setMinimumHeight(70);
        cNamaBapakIbu.addElement(pNamaBapakIbu);
        tabel61.addCell(cNamaBapakIbu);

        document.add(tabel61);
        //------------------------------------------------------------------------------------- KEDUDUKAN END

        //------------------------------------------------------------------------------------- PEKERJAAN
        PdfPTable tabel7 = new PdfPTable(2);
        tabel7.setWidthPercentage(100);

        Paragraph pPekerjaan = new Paragraph();
        pPekerjaan.add("9.  a. Pekerjaan : " + getPekerjaan());
        pPekerjaan.setLeading(0, 1);

        PdfPCell cPekerjaan = new PdfPCell();
        cPekerjaan.setMinimumHeight(20);
        cPekerjaan.addElement(pPekerjaan);
        tabel7.addCell(cPekerjaan);

        Paragraph pJabatan = new Paragraph();
        pJabatan.add("  b. Jabatan : " + getJabatan());
        pJabatan.setLeading(0, 1);

        PdfPCell cJabatan = new PdfPCell();
        cJabatan.setMinimumHeight(20);
        cJabatan.addElement(pJabatan);
        tabel7.addCell(cJabatan);

        document.add(tabel7);
        //------------------------------------------------------------------------------------- PEKERJAAN END

        //------------------------------------------------------------------------------------- INSTANSI DLL
        PdfPTable tabel8 = new PdfPTable(1);
        tabel8.setWidthPercentage(100);

        Paragraph pInstansi = new Paragraph();
        pInstansi.add("     c. Instansi/Lembaga/Kantor : " + getInstansilembagakantor());
        pInstansi.setLeading(0, 1);

        PdfPCell cInstansi = new PdfPCell();
        cInstansi.setMinimumHeight(20);
        cInstansi.addElement(pInstansi);
        tabel8.addCell(cInstansi);

        document.add(tabel8);
        //------------------------------------------------------------------------------------- INSTANSI DLL END

        //------------------------------------------------------------------------------------- NAMA ISTRI
        float[] colomn = { 7, 1, 2 };
        PdfPTable tabel9 = new PdfPTable(colomn);
        tabel9.setWidthPercentage(100);

        Paragraph pNamaIstriBapakIbu = new Paragraph();
        pNamaIstriBapakIbu.add("10.");
        pNamaIstriBapakIbu.add("\n       a. Nama Istri : ");
        pNamaIstriBapakIbu.add("\n\n       b. Nama Bapak Istri : ");
        pNamaIstriBapakIbu.add("\n\n       c. Nama Ibu Istri : ");
        pNamaIstriBapakIbu.add("\n\n       d. Alamat : ");
        pNamaIstriBapakIbu.setLeading(0, 1);

        PdfPCell cNamaIstriBapakIbu = new PdfPCell();
        cNamaIstriBapakIbu.setMinimumHeight(110);
        cNamaIstriBapakIbu.addElement(pNamaIstriBapakIbu);
        tabel9.addCell(cNamaIstriBapakIbu);

        Paragraph pUmurIstriBapakIbu = new Paragraph();
        pUmurIstriBapakIbu.add("  Umur :");
        pUmurIstriBapakIbu.setLeading(0, 1);

        PdfPCell cUmurIstriBapakIbu = new PdfPCell();
        cUmurIstriBapakIbu.setMinimumHeight(110);
        cUmurIstriBapakIbu.addElement(pUmurIstriBapakIbu);
        tabel9.addCell(cUmurIstriBapakIbu);

        Paragraph pPekerjaanIstriBapakIbu = new Paragraph();
        pPekerjaanIstriBapakIbu.add("  Pekerjaan :");
        pPekerjaanIstriBapakIbu.setLeading(0, 1);

        PdfPCell cPekerjaanIstriBapakIbu = new PdfPCell();
        cPekerjaanIstriBapakIbu.setMinimumHeight(110);
        cPekerjaanIstriBapakIbu.addElement(pPekerjaanIstriBapakIbu);
        tabel9.addCell(cPekerjaanIstriBapakIbu);

        document.add(tabel9);
        //------------------------------------------------------------------------------------- NAMA ISTRI END

        //------------------------------------------------------------------------------------- SANAK SAUDARA
        PdfPTable tabel10 = new PdfPTable(colomn);
        tabel10.setWidthPercentage(100);

        Paragraph pSanakSaudara = new Paragraph();
        pSanakSaudara.add("11.  Nama Sanak/Saudara yang menjadi Tanggungan : \n       1.\n       2.");
        pSanakSaudara.setLeading(0, 1);

        PdfPCell cSanakSaudara = new PdfPCell();
        cSanakSaudara.addElement(pSanakSaudara);
        tabel10.addCell(cSanakSaudara);

        Paragraph pSanakSaudara1 = new Paragraph();
        pSanakSaudara1.add("");
        pSanakSaudara1.setLeading(0, 1);

        PdfPCell cSanakSaudara1 = new PdfPCell();
        cSanakSaudara1.addElement(pSanakSaudara1);
        tabel10.addCell(cSanakSaudara1);

        Paragraph pSanakSaudara2 = new Paragraph();
        pSanakSaudara2.add("");
        pSanakSaudara2.setLeading(0, 1);

        PdfPCell cSanakSaudara2 = new PdfPCell();
        cSanakSaudara2.addElement(pSanakSaudara2);
        tabel10.addCell(cSanakSaudara2);

        document.add(tabel10);
        //------------------------------------------------------------------------------------- SANAK SAUDARA END

        //------------------------------------------------------------------------------------- ANAK2
        PdfPTable tabel11 = new PdfPTable(colomn);
        tabel11.setWidthPercentage(100);

        Paragraph pAnak2 = new Paragraph();
        pAnak2.add("12.  Anak-anak : ");
        pAnak2.add("\n\n       1. ");
        pAnak2.add("\n\n       2. ");
        pAnak2.add("\n\n       3. ");
        pAnak2.add("\n\n       4. ");
        pAnak2.add("\n\n       5. ");
        pAnak2.add("\n\n       6. ");
        pAnak2.add("\n");
        pAnak2.setLeading(0, 1);

        PdfPCell cAnak2 = new PdfPCell();
        cAnak2.setMinimumHeight(165);
        cAnak2.addElement(pAnak2);
        tabel11.addCell(cAnak2);

        Paragraph pUmurAnak2 = new Paragraph();
        pUmurAnak2.add("  Umur : ");
        pUmurAnak2.setLeading(0, 1);

        PdfPCell cUmurAnak2 = new PdfPCell();
        cUmurAnak2.setMinimumHeight(165);
        cUmurAnak2.addElement(pUmurAnak2);
        tabel11.addCell(cUmurAnak2);

        Paragraph pPekarjaanAnak2 = new Paragraph();
        pPekarjaanAnak2.add("  Pekerjaan : ");
        pPekarjaanAnak2.setLeading(0, 1);

        PdfPCell cPekerjaanAnak2 = new PdfPCell();
        cPekerjaanAnak2.setMinimumHeight(165);
        cPekerjaanAnak2.addElement(pPekarjaanAnak2);
        tabel11.addCell(cPekerjaanAnak2);

        document.add(tabel11);
        //------------------------------------------------------------------------------------- ANAK2 END

        //------------------------------------------------------------------------------------- CIRI-CIRI
        PdfPTable tabel12 = new PdfPTable(1);
        tabel12.setWidthPercentage(100);

        Paragraph pCiri2 = new Paragraph();
        pCiri2.add("13.  Ciri-ciri badan : ");
        pCiri2.add("\n\n       1. Rambut : " + getRambut());
        for (int i = 0; i < (35 - getRambut().length()); i++) {
            pCiri2.add(" ");
        }
        pCiri2.add("2. Muka : " + getMuka());
        for (int i = 0; i < (35 - getMuka().length()); i++) {
            pCiri2.add(" ");
        }
        pCiri2.add("3. Kulit : " + getKulit());
        pCiri2.setLeading(0, 1);

        PdfPCell cCiri2 = new PdfPCell();
        cCiri2.setMinimumHeight(45);
        cCiri2.addElement(pCiri2);
        tabel12.addCell(cCiri2);

        document.add(tabel12);
        //------------------------------------------------------------------------------------- CIRI-CIRI END

        //------------------------------------------------------------------------------------- LANJUTAN CIRI2
        PdfPTable tabel13 = new PdfPTable(1);
        tabel13.setWidthPercentage(100);

        Paragraph pCiri2Lanjutan = new Paragraph();
        for (int i = 0; i < 20; i++) {
            pCiri2Lanjutan.add(" ");
        }
        pCiri2Lanjutan.add("4.  Tinggi : " + getTinggi());
        for (int i = 0; i < (35 - getTinggi().length()); i++) {
            pCiri2Lanjutan.add(" ");
        }
        pCiri2Lanjutan.add("5.  Tanda Istimewa : " + getTandaistimewa());
        pCiri2Lanjutan.setLeading(0, 1);

        PdfPCell cCiri2Lanjutan = new PdfPCell();
        cCiri2Lanjutan.setMinimumHeight(20);
        cCiri2Lanjutan.addElement(pCiri2Lanjutan);
        tabel13.addCell(cCiri2Lanjutan);

        document.add(tabel13);
        //------------------------------------------------------------------------------------- LANJUTAN CIRI2

        //------------------------------------------------------------------------------------- RUMUS SIDIK JARI
        PdfPTable tabel14 = new PdfPTable(1);
        tabel14.setWidthPercentage(100);

        Paragraph pSidikJari = new Paragraph();
        pSidikJari.add("14.  Rumus Sidik Jari : " + getRumussidikjari());
        pSidikJari.setLeading(0, 1);

        PdfPCell cSidikJari = new PdfPCell();
        cSidikJari.setMinimumHeight(20);
        cSidikJari.addElement(pSidikJari);
        tabel14.addCell(cSidikJari);

        document.add(tabel14);
        //------------------------------------------------------------------------------------- RUMUS SIDIK JARI END

        //------------------------------------------------------------------------------------- RIWAYAT SEKOLAH
        float[] colom = { 8, 2 };
        PdfPTable tabel15 = new PdfPTable(colom);
        tabel15.setWidthPercentage(100);

        Paragraph pRiwayatSekolah = new Paragraph();
        pRiwayatSekolah.add("15.  Riwayat Sekolah : ");
        pRiwayatSekolah.add("\n\n       1. ");
        pRiwayatSekolah.add("\n\n       2. ");
        pRiwayatSekolah.add("\n\n       3. ");
        pRiwayatSekolah.add("\n\n       4. ");
        pRiwayatSekolah.add("\n\n       5. ");
        pRiwayatSekolah.add("\n\n       6. ");
        pRiwayatSekolah.setLeading(0, 1);

        PdfPCell cRiwayatSekolah = new PdfPCell();
        cRiwayatSekolah.setMinimumHeight(165);
        cRiwayatSekolah.addElement(pRiwayatSekolah);
        tabel15.addCell(cRiwayatSekolah);

        Paragraph pTahunLulus = new Paragraph();
        pTahunLulus.add("Tahun Lulus");
        pTahunLulus.setLeading(0, 1);

        PdfPCell cTahunLulus = new PdfPCell();
        cTahunLulus.setMinimumHeight(165);
        cTahunLulus.addElement(pTahunLulus);
        tabel15.addCell(cTahunLulus);

        document.add(tabel15);
        //------------------------------------------------------------------------------------- RIWAYAT SEKOLAH END

        //------------------------------------------------------------------------------------- KESENANGAN/KEGEMARAN/HOBI
        PdfPTable tabel16 = new PdfPTable(1);
        tabel16.setWidthPercentage(100);

        Paragraph pKesenenanganKegemaranHobi = new Paragraph();
        pKesenenanganKegemaranHobi.add("16.  Kesenangan/Kegemaran/Hobi : " + getHobi());
        pKesenenanganKegemaranHobi.setLeading(0, 1);

        PdfPCell cKesenenanganKegemaranHobi = new PdfPCell();
        cKesenenanganKegemaranHobi.setMinimumHeight(20);
        cKesenenanganKegemaranHobi.addElement(pKesenenanganKegemaranHobi);
        tabel16.addCell(cKesenenanganKegemaranHobi);

        document.add(tabel16);
        //------------------------------------------------------------------------------------- KESENANGAN/KEGEMARAN/HOBI END

        //------------------------------------------------------------------------------------- CATATAN KRIMINAL
        PdfPTable tabel17 = new PdfPTable(1);
        tabel17.setWidthPercentage(100);

        Paragraph pCatatanKriminal = new Paragraph();
        pCatatanKriminal.add("17.  Catatan kriminal yang ada : ");
        pCatatanKriminal.add("\n\n       1. " + getCatatankriminal1());
        pCatatanKriminal.add("\n\n       2. " + getCatatankriminal2());
        pCatatanKriminal.add("\n\n       3. " + getCatatankriminal3());
        pCatatanKriminal.setLeading(0, 1);

        PdfPCell cCatatanKriminal = new PdfPCell();
        cCatatanKriminal.setMinimumHeight(95);
        cCatatanKriminal.addElement(pCatatanKriminal);
        tabel17.addCell(cCatatanKriminal);

        document.add(tabel17);
        //------------------------------------------------------------------------------------- CATATAN KRIMINAL END

        //------------------------------------------------------------------------------------- KETERANGAN DLL
        PdfPTable tabel18 = new PdfPTable(1);
        tabel18.setWidthPercentage(100);

        Paragraph pDataKeteranganLain2 = new Paragraph();
        pDataKeteranganLain2.add("18.  Data Keterangan dan lain2 : ");
        pDataKeteranganLain2.add("\n\n\n");
        pDataKeteranganLain2.setLeading(0, 1);

        PdfPCell cDataKeteranganLain2 = new PdfPCell();
        cDataKeteranganLain2.addElement(pDataKeteranganLain2);

        if (list.size() > 0) {
            float[] kolomkegiatan = { 8, 2 };
            PdfPTable nestedTable = new PdfPTable(kolomkegiatan);

            nestedTable.addCell(new Paragraph("Kegiatan"));
            nestedTable.addCell(new Paragraph("Tanggal"));

            for (int i = 0; i < list.size(); i++) {
                nestedTable.addCell(new Paragraph(list.get(i).getNamakegiatan()));
                nestedTable.addCell(new Paragraph(list.get(i).getTanggal()));
            }

            cDataKeteranganLain2.addElement(nestedTable);
            cDataKeteranganLain2.setPaddingBottom(20f);
            tabel18.addCell(cDataKeteranganLain2);
        }

        document.add(tabel18);
        //------------------------------------------------------------------------------------- KETERANGAN DLL END

        document.close();

    } catch (DocumentException e) {
        e.printStackTrace();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return output;
}

From source file:windows.wzListWindow.java

private void printDocActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_printDocActionPerformed
    Document document = new Document();
    Footer ft = new Footer();
    companyAdress comp = new companyAdress();

    try {/*from  w w  w. ja va2  s. c om*/
        BaseFont ft1 = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.EMBEDDED);
        Font ffont = new Font(ft1, 12);

        BaseFont ft3 = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.EMBEDDED);
        Font bold = new Font(ft1, 12, Font.BOLD);
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("test.pdf"));
        document.open();
        Paragraph pr = new Paragraph();
        pr.setFont(ffont);
        writer.setPageEvent(ft);
        ContractorEntity contractor = wz
                .getContractor(Integer.valueOf(WZTable.getValueAt(WZTable.getSelectedRow(), 2).toString()));
        pr.add(WZTable.getValueAt(WZTable.getSelectedRow(), 4).toString());
        pr.setAlignment(Element.ALIGN_RIGHT);
        document.add(pr);
        pr.clear();
        if ("SPRZT WYDANY".equals(WZTable.getValueAt(WZTable.getSelectedRow(), 11).toString())) {
            Paragraph nr = new Paragraph("WYADNIE SPRZTU NR ", ffont);
            String yearSlashnr = WZTable.getValueAt(WZTable.getSelectedRow(), 1).toString();
            nr.add(new Chunk(yearSlashnr, bold));
            nr.setAlignment(Element.ALIGN_LEFT);
            document.add(nr);
            if ("WS".equals(WZTable.getValueAt(WZTable.getSelectedRow(), 12).toString())) {
                pr.setAlignment(Element.ALIGN_LEFT);
                DocEntity docPS = wz.getDocument(wz.getPSForWs(
                        Integer.valueOf(WZTable.getValueAt(WZTable.getSelectedRow(), 0).toString())));
                pr.add("DOTYCZY: PS NR " + docPS.getDocNumber());
                document.add(pr);
                pr.clear();
                pr.setAlignment(Element.ALIGN_RIGHT);
            }
        }

        if ("SPRZT PRZYJTY".equals(WZTable.getValueAt(WZTable.getSelectedRow(), 11).toString())) {
            int rok = Timestamp.valueOf(WZTable.getValueAt(WZTable.getSelectedRow(), 4).toString()).getYear()
                    + 1900;
            Paragraph nr = new Paragraph("PRZYJCIE SPRZTU NR ", ffont);
            String yearSlashnr = rok + "/" + WZTable.getValueAt(WZTable.getSelectedRow(), 1).toString();
            nr.add(new Chunk(yearSlashnr, bold));
            nr.setAlignment(Element.ALIGN_LEFT);
            document.add(nr);
        }
        pr.clear();
        pr.add(Chunk.NEWLINE);
        pr.add(Chunk.NEWLINE);
        document.add(pr);
        pr.clear();
        pr.setAlignment(Element.ALIGN_LEFT);
        pr.add(comp.getName());
        pr.add(Chunk.NEWLINE);
        pr.add("ul. " + comp.getStreet());
        pr.add(Chunk.NEWLINE);
        pr.add(comp.getPostal() + " " + comp.getCity());
        pr.add(Chunk.NEWLINE);
        pr.add("NIP: " + comp.getNip());
        pr.add(Chunk.NEWLINE);
        pr.add("Tel: " + comp.getPhone());
        pr.add(Chunk.NEWLINE);
        pr.add("Fax: " + comp.getFax());
        pr.add(Chunk.NEWLINE);
        pr.add("E-mail: " + comp.getEmail());
        pr.add(Chunk.NEWLINE);
        pr.add(Chunk.NEWLINE);
        pr.add("KLIENT:");
        pr.add(Chunk.NEWLINE);
        pr.add(contractor.getName());
        pr.add(Chunk.NEWLINE);
        pr.add("ul. " + contractor.getStreet());
        pr.add(Chunk.NEWLINE);
        pr.add(contractor.getPostalCode() + " " + contractor.getCity());
        pr.add(Chunk.NEWLINE);
        pr.add("NIP: " + contractor.getNip());
        pr.add(Chunk.NEWLINE);
        pr.add("Tel: " + contractor.getPhone());
        pr.add(Chunk.NEWLINE);
        pr.add("E-mail: " + contractor.getEmail());
        document.add(pr);

        pr.clear();
        pr.add(Chunk.NEWLINE);
        pr.add(Chunk.NEWLINE);
        pr.add("PRZYJTE URZDZENIA:");
        document.add(pr);

        //PUT IMAGE FROM DRIVE
        java.awt.Image awtImage = Toolkit.getDefaultToolkit().createImage("C:/GIT/support/logo.jpg");
        Image img = com.itextpdf.text.Image.getInstance(awtImage, null);
        int indentation = 0;
        float scaler = ((document.getPageSize().getWidth() - document.leftMargin() - document.rightMargin()
                - indentation) / img.getWidth()) * 20;
        img.scalePercent(scaler);
        img.setAbsolutePosition(document.right() - 90, document.top() - 150);
        document.add(new Paragraph());
        document.add(img);

        //ADD TABLE

        PdfPTable table = new PdfPTable(7); // 3 columns.
        table.setWidthPercentage(100); //Width 100%
        table.setSpacingBefore(10f); //Space before table
        table.setSpacingAfter(10f); //Space after table
        //Set Column widths
        float[] columnWidths = { 1f, 4f, 3f, 2f, 2f, 6f, 6f };
        table.setWidths(columnWidths);
        BaseFont ft2 = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.EMBEDDED);
        Font headerFont = new Font(ft2, 9);
        Paragraph pos1 = new Paragraph("", headerFont);
        Paragraph pos2 = new Paragraph("", headerFont);
        Paragraph pos3 = new Paragraph("", headerFont);
        Paragraph pos4 = new Paragraph("", headerFont);
        Paragraph pos5 = new Paragraph("", headerFont);
        Paragraph pos6 = new Paragraph("", headerFont);
        Paragraph pos7 = new Paragraph("", headerFont);

        //FORMATING TABLE
        pos1.clear();
        pos1.add("LP");
        PdfPCell cell1 = new PdfPCell(pos1);
        cell1.setBorderColor(BaseColor.BLACK);
        cell1.setBackgroundColor(BaseColor.LIGHT_GRAY);
        cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell1.setVerticalAlignment(Element.ALIGN_MIDDLE);
        table.addCell(cell1);
        pos2.clear();
        pos2.add("NAZWA");
        PdfPCell cell2 = new PdfPCell(pos2);
        cell2.setBorderColor(BaseColor.BLACK);
        cell2.setBackgroundColor(BaseColor.LIGHT_GRAY);
        cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell2.setVerticalAlignment(Element.ALIGN_MIDDLE);
        table.addCell(cell2);
        pos3.clear();
        pos3.add("NR SERYJNY");
        PdfPCell cell3 = new PdfPCell(pos3);
        cell3.setBorderColor(BaseColor.BLACK);
        cell3.setBackgroundColor(BaseColor.LIGHT_GRAY);
        cell3.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell3.setVerticalAlignment(Element.ALIGN_MIDDLE);
        table.addCell(cell3);
        pos4.clear();
        pos4.add("CENA NETTO");
        PdfPCell cell4 = new PdfPCell(pos4);
        cell4.setBorderColor(BaseColor.BLACK);
        cell4.setBackgroundColor(BaseColor.LIGHT_GRAY);
        cell4.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell4.setVerticalAlignment(Element.ALIGN_MIDDLE);
        table.addCell(cell4);
        pos5.clear();
        pos5.add("CENA BRUTTO");
        PdfPCell cell5 = new PdfPCell(pos5);
        cell5.setBorderColor(BaseColor.BLACK);
        cell5.setBackgroundColor(BaseColor.LIGHT_GRAY);
        cell5.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell5.setVerticalAlignment(Element.ALIGN_MIDDLE);
        table.addCell(cell5);
        pos6.clear();
        pos6.add("PROBLEM");
        PdfPCell cell6 = new PdfPCell(pos6);
        cell6.setBorderColor(BaseColor.BLACK);
        cell6.setBackgroundColor(BaseColor.LIGHT_GRAY);
        cell6.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell6.setVerticalAlignment(Element.ALIGN_MIDDLE);
        table.addCell(cell6);
        pos7.clear();
        pos7.add("NAPRAWA");
        PdfPCell cell7 = new PdfPCell(pos7);
        cell7.setBorderColor(BaseColor.BLACK);
        cell7.setBackgroundColor(BaseColor.LIGHT_GRAY);
        cell7.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell7.setVerticalAlignment(Element.ALIGN_MIDDLE);
        table.addCell(cell7);

        cell2.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell3.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell4.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell5.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell6.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell7.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell1.setBackgroundColor(BaseColor.WHITE);
        cell2.setBackgroundColor(BaseColor.WHITE);
        cell3.setBackgroundColor(BaseColor.WHITE);
        cell4.setBackgroundColor(BaseColor.WHITE);
        cell5.setBackgroundColor(BaseColor.WHITE);
        cell6.setBackgroundColor(BaseColor.WHITE);
        cell7.setBackgroundColor(BaseColor.WHITE);
        int counter = 1;
        for (DocProductEntity prod : productToShow) {
            //col 1 (LP)
            table.addCell(createCell("" + counter, Element.ALIGN_CENTER));
            counter++;
            //col 2 (NAME)
            table.addCell(createCell(prod.getName(), Element.ALIGN_LEFT));
            //col 3 (NR SER)
            table.addCell(createCell(prod.getSerial(), Element.ALIGN_CENTER));
            //col 4 (NETTO)
            table.addCell(createCell(String.valueOf(prod.getPrice()), Element.ALIGN_RIGHT));
            //col 5 (BRUTTO)
            table.addCell(createCell(String.valueOf(prod.getPrice() + (prod.getPrice() * 0.23)),
                    Element.ALIGN_RIGHT));
            //col 6 (PROBLEM)
            table.addCell(createCell(prod.getProblem(), Element.ALIGN_LEFT));
            //col 7 (REPAIRS)
            table.addCell(createCell(prod.getRepair(), Element.ALIGN_LEFT));
        }
        document.add(table);
        pr.setAlignment(Element.ALIGN_RIGHT);
        pr.clear();
        pr.add("PRZEWIDYWANIY KOSZT NAPRAWY:");
        document.add(pr);
        pr.clear();
        pr.add("Razem netto: " + nettoLabel.getText() + " Razem brutto: " + bruttoLabel.getText());
        document.add(pr);
        pr.clear();
        pr.add("Sownie: " + amountInWords(Float.valueOf(bruttoLabel.getText().replace(",", "."))));
        document.add(pr);
        pr.clear();
        document.add(Chunk.NEWLINE);
        document.add(Chunk.NEWLINE);
        document.add(Chunk.NEWLINE);
        pr.add(".................................................");
        document.add(pr);
        pr.clear();
        pr.add("Podpis i piecztka pracownika");
        document.add(pr);
        if ("SPRZT WYDANY".equals(WZTable.getValueAt(WZTable.getSelectedRow(), 11).toString())) {
            pr.clear();
            pr.add(Chunk.NEWLINE);
            pr.add(Chunk.NEWLINE);
            pr.add(".................................................");
            document.add(pr);
            pr.clear();
            pr.add("Sprzt odebraem (Podpis klienta)");
            document.add(pr);
        }
        //CLOSING DOCUMENT
        document.close();
        writer.close();

    } catch (DocumentException e) {
        e.printStackTrace();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    try {
        StampPageXofY numeration = new StampPageXofY();
        tempName = nowTimestamp();
        numeration.manipulatePdf("test.pdf", tempName + ".pdf");
    } catch (IOException ex) {
        Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex);
    } catch (DocumentException ex) {
        Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex);
    }
    //OPEN READY DOCUMENT
    try {
        Desktop.getDesktop().open(new File(tempName + ".pdf"));
    } catch (IOException ex) {
        Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:zeugnis.ZeugnisPDF.java

/**
* Erzeugt das Zeugnis PDF in einem definierten Ordner
* @throws IOException//from w  w  w.  j  a v a2s .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();
}