Example usage for com.itextpdf.text Rectangle Rectangle

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

Introduction

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

Prototype

public Rectangle(com.itextpdf.awt.geom.Rectangle rect) 

Source Link

Document

Constructs a Rectangle-object based on a com.itextpdf.awt.geom.Rectangle object

Usage

From source file:com.isdemu.controller.BarCode128.java

public static void main(String[] args) throws FileNotFoundException, DocumentException {

    Document document = new Document(new Rectangle(PageSize.A4));
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("c:/Java4s_BarCode_128.pdf"));

    document.open();/* w w  w  . j  av a2  s  .co m*/
    document.add(new Paragraph("Code_128 Format_Java4s.com"));

    Barcode128 code128 = new Barcode128();
    code128.setGenerateChecksum(true);
    code128.setCode("1234554321");

    document.add(code128.createImageWithBarcode(writer.getDirectContent(), null, null));
    document.close();

    System.out.println("Document Generated...!!!!!!");
}

From source file:com.vectorprint.report.itext.EventHelper.java

License:Open Source License

/**
 * Calls the super and {@link Advanced#draw(com.itextpdf.text.Rectangle, java.lang.String) } for each Advanced styler
 * registered. Adds a debugging link for images when in debug mode.
 *
 * @param writer/*w w  w.  j  a va2s. co m*/
 * @param document
 * @param rect
 * @param genericTag
 * @see #addDelayedStyler(java.lang.String, java.util.Collection, com.itextpdf.text.Chunk) 
 * @see Advanced#addDelayedData(java.lang.String, com.itextpdf.text.Chunk)
 * @see VectorPrintDocument
 */
@Override
public final void onGenericTag(PdfWriter writer, Document document, final Rectangle rect, String genericTag) {
    //      if (log.isLoggable(Level.FINE)) {
    //         Collection<Advanced> av = doOnGenericTag.get(genericTag);
    //         String data = null;
    //         if (av!=null) {
    //            for (Advanced a : av) {
    //               data += a.getDelayed(genericTag).getDataPart();
    //               break;
    //            }
    //         }
    //         System.out.println("wrapped: " + carriageReturns.toString() + ", " + genericTag + " " + data + " " + rect.toString() + ", x=" + rect.getLeft());
    //      }
    if (doOnGenericTag.get(genericTag) != null && !genericTag.startsWith(VectorPrintDocument.DRAWNEAR)
            && !genericTag.startsWith(VectorPrintDocument.DRAWSHADOW)) {
        int i = -1;
        for (Advanced a : doOnGenericTag.get(genericTag)) {
            ++i;
            if (genericTag.startsWith(DefaultElementProducer.ADV) && Integer
                    .parseInt(genericTag.replace(DefaultElementProducer.ADV, "")) > maxTagForGenericTagOnPage) {
                continue;
            }
            try {
                if (a.shouldDraw(a.getDelayed(genericTag).getData())) {
                    if (a instanceof DebugStyler && imageChunks.containsKey(genericTag)) {
                        Chunk wrapper = imageChunks.get(genericTag);
                        Object[] atts = (Object[]) wrapper.getAttributes().get(Chunk.IMAGE);
                        Rectangle shifted = new Rectangle(rect);
                        shifted.setLeft(shifted.getLeft() + (Float) atts[1]);
                        shifted.setRight(shifted.getRight() + (Float) atts[1]);
                        shifted.setTop(shifted.getTop() + (Float) atts[2]);
                        shifted.setBottom(shifted.getBottom() + (Float) atts[2]);
                        a.draw(shifted, genericTag);
                    } else if (!genericTag.startsWith(VectorPrintDocument.IMG_DEBUG)) {
                        a.draw(rect, genericTag);
                    }
                }
            } catch (VectorPrintException ex) {
                throw new VectorPrintRuntimeException(ex);
            }
        }
    }
    // images
    if (genericTag.startsWith(VectorPrintDocument.IMG_DEBUG)
            && getSettings().getBooleanProperty(false, DEBUG)) {
        // only now we can define a goto action, we know the position of the image
        if (rectangles.containsKey(genericTag)) {
            Rectangle rectangle = imageRectFromChunk(genericTag, rect);
            DebugHelper.debugAnnotation(rectangle, genericTag.replaceFirst(VectorPrintDocument.IMG_DEBUG, ""),
                    writer);
        } else {
            DebugHelper.debugAnnotation(rect, genericTag.replaceFirst(VectorPrintDocument.IMG_DEBUG, ""),
                    writer);
        }
    }
    if (genericTag.startsWith(VectorPrintDocument.DRAWNEAR)) {
        Rectangle rectangle = imageRectFromChunk(genericTag, rect);
        com.vectorprint.report.itext.style.stylers.Image image = (com.vectorprint.report.itext.style.stylers.Image) doOnGenericTag
                .get(genericTag).iterator().next();
        short i = -1;
        for (Advanced a : doOnGenericTag.get(genericTag)) {
            try {
                if (++i > 0 && a.shouldDraw(a.getDelayed(genericTag).getData())) {
                    if (getSettings().getBooleanProperty(false, DEBUG)) {
                        DebugHelper.styleLink(writer.getDirectContent(), a.getStyleClass(), "draw near",
                                rectangle.getLeft(), rectangle.getTop(), getSettings(), elementProducer);
                    }
                    a.draw(rectangle, genericTag);
                }
            } catch (VectorPrintException ex) {
                throw new VectorPrintRuntimeException(ex);
            }

        }
    }
    if (genericTag.startsWith(VectorPrintDocument.DRAWSHADOW)) {
        // we know the position of the image
        Rectangle r = imageRectFromChunk(genericTag, rect);
        com.vectorprint.report.itext.style.stylers.Image image = (com.vectorprint.report.itext.style.stylers.Image) doOnGenericTag
                .get(genericTag).iterator().next();
        try {
            image.drawShadow(r.getLeft(), r.getBottom(), r.getWidth(), r.getHeight(),
                    genericTag.replaceFirst(VectorPrintDocument.DRAWSHADOW, ""));
        } catch (VectorPrintException ex) {
            throw new VectorPrintRuntimeException(ex);
        }
    }
}

