Example usage for com.itextpdf.text Document setMargins

List of usage examples for com.itextpdf.text Document setMargins

Introduction

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

Prototype


public boolean setMargins(float marginLeft, float marginRight, float marginTop, float marginBottom) 

Source Link

Document

Sets the margins.

Usage

From source file:com.devox.GUI.PDF.ExportarAPDF.java

public void crearDestruccion(File file) {
    try {//from   w w w .  jav  a  2s  .  c  om
        Document document = new Document(PageSize.A4);
        file.createNewFile();
        PdfWriter w = PdfWriter.getInstance(document, new FileOutputStream(file));
        document.open();
        setLogo();
        CabeceraPieDePagina event = new CabeceraPieDePagina();
        w.setPageEvent(event);
        document.setMargins(50, 50, 100, 220);
        document.newPage();
        document.add(setUpInformation());
        PdfPTable t = createTable();
        addProductos(model, t);
        document.add(t);
        //
        document.close();
    } catch (Exception ex) {
        Log.print(ex);
        Log.print(ex);
    }
}

From source file:com.devox.GUI.PDF.ExportarAPDF.java

public void crearApto(File file) {
    try {/*from  www.j ava 2 s. c o m*/
        Document document = new Document(PageSize.A4);
        file.createNewFile();
        PdfWriter w = PdfWriter.getInstance(document, new FileOutputStream(file));
        document.open();
        setLogo();
        CabeceraPieDePagina event = new CabeceraPieDePagina();
        w.setPageEvent(event);
        document.setMargins(50, 50, 100, 220);
        document.newPage();
        document.add(setUpInformationTarimas());
        //            PdfPTable t = createTable();
        //            addProductos(model, t);
        //            document.add(t);
        //
        document.close();
    } catch (Exception ex) {
        Log.print(ex);
        Log.print(ex);
    }
}

From source file:com.devox.GUI.PDF.ExportarAPDF.java

public void crearTarimas(File file) {
    try {/*from   w w w .  j a v  a2  s.  co m*/
        Document document = new Document(PageSize.A4.rotate());
        file.createNewFile();
        PdfWriter w = PdfWriter.getInstance(document, new FileOutputStream(file));
        document.open();
        setLogo();
        CabeceraPieDePagina2 event = new CabeceraPieDePagina2();
        w.setPageEvent(event);
        document.setMargins(50, 50, 100, 50);
        document.newPage();
        document.add(setUpInformationTarimas());
        PdfPTable t = createTableTarimas();
        addProductosTarimas(t);
        document.add(t);
        //
        document.close();
    } catch (Exception ex) {
        Log.print(ex);
        Log.print(ex);
    }
}

From source file:com.github.ossdevs.jhocr.converter.HocrToPdf.java

License:Open Source License

/**
 * This is the old <code>convert()</code> method, almost untouched.<br>
 * This method will be used if {@link #pdfFormat} is not set.
 *
 * @return true if the conversion was successful.
 *//*from   w w  w  .ja va  2  s  . c om*/
private boolean convertSimple() {
    boolean result = false;

    Document document = new Document();

    try {
        PdfWriter writer = PdfWriter.getInstance(document, getOutputStream());

        document.open();
        document.addHeader(KEY_JHOCR_INFO, KEY_JHOCR_INFO_VALUE);
        document.setMargins(0, 0, 0, 0);

        /**
         * TODO add documentation
         */
        for (HocrDocumentItem item : getItems()) {

            HocrParser parser = new HocrParser(item.getHocrInputStream());

            HocrDocument hocrDocument = parser.parse();

            /**
             * TODO add documentation
             * TODO add multipage image support
             */
            if (hocrDocument.getPages().size() > 1) {
                throw new UnsupportedOperationException(
                        "Multipage tif are not yet implemented, please report: http://code.google.com/p/jhocr/issues/list");
            }

            /**
             * TODO add documentation
             */
            for (HocrPage hocrPage : hocrDocument.getPages()) {
                HocrPageProcessor pageProcessor = new HocrPageProcessor(hocrPage, item.getImageInputStream(),
                        isUseImageDpi());

                if (pageProcessor.isInitialized()) {
                    pageProcessor.process(document, writer);
                }
            }
        }

        if (!outlines.isEmpty()) {
            writer.setOutlines(outlines);
        }

        /**
         * Closing the document body stream.
         */
        document.close();
        getOutputStream().close();
        result = true;

    } catch (UnsupportedOperationException e) {
        document.close();
        logger.error("This operation is not yet implemented.", e);
        result = false;
    } catch (DocumentException e) {
        document.close();
        logger.error("exception while genrating the PDF.", e);
        result = false;
    } catch (IOException e) {
        document.close();
        logger.error("FileSystem I/O Exception, please check the log and file system persmissions.", e);
        result = false;
    }

    return result;
}