From source file:com.vectorprint.report.itext.style.stylers.SimpleColumns.java

License:Open Source License

/**
 * writes out content taking into account the current vertical position in the document and making sure that the next
 * call to {@link Document#add(com.itextpdf.text.Element)} will start at the correct vertical position.
 *
 * @see #getSpaceBefore()/* w w w .j  ava 2 s.c o  m*/
 * @see #getSpaceAfter()
 *
 * @param last when true space will be appended to start adding content at the correct position after the columns
 * @throws DocumentException
 */
public SimpleColumns write(boolean last) throws DocumentException {
    int status = ColumnText.START_COLUMN;
    ct.setSimpleColumn(columns.get(column));
    if (firstWrite) {
        float top = getWriter().getVerticalPosition(false) > getTop() ? getTop()
                : getWriter().getVerticalPosition(false);
        pageTop = minY = top - getValue(Spacing.SPACEBEFOREPARAM, Float.class);
        ct.setYLine(pageTop);
        firstWrite = false;
        if (log.isLoggable(Level.FINE)) {
            log.fine(String.format("first write of columns top for content determined: %s",
                    top - getValue(Spacing.SPACEBEFOREPARAM, Float.class)));
        }
    } else {
        if (log.isLoggable(Level.FINE)) {
            log.fine(String.format("following write of columns, using current top for content: %s", currentY));
        }
        ct.setYLine(currentY);
    }
    while (ColumnText.hasMoreText(status)) {
        if (getSettings().getBooleanProperty(Boolean.FALSE, ReportConstants.DEBUG)) {
            Rectangle rect = new Rectangle(columns.get(column));
            rect.setTop(ct.getYLine());
            DebugHelper.debugRect(ct.getCanvas(), rect, new float[] { 2, 2 }, 0.3f, getSettings(),
                    elementProducer);
        }
        status = ct.go();
        currentY = ct.getYLine();
        if (ct.getYLine() < minY) {
            minY = ct.getYLine();
        }
        if (ColumnText.hasMoreText(status)) {
            if (column == getNumColumns() - 1) {
                column = 0;
                getDocument().newPage();
                minY = pageTop = currentY = getTop();
                if (log.isLoggable(Level.FINE)) {
                    log.fine(String.format("starting next page for columns"));
                }
            } else {
                column++;
                if (log.isLoggable(Level.FINE)) {
                    log.fine(String.format("going to column %s", column));
                }
            }
            ct.setSimpleColumn(columns.get(column));
            ct.setYLine(pageTop);
        } else {
            contentWritten = addedContent;
            if (log.isLoggable(Level.FINE)) {
                log.fine(String.format("column content written %s", addedContent));
            }
        }
    }
    if (last) {
        float space = (pageTop - minY < getBottom())
                ? getBottom() + getValue(Spacing.SPACEAFTERPARAM, Float.class)
                : pageTop - minY + getValue(Spacing.SPACEAFTERPARAM, Float.class);
        // add necessary spacing, space otherwise ignored!
        if (log.isLoggable(Level.FINE)) {
            log.fine(String.format("appending %s mm to start following content at the correct position",
                    ItextHelper.ptsToMm(space)));
        }
        Paragraph p = new Paragraph(" ");
        p.setSpacingAfter(space);
        getDocument().add(p);
    }
    return this;
}