From source file:com.github.ossdevs.jhocr.converter.HocrToPdf.java

License:Open Source License

/**
 * @param pdfXConformance determines into which format the PDF-X will be converted.
 * @return true if the conversion was successful.
 *///  w  ww  .  java  2s  . c  o  m
private boolean convertToPDFX(int pdfXConformance) {
    boolean result = false;
    Document document = new Document();

    try {
        PdfWriter writer = PdfWriter.getInstance(document, getOutputStream());
        writer.setPDFXConformance(pdfXConformance);

        document.open();
        document.addHeader(KEY_JHOCR_INFO, KEY_JHOCR_INFO_VALUE);
        document.setMargins(0, 0, 0, 0);

        /**
         * TODO add documentation
         */
        for (HocrDocumentItem item : getItems()) {

            HocrParser parser = new HocrParser(item.getHocrInputStream());

            HocrDocument hocrDocument = parser.parse();

            /**
             * TODO add documentation
             * TODO add multipage image support
             */
            if (hocrDocument.getPages().size() > 1) {
                throw new UnsupportedOperationException(
                        "Multipage tif are not yet implemented, please report: http://code.google.com/p/jhocr/issues/list");
            }

            /**
             * TODO add documentation
             */
            for (HocrPage hocrPage : hocrDocument.getPages()) {
                HocrPageProcessor pageProcessor = new HocrPageProcessor(hocrPage, item.getImageInputStream(),
                        isUseImageDpi());

                if (pageProcessor.isInitialized()) {
                    pageProcessor.process(document, writer);
                }
            }
        }

        if (!outlines.isEmpty()) {
            writer.setOutlines(outlines);
        }

        /**
         * Closing the document body stream.
         */
        document.close();
        getOutputStream().close();
        result = true;

    } catch (UnsupportedOperationException e) {
        document.close();
        logger.error("This operation is not yet implemented.", e);
        result = false;
    } catch (DocumentException e) {
        document.close();
        logger.error("exception while genrating the PDF.", e);
        result = false;
    } catch (IOException e) {
        document.close();
        logger.error("FileSystem I/O Exception, please check the log and file system persmissions.", e);
        result = false;
    }

    return result;

}

From source file:com.github.ossdevs.jhocr.converter.HocrToPdf.java

License:Open Source License

/**
 * @param pdfConformanceLevel determines into which format the PDF-A&/B will be converted.
 * @return true if the conversion was successful.
 */// w  w w.  j a va2  s.  c o  m
private boolean convertToPDFA(PdfAConformanceLevel pdfConformanceLevel) {
    boolean result = false;
    Document document = new Document();

    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();

    if (classLoader == null) {
        classLoader = Class.class.getClassLoader();
    }

    try {
        PdfAWriter writer = PdfAWriter.getInstance(document, getOutputStream(), pdfConformanceLevel);
        writer.createXmpMetadata();

        document.open();
        document.addHeader(KEY_JHOCR_INFO, KEY_JHOCR_INFO_VALUE);
        document.setMargins(0, 0, 0, 0);

        /**
         * TODO add documentation
         */
        for (HocrDocumentItem item : getItems()) {

            HocrParser parser = new HocrParser(item.getHocrInputStream());

            HocrDocument hocrDocument = parser.parse();

            /**
             * TODO add documentation
             * TODO add multipage image support
             */
            if (hocrDocument.getPages().size() > 1) {
                throw new UnsupportedOperationException(
                        "Multipage tif are not yet implemented, please report: http://code.google.com/p/jhocr/issues/list");
            }

            /**
             * TODO add documentation
             */
            for (HocrPage hocrPage : hocrDocument.getPages()) {
                HocrPageProcessor pageProcessor = new HocrPageProcessor(hocrPage, item.getImageInputStream(),
                        isUseImageDpi());

                if (pageProcessor.isInitialized()) {
                    pageProcessor.process(document, writer);
                }
            }
        }

        if (!outlines.isEmpty()) {
            writer.setOutlines(outlines);
        }

        InputStream is = this.getClass().getResourceAsStream("/sRGB.profile");

        ICC_Profile icc = ICC_Profile.getInstance(is);
        writer.setOutputIntents(KEY_JHOCR_INFO, KEY_JHOCR_INFO_VALUE, "http://www.color.org",
                "sRGB IEC61966-2.1", icc);

        /**
         * Closing the document body stream.
         */
        document.close();
        getOutputStream().close();
        result = true;

    } catch (UnsupportedOperationException e) {
        document.close();
        logger.error("This operation is not yet implemented.", e);
        result = false;
    } catch (DocumentException e) {
        document.close();
        logger.error("exception while genrating the PDF.", e);
        result = false;
    } catch (IOException e) {
        document.close();
        logger.error("FileSystem I/O Exception, please check the log and file system persmissions.", e);
        result = false;
    }

    return result;

}