From source file:eeebees.BarCode128.java

public static void main(String[] args) throws FileNotFoundException, DocumentException {

    Document document = new Document(new Rectangle(PageSize.A4));
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("D:/Java4s_BarCode_128.pdf"));

    document.open();//  ww  w .  j  ava 2 s.  com
    document.add(new Paragraph("Code_128 Format_Java4s.com"));

    Barcode128 code128 = new Barcode128();
    code128.setGenerateChecksum(true);
    code128.setCode("1234554321");

    document.add(code128.createImageWithBarcode(writer.getDirectContent(), null, null));
    document.close();

    System.out.println("Document Generated...!!!!!!");
}

From source file:ExternalNonFormClasses.PDFEnator.java

public void createPDF() {
    try {//from w  w  w.j av  a 2  s . c om
        Rectangle one = new Rectangle(PageSize.LETTER);
        Document doc = new Document(one);
        PdfWriter writer = PdfWriter.getInstance(doc,
                new FileOutputStream(getDirectory() + "\\" + data_title + ".pdf"));
        //doc.setMargins(1, 1, 1, 1);
        doc.open();
        PdfContentByte canvas = writer.getDirectContent();
        Font font = new Font(Font.FontFamily.TIMES_ROMAN, 11);
        x = one.getWidth();
        y = one.getHeight();
        tableX = (x / 2) - 235;
        tableY = y - 180;

        getHeader();
        Paragraph para = new Paragraph("Province of " + formHeaderValues[0], font);
        para.setAlignment(Element.ALIGN_CENTER);
        doc.add(para);
        Paragraph para2 = new Paragraph("City/Municipality of " + formHeaderValues[1], font);
        para2.setAlignment(Element.ALIGN_CENTER);
        doc.add(para2);
        Paragraph para3 = new Paragraph("Barangay " + formHeaderValues[2], font);
        para3.setAlignment(Element.ALIGN_CENTER);
        doc.add(para3);
        doc.add(Chunk.NEWLINE);
        doc.add(Chunk.NEWLINE);
        Paragraph para4 = new Paragraph(data_title, font);
        para4.setAlignment(Element.ALIGN_CENTER);
        doc.add(para4);

        PdfPTable pdftable;

        pdftable = writeHeaders(font);

        //pdftable.writeSelectedRows(0, -1, (x / 2) - 235, y - 180, canvas);
        int counter = 1, rowCounter = 0, columnCounter = 0;
        int yIncrementor = 16;
        boolean test = true;
        while (counter <= this.totalDataSize) {
            //System.out.println("data#: " + counter + "@ (" + rowCounter + "," + (columnCounter) + ") = " + this.table.getValueAt(rowCounter, columnCounter).toString());
            PdfPCell cell1 = new PdfPCell(
                    new Paragraph(this.table.getValueAt(rowCounter, columnCounter++).toString(), font));
            cell1.setPaddingBottom(5);
            cell1.setHorizontalAlignment(Element.ALIGN_LEFT);
            pdftable.addCell(cell1);

            if (counter > 0 && (counter % column) == 0) { //if there are 4 columns
                //pdftable.writeSelectedRows(0, -1, (x / 2) - 235, (y - 180) - yIncrementor, canvas); //print row of 4 columns
                yIncrementor += 16; //move to next row coordinate, so y coordinate plus plus
                rowCounter++; //move to next row
                columnCounter = 0; //back to start column
                boolean newPage = false;

                if ((tableY - ((yIncrementor - 16) + 80)) <= 72) { //if it exceeds 1 inch in footer, new page
                    //                        System.out.println("(" + tableY + "-((" + yIncrementor + "-16)+" + 16 + "))");
                    //                        System.out.println("Nanobra? YES; " + (tableY - ((yIncrementor - 16) + 16)));
                    newPage = true;
                } else if ((tableY - (yIncrementor + 80)) <= 72) {
                    //                        System.out.println("(" + tableY + "-(" + yIncrementor + "+" + 16 + "))");
                    //                        System.out.println("Nanobra? YES; " + (tableY - (yIncrementor + 16)));
                    newPage = true;
                }

                if (newPage) {
                    pdftable.completeRow();
                    pdftable.writeSelectedRows(0, -1, tableX, tableY, canvas); //print the data for the current page
                    doc.newPage(); //create new page
                    pdftable = writeHeaders(font); //write headers to new page
                    yIncrementor = 16; //restore default
                }
            }

            //                if (counter == this.totalDataSize) { //para lng mudouble ang data
            //                    if (test) {
            //                        test = false;
            //                        counter = 0;
            //                        rowCounter = 0;
            //                        columnCounter = 0;
            //                    }
            //                } else if (counter == this.totalDataSize) {
            //                    if (!test) {
            //                        break;
            //                    }
            //                }
            counter++;
        }
        pdftable.completeRow();
        pdftable.writeSelectedRows(0, -1, tableX, tableY, canvas);
        doc.close();

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

}

From source file:ExternalNonFormClasses.PDFEnator.java

public void createProfilePDF(String id, ArrayList<String> data) {
    this.data_title = "Citizen Profile";
    this.table = null;
    this.caller = 4;
    this.row = 17;
    this.column = 2;
    this.personID = id;
    this.totalDataSize = row * column;
    tableHeaderData = new ArrayList<>();
    tableHeaderData.add("Label");
    tableHeaderData.add("Information");

    ArrayList<String> dataAll = data;

    try {/*from  w w w. j  a v  a 2s .co  m*/
        getHeader();
        Document doc = new Document();
        PdfWriter writer = PdfWriter.getInstance(doc,
                new FileOutputStream(getDirectory() + "\\" + data_title + ".pdf"));
        Rectangle one = new Rectangle(PageSize.LETTER);
        doc.setPageSize(one);
        //doc.setMargins(1, 1, 1, 1);
        doc.open();
        PdfContentByte canvas = writer.getDirectContent();
        Font font = new Font(Font.FontFamily.TIMES_ROMAN, 11);
        x = one.getWidth();
        y = one.getHeight();
        tableX = (x / 2) - 235;
        tableY = y - 180;

        Paragraph para = new Paragraph("Province of " + formHeaderValues[0], font);
        para.setAlignment(Element.ALIGN_CENTER);
        doc.add(para);
        Paragraph para2 = new Paragraph("City/Municipality of " + formHeaderValues[1], font);
        para2.setAlignment(Element.ALIGN_CENTER);
        doc.add(para2);
        Paragraph para3 = new Paragraph("Barangay " + formHeaderValues[2], font);
        para3.setAlignment(Element.ALIGN_CENTER);
        doc.add(para3);
        Paragraph para4 = new Paragraph(data_title, font);
        para4.setAlignment(Element.ALIGN_CENTER);
        doc.add(para4);

        PdfPTable pdftable;
        pdftable = writeHeaders(font);
        int counter = 1, rowCounter = 0, columnCounter = 0;
        int yIncrementor = 16;
        String label = null, value = null;
        System.out.println(dataAll.size());
        while (counter <= this.row) {
            switch (counter - 1) {
            case 0:
                label = "Citizen ID";
                value = id;
                break;
            case 1:
                label = "Last Name";
                value = dataAll.get(counter - 2);
                break;
            case 2:
                label = "First Name";
                value = dataAll.get(counter - 2);
                break;
            case 3:
                label = "Middle Name";
                value = dataAll.get(counter - 2);
                break;
            case 4:
                label = "Name Suffix";
                value = dataAll.get(counter - 2);
                break;
            case 5:
                label = "Date of Birth";
                value = dataAll.get(counter - 2);
                break;
            case 6:
                label = "Gender";
                value = dataAll.get(counter - 2);
                break;
            case 7:
                label = "Address";
                value = dataAll.get(counter - 2);
                break;
            case 8:
                label = "Age";
                value = dataAll.get(counter - 2);
                break;
            case 9:
                label = "Place of Birth";
                value = dataAll.get(counter - 2);
                break;
            case 10:
                label = "Civil Status";
                value = dataAll.get(counter - 2);
                break;
            case 11:
                label = "Contact";
                value = dataAll.get(counter - 2);
                break;
            case 12:
                label = "Zip Code";
                value = dataAll.get(counter - 2);
                break;
            case 13:
                label = "Precinct Number";
                value = dataAll.get(counter - 2);
                break;
            case 14:
                label = "Occupation";
                value = dataAll.get(counter - 2);
                break;
            case 15:
                label = "Email Address";
                value = dataAll.get(counter - 2);
                break;
            case 16:
                label = "Religion";
                value = dataAll.get(counter - 2);
                break;
            }
            if (value.length() <= 0) {
                value = "N/A";
            }

            System.out.println(label + ": " + value);
            PdfPCell cell1 = new PdfPCell(new Paragraph(label, font));
            cell1.setPaddingBottom(5);
            cell1.setHorizontalAlignment(Element.ALIGN_LEFT);
            pdftable.addCell(cell1);

            PdfPCell cell2 = new PdfPCell(new Paragraph(value, font));
            cell2.setPaddingBottom(5);
            cell2.setHorizontalAlignment(Element.ALIGN_LEFT);
            pdftable.addCell(cell2);

            if (counter > 0 && (counter % column) == 0) { //if there are 4 columns
                yIncrementor += 16; //move to next row coordinate, so y coordinate plus plus
                rowCounter++; //move to next row
                columnCounter = 0; //back to start column
                boolean newPage = false;

                if ((tableY - ((yIncrementor - 16) + 80)) <= 72 || (tableY - (yIncrementor + 80)) <= 72) { //if it exceeds 1 inch in footer, new page
                    newPage = true;
                }

                if (newPage) {
                    pdftable.completeRow();
                    pdftable.writeSelectedRows(0, -1, tableX, tableY, canvas); //print the data for the current page
                    doc.newPage(); //create new page
                    pdftable = writeHeaders(font); //write headers to new page
                    yIncrementor = 16; //restore default
                }
            }
            counter++;
        }
        pdftable.completeRow();
        pdftable.writeSelectedRows(0, -1, tableX, tableY, canvas);
        doc.close();

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

}

From source file:mkl.testarea.itext5.pdfcleanup.PdfCleanUpRegionFilter.java

License:Open Source License

/**
 * @return null if the intersection is empty, {@link com.itextpdf.text.Rectangle} representing intersection otherwise
 *//*  ww  w . ja va2s  . c o  m*/
private Rectangle intersection(Rectangle rect1, Rectangle rect2) {
    com.itextpdf.awt.geom.Rectangle awtRect1 = new com.itextpdf.awt.geom.Rectangle(rect1);
    com.itextpdf.awt.geom.Rectangle awtRect2 = new com.itextpdf.awt.geom.Rectangle(rect2);
    com.itextpdf.awt.geom.Rectangle awtIntersection = awtRect1.intersection(awtRect2);

    return awtIntersection.isEmpty() ? null : new Rectangle(awtIntersection);
}

From source file:modelo.Ejemplo1.java

/**
 * Raz.//from   w  w  w .j  a va 2  s .  c  o  m
 */
public static void main(String[] args) {
    //Creamos la representacin de una pgina, con un tamao
    //por defecto.

    Rectangle pagina = new Rectangle(PageSize.LETTER);

    //Establecemos el color de la pgina y reescribimos la funcin
    //toString de la clase BaseColor para obtener el nombre del color.

    // Creamos un documento y le pasamos como parametro un objeto de
    // tipo Rectangle, dicho objeto contiene las especificaciones
    // de como se vera nuestra pgina.
    Document documento = new Document(pagina);

    try {

        // Obtenemos una instancia de un objeto PDFWriter
        PdfWriter.getInstance(documento, new FileOutputStream("Ejemplo1.pdf"));
        documento.open();

        // Generamos nuestro contenido.
        String contenido = "Generacin de un PDF simple:\n " + "\t\tAncho de pgina: "
                + documento.getPageSize().getWidth() + "\n\t\tAlto de pgina: "
                + documento.getPageSize().getHeight() + "\n\t\tColor de pgina: ";

        // Lo agregamos al documento por medio de una instancia
        // de un obtjeto Paragraph.
        //
        documento.add(new Paragraph(contenido));

        // Cerramos el documento para hacer persistente el contenido.
        documento.close();

    } catch (DocumentException ex) {
        // Atrapamos excepciones concernientes al documento.
    } catch (java.io.IOException ex) {
        // Atrapamos excepciones concernientes al I/O.
    }
}

From source file:org.gephi.io.exporter.preview.PDFExporter.java

License:Open Source License

public boolean execute() {
    Progress.start(progress);//from  w  w w  . j  a  v  a 2s .c  om

    PreviewController controller = Lookup.getDefault().lookup(PreviewController.class);
    controller.getModel(workspace).getProperties().putValue(PreviewProperty.VISIBILITY_RATIO, 1.0);
    controller.refreshPreview(workspace);
    PreviewProperties props = controller.getModel(workspace).getProperties();

    Rectangle size = new Rectangle(pageSize);
    if (landscape) {
        size = new Rectangle(pageSize.rotate());
    }
    Color col = props.getColorValue(PreviewProperty.BACKGROUND_COLOR);
    size.setBackgroundColor(new BaseColor(col.getRed(), col.getGreen(), col.getBlue()));

    Document document = new Document(size);
    PdfWriter pdfWriter = null;
    try {
        pdfWriter = PdfWriter.getInstance(document, stream);
        pdfWriter.setPdfVersion(PdfWriter.PDF_VERSION_1_5);
        pdfWriter.setFullCompression();

    } catch (DocumentException ex) {
        Exceptions.printStackTrace(ex);
    }
    document.open();
    PdfContentByte cb = pdfWriter.getDirectContent();
    cb.saveState();

    props.putValue(PDFTarget.LANDSCAPE, landscape);
    props.putValue(PDFTarget.PAGESIZE, size);
    props.putValue(PDFTarget.MARGIN_TOP, new Float((float) marginTop));
    props.putValue(PDFTarget.MARGIN_LEFT, new Float((float) marginLeft));
    props.putValue(PDFTarget.MARGIN_BOTTOM, new Float((float) marginBottom));
    props.putValue(PDFTarget.MARGIN_RIGHT, new Float((float) marginRight));
    props.putValue(PDFTarget.PDF_CONTENT_BYTE, cb);
    target = (PDFTarget) controller.getRenderTarget(RenderTarget.PDF_TARGET, workspace);
    if (target instanceof LongTask) {
        ((LongTask) target).setProgressTicket(progress);
    }

    try {
        controller.render(target, workspace);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }

    cb.restoreState();
    document.close();

    Progress.finish(progress);

    props.putValue(PDFTarget.PDF_CONTENT_BYTE, null);
    props.putValue(PDFTarget.PAGESIZE, null);

    return !cancel;
}

From source file:src.GUI.PDFGEN.java

License:Open Source License

public void PDFAB(String Headline, int AmountExer, GUISETTINGSPDF k) {
    Document Doc = new Document();
    Rectangle Rec = new Rectangle(PageSize.A4);
    Doc.setPageSize(Rec);/*  w ww . j a va2  s .co  m*/
    try {
        F = File.createTempFile("Blatt", ".pdf");
        PdfWriter.getInstance(Doc, new FileOutputStream(F));
        Doc.open();
        Paragraph Para = new Paragraph(Headline, FONTS.FontHeader());
        Para.setAlignment(Element.ALIGN_CENTER);
        Doc.add(Para);
        First = new MEMORY();
        Current = First;
        GUISETTINGSPDF D = k;
        //Image Img = Image.getInstance("Logo");
        //Doc.add(Img);
        for (int i = 1; i <= AmountExer; i++) {
            List = new List(List.ORDERED, List.ALPHABETICAL);
            for (int c = 0; c < k.taskNumber; c++) {
                TERM Term = new TERM(k.aoAddition, k.aoSubtraction, k.aoMultiplication, k.aoDivision,
                        k.bracketDepht, k.Substitutions, k.Digits, k.decimalPlaces, k.justPositive);
                Current.writeExercise(Term.infix() + "=");
                Current.writeSolution(Double.parseDouble(Term.getSolution()));
                List.add(new ListItem(Current.readExercise()));
                Current.Next = new MEMORY();
                Current = Current.Next;
            }
            Doc.add(new Paragraph(" \n Aufgabe " + i, FONTS.Font()));
            k = k.next;
            Doc.add(List);
        }
        Doc.close();
        Desktop.getDesktop().open(F);
        PDFLB(AmountExer, D);
        Desktop.getDesktop().open(G);
    } catch (Exception e) {
        e.printStackTrace();
    }
}