From source file:com.mstoyanov.music_lessons.pdf.CreatePDF.java

License:Open Source License

public boolean exportPDF() {
    // Checks if external storage is available:
    if (!isExternalStorageWritable()) {
        Toast.makeText(context, "External storage not accessible!", Toast.LENGTH_SHORT).show();
        return false;
    }/* ww  w .j  a  v  a  2 s .c o m*/
    // Get the path to the user's public downloads directory:
    String fileName = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).toString()
            + "/Schedule.pdf";
    try {
        Document document = new Document(PageSize.LETTER.rotate());
        PdfWriter.getInstance(document, new FileOutputStream(fileName));
        // Create a new letter sized document in landscape mode:
        document.setPageSize(PageSize.LETTER.rotate());
        document.setMargins(72, 36, 36, 36);
        document.open();
        addMetaData(document);
        addContent(document);
        document.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
    Toast.makeText(context, "Schedule exported to external storage/Download", Toast.LENGTH_LONG).show();
    return true;
}

From source file:com.mycom.products.mywebsite.backend.util.DownloadHandler.java

License:Open Source License

@RequestMapping(value = "/user/{id}", method = RequestMethod.GET)
protected final void downloadUserInformation(@PathVariable int id, HttpServletRequest request,
        final HttpServletResponse response) throws ServletException, BusinessException, DocumentException {
    UserBean user = userService.select(id, FetchMode.EAGER);
    if (user == null) {
        return;/*from   www  .  j  a va  2  s. co  m*/
    }
    Document document = new Document();
    document.setMargins(70, 70, 20, 20);

    try {
        response.setContentType("application/pdf");
        response.setHeader("Content-Disposition",
                "attachment; filename=\"" + user.getName() + "_profile.pdf\"");
        PdfWriter.getInstance(document, response.getOutputStream());
        document.open();
        Image profileImage = null;
        try {
            profileImage = Image.getInstance(user.getContent().getFilePath());
        } catch (Exception e) {
            // e.printStackTrace();
        }
        if (profileImage != null) {
            profileImage.setAlignment(Image.MIDDLE | Image.TEXTWRAP);
            profileImage.setBorder(Image.BOX);
            profileImage.setBorderWidth(5);
            BaseColor bgcolor = WebColors.getRGBColor("#E5E3E3");
            profileImage.setBorderColor(bgcolor);
            profileImage.scaleToFit(100, 100);
            document.add(profileImage);
        }
        document.add(Chunk.NEWLINE);
        document.add(Chunk.NEWLINE);

        // Adding Table Data
        PdfPTable table = new PdfPTable(2); // 2 columns.
        table.setWidthPercentage(100); // Width 100%
        table.setSpacingBefore(15f); // Space before table
        table.setSpacingAfter(15f); // Space after table

        // Set Column widths
        float[] columnWidths = { 1f, 2f, };
        table.setWidths(columnWidths);

        // Name
        setTableHeader("Name", table);
        setTableContent(user.getName(), table);

        // Gender
        setTableHeader("Gender", table);
        String gender = "Male";
        if (user.getGender() == Gender.FEMALE) {
            gender = "Female";
        }
        setTableContent(gender, table);

        // Age
        setTableHeader("Age", table);
        setTableContent("" + user.getAge(), table);

        // Date of Birth
        setTableHeader("DOB", table);
        DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("dd/MM/yyyy");
        setTableContent(dateFormatter.format(user.getDob()), table);

        // Email
        setTableHeader("Email", table);
        setTableContent(user.getEmail(), table);

        // NRC
        setTableHeader("NRC", table);
        setTableContent(user.getNrc(), table);

        // Phone
        setTableHeader("Phone", table);
        setTableContent(user.getPhone(), table);

        // Roles
        String roleStr = "";
        List<RoleBean> roles = user.getRoles();
        if (roles != null && roles.size() > 0) {
            Iterator<RoleBean> itr = roles.iterator();
            while (itr.hasNext()) {
                RoleBean role = itr.next();
                roleStr += role.getName();
                if (itr.hasNext()) {
                    roleStr += ",";
                }
            }
        }
        setTableHeader("Role(s)", table);
        setTableContent(roleStr, table);

        // Address
        setTableHeader("Address", table);
        setTableContent(user.getAddress(), table);

        document.add(table);
        document.add(new Paragraph(new Date().toString()));

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

    }
    document.close();
}

From source file:com.norbsoft.pdfconverter.helpers.PDFHelper.java

License:Open Source License

public int generate(String saveUrl, SerializableBitmap sign, Form form, ArrayList<String> photos,
        ArrayList<String> workers) {
    try {//  w  w w  .j  a  v a2 s . com
        Document document = new Document();

        url = saveUrl;
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(url));
        document.setMargins(20, 20, 20, 20);
        document.open();

        Bitmap inputLogo = BitmapFactory.decodeStream(context.getAssets().open("logo.jpg"));
        ByteArrayOutputStream outstream = new ByteArrayOutputStream();
        inputLogo.compress(Bitmap.CompressFormat.JPEG, 100, outstream);
        Image logo = Image.getInstance(outstream.toByteArray());

        Bitmap inputQR = BitmapFactory.decodeStream(context.getAssets().open("qr.jpg"));
        outstream = new ByteArrayOutputStream();
        inputQR.compress(Bitmap.CompressFormat.JPEG, 100, outstream);
        Image qr = Image.getInstance(outstream.toByteArray());

        outstream = new ByteArrayOutputStream();
        sign.getImage().compress(Bitmap.CompressFormat.JPEG, 100, outstream);
        Image sgn = Image.getInstance(outstream.toByteArray());

        qr.scaleAbsolute(90f, 90f);
        qr.setAbsolutePosition(340f, 705f);

        logo.scaleAbsolute(150f, 50f);
        logo.setAbsolutePosition(50f, 750f);

        sgn.scaleAbsolute(130f, 30f);
        sgn.setAbsolutePosition(25f, 75f);

        Paragraph p = new Paragraph("\r\n\r\n\r\nMPWiK S.A.\r\n50-421 Wrocaw\r\nul.Na Grobli 14-16", normal);
        p.setIndentationLeft(420f);
        document.add(p);

        p = new Paragraph("RAPORT WYMIANY WODOMIERZA", bold);
        p.setAlignment(Element.ALIGN_CENTER);
        p.setSpacingBefore(60f);
        document.add(p);

        document.add(table(form));

        p = new Paragraph(form.getInformations(), normal);
        p.setAlignment(Element.ALIGN_LEFT);
        p.setIndentationLeft(50f);
        p.setSpacingBefore(20f);
        document.add(p);

        document.add(signTable(form, sgn, workers));

        document.add(logo);
        document.add(qr);

        if (photos != null && photos.size() > 0) {
            document.newPage();
            for (int i = 0; i < photos.size(); i++) {
                try {
                    if (photos.get(i) != null && !photos.get(i).equals("")) {
                        Log.d(TAG, photos.get(i));
                        Bitmap temp = PictureHelper.bitmapFromUrl(photos.get(i));
                        outstream = new ByteArrayOutputStream();
                        temp.compress(Bitmap.CompressFormat.JPEG, 100, outstream);
                        Image photo = Image.getInstance(outstream.toByteArray());
                        photo.scaleToFit(document.getPageSize().getWidth() - 50,
                                document.getPageSize().getHeight());
                        document.add(photo);
                    }
                } catch (Exception e) {

                }
            }
        }
        document.close();
        writer.close();
        return 1;
    } catch (FileNotFoundException e) {
        Log.e(TAG, e.getMessage());
        return 0;
    } catch (DocumentException e) {
        Log.e(TAG, e.getMessage());
        return 0;
    } catch (IOException e) {
        Log.e(TAG, e.getMessage());
        return 0;
    } catch (Exception e) {
        Log.e(TAG, e.getMessage());
        return 0;
    }
}

From source file:com.pdfwriter.PrintInventoryReport.java

public void create(ObservableList list, String totalSales) {
    try {/* ww  w . j a va 2s.  com*/
        Document document = new Document(PageSize.LETTER);
        document.setMargins(1, 1, 1, 1);

        PdfWriter.getInstance(document, new FileOutputStream(filename));
        document.open();
        Font font2 = new Font(Font.FontFamily.UNDEFINED, 10, Font.BOLD);
        PdfPTable table = new PdfPTable(5);
        table.setWidthPercentage(95);
        table.setWidths(new int[] { 40, 40, 40, 40, 40 });
        PdfPCell cell;

        cell = new PdfPCell(new Phrase("", font2));
        cell.setBorder(0);
        cell.setColspan(8);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setVerticalAlignment(Element.ALIGN_CENTER);
        cell.setBorderWidthTop(0);

        cell.setBorderWidthBottom(0);
        table.addCell(cell);

        cell = new PdfPCell(
                new Phrase("KELNOVI SHOPPING BOTIQUE", new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD)));
        cell.setColspan(10);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(0);
        table.addCell(cell);

        cell = new PdfPCell(
                new Phrase("Pondol,Loon, Bohol", new Font(Font.FontFamily.HELVETICA, 12, Font.BOLD)));
        cell.setColspan(10);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(0);
        table.addCell(cell);

        cell = new PdfPCell(
                new Phrase("Phone/Fax#:000-000-000", new Font(Font.FontFamily.UNDEFINED, 9, Font.UNDERLINE)));
        cell.setColspan(10);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(0);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(" "));
        cell.setColspan(10);
        cell.setRowspan(3);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(0);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase("SALES REPORT", new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD)));
        cell.setColspan(10);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(0);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(" "));
        cell.setColspan(10);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(0);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase("NO."));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(14);
        cell.setBackgroundColor(BaseColor.GRAY);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase("PRODUCT NAME"));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(14);
        cell.setBackgroundColor(BaseColor.GRAY);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase("PRICE"));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(14);
        cell.setBackgroundColor(BaseColor.GRAY);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase("QUANTITY"));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(14);
        cell.setBackgroundColor(BaseColor.GRAY);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase("AMOUNT PAYABLE"));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(14);
        cell.setBackgroundColor(BaseColor.GRAY);
        table.addCell(cell);

        for (int i = 0; i < list.size(); i++) {
            it = (ProductClass) list.get(i);

            cell = new PdfPCell(new Phrase("" + it.idProperty().get()));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setBorder(14);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase("" + it.productDescriptionProperty().get()));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setBorder(14);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase("" + it.productPriceProperty().get()));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setBorder(14);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase("" + it.productQtyProperty().get()));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setBorder(14);
            table.addCell(cell);
            //totalSales.setText(String.format("%,.2f",globalSales));

            cell = new PdfPCell(new Phrase(
                    String.format("%,.2f", Double.parseDouble(it.productTotalSalesProperty().get()))));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setBorder(14);
            table.addCell(cell);

        }

        cell = new PdfPCell(new Phrase(" "));
        cell.setColspan(10);
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setBorder(0);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase(" "));
        cell.setColspan(10);
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setBorder(0);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase("TOTAL AMOUNT PAYABLE:"));
        cell.setColspan(10);
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setBorder(0);
        table.addCell(cell);

        cell = new PdfPCell(
                new Phrase("Php " + totalSales, new Font(Font.FontFamily.UNDEFINED, 14, Font.UNDERLINE)));
        cell.setColspan(10);
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setBorder(0);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(" "));
        cell.setColspan(10);
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setBorder(0);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase("Approved by:"));
        cell.setColspan(10);
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setBorder(0);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase("MICHAEL NOVI MALUENDA II",
                new Font(Font.FontFamily.UNDEFINED, 14, Font.UNDERLINE)));
        cell.setColspan(10);
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setBorder(0);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase("General Manager"));
        cell.setColspan(10);
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setBorder(0);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(" "));
        cell.setColspan(10);
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setBorder(0);
        table.addCell(cell);

        document.add(table);
        document.close();
        openFile();

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