Example usage for com.lowagie.text Image setAlignment

List of usage examples for com.lowagie.text Image setAlignment

Introduction

In this page you can find the example usage for com.lowagie.text Image setAlignment.

Prototype


public void setAlignment(int alignment) 

Source Link

Document

Sets the alignment for the image.

Usage

From source file:Cotizacion.ExportarPDF.java

private static void acomodarImagenCabecera(Paragraph imagen) {

    try {//w  ww.j  a  va  2  s .  co m
        Image im;
        im = Image.getInstance("src/Imagenes/arriba.png");
        im.setAlignment(Image.ALIGN_CENTER | Image.TEXTWRAP);
        imagen.add(im);
    } catch (Exception e) {
        System.out.print(e.getMessage());
    }
}

From source file:Cotizacion.ExportarPDF.java

private static void acomodarImagenLogo(Paragraph imagen) throws BadElementException {
    try {/* w w  w.ja va  2 s .c  om*/
        Image im = Image.getInstance("src/Imagenes/todo Lonas.png");
        im.setAlignment(Image.ALIGN_LEFT | Image.TEXTWRAP);
        imagen.add(im);
    } catch (Exception e) {
        System.out.print(e.getMessage());
    }
}

From source file:Cotizacion.ExportarPDF.java

private static void acomodarImagenFirma(Paragraph imagen) throws BadElementException {
    try {//from   ww  w .j ava2  s. c  o m
        Image im = Image.getInstance("src/Imagenes/firma3.png");
        im.setAlignment(Image.ALIGN_CENTER | Image.TEXTWRAP);
        imagen.add(im);
        //            agregarLineasEnBlanco(parrafoNormal, 3);

    } catch (Exception e) {
        System.out.print(e.getMessage());
    }
}

From source file:Cotizacion.ExportarPDF.java

private static void acomodarImagenPie(Paragraph imagen) throws BadElementException {
    try {// w ww. java  2  s.co  m
        Image im = Image.getInstance("src/Imagenes/abajo.png");
        im.setAbsolutePosition(0, 0);
        im.setAlignment(Image.ALIGN_CENTER);
        im.scalePercent(60f);
        imagen.add(im);

    } catch (Exception e) {
        System.out.print(e.getMessage());
    }
}

From source file:de.appplant.cordova.plugin.printer.Printer.java

License:Apache License

/**
 * Slices the screenshot into pages, merges those into a single pdf
 * and saves it in the public accessible /sdcard dir.
 *///from   w w w .j  av a2  s  .c o  m
private File saveWebViewAsPdf(Bitmap screenshot) {
    try {

        File sdCard = Environment.getExternalStorageDirectory();
        File dir = new File(sdCard.getAbsolutePath() + "/" + this.publicTmpDir + "/");
        dir.mkdirs();
        File file;
        FileOutputStream stream;

        double pageWidth = PageSize.A4.getWidth() * 0.85; // width of the image is 85% of the page
        double pageHeight = PageSize.A4.getHeight() * 0.80; // max height of the image is 80% of the page
        double pageHeightToWithRelation = pageHeight / pageWidth; // e.g.: 1.33 (4/3)

        Bitmap currPage;
        int totalSize = screenshot.getHeight();
        int currPos = 0;
        int currPageCount = 0;
        int sliceWidth = screenshot.getWidth();
        int sliceHeight = (int) Math.round(sliceWidth * pageHeightToWithRelation);
        while (totalSize > currPos && currPageCount < 100) // max 100 pages
        {
            currPageCount++;

            Log.v(LOG_TAG, "Creating page nr. " + currPageCount);

            // slice bitmap
            currPage = Bitmap.createBitmap(screenshot, 0, currPos, sliceWidth,
                    (int) Math.min(sliceHeight, totalSize - currPos));

            // save page as png
            stream = new FileOutputStream(new File(dir, "print-page-" + currPageCount + ".png"));
            currPage.compress(Bitmap.CompressFormat.PNG, 100, stream);
            stream.close();

            // move current position indicator
            currPos += sliceHeight;
        }

        // create pdf
        Log.v(LOG_TAG, "Creating pdf");
        Document document = new Document();
        File filePdf = new File(dir, this.printTitle + ".pdf"); // change the output name of the pdf here
        PdfWriter.getInstance(document, new FileOutputStream(filePdf));
        document.open();
        for (int i = 1; i <= currPageCount; ++i) {
            Log.v(LOG_TAG, "Adding page nr. " + i + " to the pdf file.");
            file = new File(dir, "print-page-" + i + ".png");
            Image image = Image.getInstance(file.getAbsolutePath());
            image.scaleToFit((float) pageWidth, 9999);
            image.setAlignment(Element.ALIGN_CENTER);
            document.add(image);
            document.newPage();
        }
        document.close();

        // delete tmp image files
        for (int i = 1; i <= currPageCount; ++i) {
            file = new File(dir, "print-page-" + i + ".png");
            file.delete();
        }

        return filePdf;

    } catch (IOException e) {
        Log.e(LOG_TAG, "ERROR: " + e.getMessage());
        e.printStackTrace();
        // return error answer to cordova
        PluginResult result = new PluginResult(PluginResult.Status.ERROR, e.getMessage());
        result.setKeepCallback(false);
        ctx.sendPluginResult(result);
    } catch (DocumentException e) {
        Log.e(LOG_TAG, "ERROR: " + e.getMessage());
        e.printStackTrace();
        // return error answer to cordova
        PluginResult result = new PluginResult(PluginResult.Status.ERROR, e.getMessage());
        result.setKeepCallback(false);
        ctx.sendPluginResult(result);
    }

    Log.e(LOG_TAG, "Uncaught ERROR!");

    return null;
}

From source file:de.dhbw.humbuch.util.PDFHandler.java

/**
 * Set the logo of Humboldt on the left corner and the current date on the
 * right corner/*from www  .j  av a2  s.  com*/
 * 
 * @param document
 *            reference of the pdfDocument object
 */
protected void addHeading(Document document) {
    Paragraph paragraph = new Paragraph();
    PdfPTable table = createMyStandardTable(2);

    table.setTotalWidth(TABLEWIDTH);
    PdfPCell cell;

    Image img = new ResourceLoader("pdf/humboldt_logo.png").getImage();
    img.setAlignment(Element.ALIGN_BOTTOM);
    img.scaleToFit(205f, 65f);
    cell = new PdfPCell(img);

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

    String date = new SimpleDateFormat("dd.MM.yyyy", Locale.GERMAN).format(Calendar.getInstance().getTime());

    cell = new PdfPCell(new Phrase(date));
    cell.setBorder(0);
    cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    cell.setVerticalAlignment(Element.ALIGN_BOTTOM);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase(""));
    cell.setBorder(Rectangle.BOTTOM);
    table.addCell(cell);
    cell = new PdfPCell(new Phrase(""));
    cell.setBorder(Rectangle.BOTTOM);
    table.addCell(cell);

    paragraph.add(table);
    addEmptyLine(paragraph, 1);

    try {
        document.add(paragraph);
    } catch (DocumentException e) {
        e.printStackTrace();
    }
}

From source file:de.japes.text.PdfCreator.java

License:Open Source License

public String exportToPdf(byte[] imgArray) {

    String filename;/*w ww  . ja v a  2s  .  c  o m*/
    Document document = new Document();
    Image img = null;

    Calendar cal = Calendar.getInstance();

    filename = "chart_" + cal.get(Calendar.YEAR) + cal.get(Calendar.MONTH) + cal.get(Calendar.DAY_OF_MONTH)
            + "_" + cal.get(Calendar.HOUR_OF_DAY) + cal.get(Calendar.MINUTE) + ".pdf";

    try {
        img = Image.getInstance(imgArray);
    } catch (MalformedURLException e) {
        return e.getMessage();
    } catch (IOException e) {
        return e.getMessage();
    } catch (BadElementException e) {
        return e.getMessage();
    }

    img.setAlignment(Image.ALIGN_CENTER);

    try {

        // step 2:
        // we create a writer that listens to the document
        // and directs a PDF-stream to a file

        PdfWriter.getInstance(document, new FileOutputStream(filename));

        // step 3: we open the document
        document.open();

        // step 4: we add a paragraph to the document
        document.add(img);

    } catch (DocumentException de) {
        return de.getMessage();
    } catch (IOException ioe) {
        return ioe.getMessage();
    }

    // step 5: we close the document
    document.close();

    return filename;
}

From source file:de.xirp.report.ReportGenerator.java

License:Open Source License

/**
 * Adds a/*www.j a va  2  s  .c  o m*/
 * {@link de.xirp.report.data.ContentPartImage image}
 * item to the PDF {@link com.lowagie.text.Document}.
 * 
 * @param item
 *            The image item to add.
 * @throws IOException
 *             if something went wrong saving the PDF.
 * @throws DocumentException
 *             if something went wrong adding the page.
 * @throws MalformedURLException
 *             if something went wrong saving the PDF.
 * @see de.xirp.report.data.ContentPartImage
 * @see com.lowagie.text.Document
 */
private static void addImage(ContentPartImage item)
        throws MalformedURLException, IOException, DocumentException {

    imageCounter++;

    String path = ""; //$NON-NLS-1$
    File file = new File(item.getPath());
    if (file.exists()) {
        path = item.getPath();
    }

    Image image = Image.getInstance(path);
    image.setAlignment(Image.MIDDLE);
    int maxWidth = 500;
    float plain = image.plainWidth();
    if (plain > maxWidth) {
        float percentage = maxWidth / plain;
        image.scalePercent(percentage * 100);
    }
    document.add(image);
    document.add(getParagraph(I18n.getString("ReportGenerator.report.document.image") //$NON-NLS-1$
            + " " + imageCounter + ": " + item.getShortDescription(), //$NON-NLS-1$ //$NON-NLS-2$
            IMAGE, Element.ALIGN_CENTER));

}

From source file:edu.harvard.mcz.imagecapture.encoder.LabelEncoder.java

License:Open Source License

@SuppressWarnings("hiding")
public static boolean printList(List<UnitTrayLabel> taxa) throws PrintFailedException {
    boolean result = false;
    UnitTrayLabel label = new UnitTrayLabel();
    LabelEncoder encoder = new LabelEncoder(label);
    Image image = encoder.getImage();
    int counter = 0;
    try {//from   www . j a  v a  2  s.c  o  m
        Document document = new Document();
        PdfWriter.getInstance(document, new FileOutputStream("labels.pdf"));
        document.setPageSize(PageSize.LETTER);
        document.open();

        PdfPTable table = new PdfPTable(4);
        table.setWidthPercentage(100f);
        //table.setHorizontalAlignment(PdfPTable.ALIGN_LEFT);
        float[] cellWidths = { 30f, 20f, 30f, 20f };
        table.setWidths(cellWidths);

        UnitTrayLabelLifeCycle uls = new UnitTrayLabelLifeCycle();
        if (taxa == null) {
            taxa = uls.findAll();
        }
        Iterator<UnitTrayLabel> i = taxa.iterator();
        PdfPCell cell = null;
        PdfPCell cell_barcode = null;
        // Create two lists of 12 cells, the first 6 of each representing
        // the left hand column of 6 labels, the second 6 of each 
        // representing the right hand column.  
        // cells holds the text for each label, cells_barcode the barcode.
        ArrayList<PdfPCell> cells = new ArrayList<PdfPCell>(12);
        ArrayList<PdfPCell> cells_barcode = new ArrayList<PdfPCell>(12);
        for (int x = 0; x < 12; x++) {
            cells.add(null);
            cells_barcode.add(null);
        }
        int cellCounter = 0;
        while (i.hasNext()) {
            // Loop through all of the taxa (unit tray labels) found to print 
            label = i.next();
            for (int toPrint = 0; toPrint < label.getNumberToPrint(); toPrint++) {
                // For each taxon, loop through the number of requested copies 
                // Generate a text and a barcode cell for each, and add to array for page
                log.debug("Label " + toPrint + " of " + label.getNumberToPrint());
                cell = new PdfPCell();
                cell.setBorderColor(Color.LIGHT_GRAY);
                cell.setVerticalAlignment(PdfPCell.ALIGN_TOP);
                cell.disableBorderSide(PdfPCell.RIGHT);
                cell.setPaddingLeft(3);

                String higherNames = "";
                if (label.getTribe().trim().length() > 0) {
                    higherNames = label.getFamily() + ": " + label.getSubfamily() + ": " + label.getTribe();
                } else {
                    higherNames = label.getFamily() + ": " + label.getSubfamily();
                }
                Paragraph higher = new Paragraph();
                higher.setFont(new Font(Font.TIMES_ROMAN, 11, Font.NORMAL));
                higher.add(new Chunk(higherNames));
                cell.addElement(higher);

                Paragraph name = new Paragraph();
                Chunk genus = new Chunk(label.getGenus().trim() + " ");
                genus.setFont(new Font(Font.TIMES_ROMAN, 11, Font.ITALIC));
                Chunk species = new Chunk(label.getSpecificEpithet().trim());
                Chunk normal = null; // normal font prefix to preceed specific epithet (nr. <i>epithet</i>)
                if (label.getSpecificEpithet().contains(".") || label.getSpecificEpithet().contains("[")) {
                    if (label.getSpecificEpithet().startsWith("nr. ")) {
                        normal = new Chunk("nr. ");
                        normal.setFont(new Font(Font.TIMES_ROMAN, 11, Font.NORMAL));
                        species = new Chunk(label.getSpecificEpithet().trim().substring(4));
                        species.setFont(new Font(Font.TIMES_ROMAN, 11, Font.ITALIC));
                    } else {
                        species.setFont(new Font(Font.TIMES_ROMAN, 11, Font.NORMAL));
                    }
                } else {
                    species.setFont(new Font(Font.TIMES_ROMAN, 11, Font.ITALIC));
                }
                String s = "";
                if (label.getSubspecificEpithet().trim().length() > 0) {
                    s = " ";
                } else {
                    s = "";
                }
                Chunk subspecies = new Chunk(s + label.getSubspecificEpithet().trim());
                if (label.getSubspecificEpithet().contains(".")
                        || label.getSubspecificEpithet().contains("[")) {
                    subspecies.setFont(new Font(Font.TIMES_ROMAN, 11, Font.NORMAL));
                } else {
                    subspecies.setFont(new Font(Font.TIMES_ROMAN, 11, Font.ITALIC));
                }
                if (label.getInfraspecificRank().trim().length() > 0) {
                    s = " ";
                } else {
                    s = "";
                }
                Chunk infraRank = new Chunk(s + label.getInfraspecificRank().trim());
                infraRank.setFont(new Font(Font.TIMES_ROMAN, 11, Font.NORMAL));

                if (label.getInfraspecificEpithet().trim().length() > 0) {
                    s = " ";
                } else {
                    s = "";
                }
                Chunk infra = new Chunk(s + label.getInfraspecificEpithet().trim());
                infra.setFont(new Font(Font.TIMES_ROMAN, 11, Font.ITALIC));
                if (label.getUnNamedForm().trim().length() > 0) {
                    s = " ";
                } else {
                    s = "";
                }
                Chunk unNamed = new Chunk(s + label.getUnNamedForm().trim());
                unNamed.setFont(new Font(Font.TIMES_ROMAN, 11, Font.NORMAL));

                name.add(genus);
                if (normal != null) {
                    name.add(normal);
                }
                name.add(species);
                name.add(subspecies);
                name.add(infraRank);
                name.add(infra);
                name.add(unNamed);
                cell.addElement(name);

                Paragraph authorship = new Paragraph();
                authorship.setFont(new Font(Font.TIMES_ROMAN, 10, Font.NORMAL));
                if (label.getAuthorship() != null && label.getAuthorship().length() > 0) {
                    Chunk c_authorship = new Chunk(label.getAuthorship());
                    authorship.add(c_authorship);
                }
                cell.addElement(authorship);
                //cell.addElement(new Paragraph(" "));
                if (label.getDrawerNumber() != null && label.getDrawerNumber().length() > 0) {
                    Paragraph drawerNumber = new Paragraph();
                    drawerNumber.setFont(new Font(Font.TIMES_ROMAN, 10, Font.NORMAL));
                    Chunk c_drawerNumber = new Chunk(label.getDrawerNumber());
                    drawerNumber.add(c_drawerNumber);
                    cell.addElement(drawerNumber);
                } else {
                    if (label.getCollection() != null && label.getCollection().length() > 0) {
                        Paragraph collection = new Paragraph();
                        collection.setFont(new Font(Font.TIMES_ROMAN, 10, Font.NORMAL));
                        Chunk c_collection = new Chunk(label.getCollection());
                        collection.add(c_collection);
                        cell.addElement(collection);
                    }
                }

                cell_barcode = new PdfPCell();
                cell_barcode.setBorderColor(Color.LIGHT_GRAY);
                cell_barcode.disableBorderSide(PdfPCell.LEFT);
                cell_barcode.setVerticalAlignment(PdfPCell.ALIGN_TOP);

                encoder = new LabelEncoder(label);
                image = encoder.getImage();
                image.setAlignment(Image.ALIGN_TOP);
                cell_barcode.addElement(image);

                cells.add(cellCounter, cell);
                cells_barcode.add(cellCounter, cell_barcode);

                cellCounter++;
                // If we have hit a full set of 12 labels, add them to the document
                // in two columns, filling left column first, then right
                if (cellCounter == 12) {
                    // add a page of 12 cells in columns of two.
                    for (int x = 0; x < 6; x++) {
                        if (cells.get(x) == null) {
                            PdfPCell c = new PdfPCell();
                            c.setBorder(0);
                            table.addCell(c);
                            table.addCell(c);
                        } else {
                            table.addCell(cells.get(x));
                            table.addCell(cells_barcode.get(x));
                        }
                        if (cells.get(x + 6) == null) {
                            PdfPCell c = new PdfPCell();
                            c.setBorder(0);
                            table.addCell(c);
                            table.addCell(c);
                        } else {
                            table.addCell(cells.get(x + 6));
                            table.addCell(cells_barcode.get(x + 6));
                        }
                    }
                    // Reset to begin next page
                    cellCounter = 0;
                    document.add(table);
                    table = new PdfPTable(4);
                    table.setWidthPercentage(100f);
                    table.setWidths(cellWidths);
                    for (int x = 0; x < 12; x++) {
                        cells.set(x, null);
                        cells_barcode.set(x, null);
                    }
                }
            } // end loop through toPrint (for a taxon)
            counter++;
        } // end while results has next (for all taxa requested)
          // get any remaining cells in pairs
        for (int x = 0; x < 6; x++) {
            if (cells.get(x) == null) {
                PdfPCell c = new PdfPCell();
                c.setBorder(0);
                table.addCell(c);
                table.addCell(c);
            } else {
                table.addCell(cells.get(x));
                table.addCell(cells_barcode.get(x));
            }
            if (cells.get(x + 6) == null) {
                PdfPCell c = new PdfPCell();
                c.setBorder(0);
                table.addCell(c);
                table.addCell(c);
            } else {
                table.addCell(cells.get(x + 6));
                table.addCell(cells_barcode.get(x + 6));
            }
        }
        // add any remaining cells
        document.add(table);
        try {
            document.close();
        } catch (Exception e) {
            throw new PrintFailedException("No labels to print." + e.getMessage());
        }
        // Check to see if there was content in the document.
        if (counter == 0) {
            result = false;
        } else {
            // Printed to pdf ok.
            result = true;
            // Increment number printed.
            i = taxa.iterator();
            while (i.hasNext()) {
                label = i.next();
                for (int toPrint = 0; toPrint < label.getNumberToPrint(); toPrint++) {
                    label.setPrinted(label.getPrinted() + 1);
                }
                label.setNumberToPrint(0);
                try {
                    uls.attachDirty(label);
                } catch (SaveFailedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        throw new PrintFailedException("File not found.");
    } catch (DocumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        throw new PrintFailedException("Error buiding PDF document.");
    } catch (OutOfMemoryError e) {
        System.out.println("Out of memory error. " + e.getMessage());
        System.out.println("Failed.  Too many labels.");
        throw new PrintFailedException("Ran out of memory, too many labels at once.");
    }
    return result;
}

From source file:fr.paris.lutece.plugins.directory.modules.pdfproducer.utils.PDFUtils.java

License:Open Source License

/**
 * method to create PDF/*from w  ww. j av  a 2s.  c o m*/
 * @param adminUser The admin user
 * @param locale The locale
 * @param strNameFile PDF name
 * @param out OutputStream
 * @param nIdRecord the id record
 * @param listIdEntryConfig list of config id entry
 * @param bExtractNotFilledField if true, extract empty fields, false
 */
public static void doCreateDocumentPDF(AdminUser adminUser, Locale locale, String strNameFile, OutputStream out,
        int nIdRecord, List<Integer> listIdEntryConfig, Boolean bExtractNotFilledField) {
    Document document = new Document(PageSize.A4);

    Plugin plugin = PluginService.getPlugin(DirectoryPlugin.PLUGIN_NAME);

    EntryFilter filter;

    Record record = RecordHome.findByPrimaryKey(nIdRecord, plugin);

    filter = new EntryFilter();
    filter.setIdDirectory(record.getDirectory().getIdDirectory());
    filter.setIsGroup(EntryFilter.FILTER_TRUE);

    List<IEntry> listEntry = DirectoryUtils.getFormEntries(record.getDirectory().getIdDirectory(), plugin,
            adminUser);
    int nIdDirectory = record.getDirectory().getIdDirectory();
    Directory directory = DirectoryHome.findByPrimaryKey(nIdDirectory, plugin);

    try {
        PdfWriter.getInstance(document, out);
    } catch (DocumentException e) {
        AppLogService.error(e);
    }

    document.open();

    if (record.getDateCreation() != null) {
        SimpleDateFormat monthDayYearformatter = new SimpleDateFormat(
                AppPropertiesService.getProperty(PROPERTY_POLICE_FORMAT_DATE));

        Font fontDate = new Font(
                DirectoryUtils.convertStringToInt(AppPropertiesService.getProperty(PROPERTY_POLICE_NAME)),
                DirectoryUtils.convertStringToInt(AppPropertiesService.getProperty(PROPERTY_POLICE_SIZE_DATE)),
                DirectoryUtils
                        .convertStringToInt(AppPropertiesService.getProperty(PROPERTY_POLICE_STYLE_DATE)));

        Paragraph paragraphDate = new Paragraph(
                new Phrase(monthDayYearformatter.format(record.getDateCreation()).toString(), fontDate));

        paragraphDate.setAlignment(DirectoryUtils
                .convertStringToInt(AppPropertiesService.getProperty(PROPERTY_POLICE_ALIGN_DATE)));

        try {
            document.add(paragraphDate);
        } catch (DocumentException e) {
            AppLogService.error(e);
        }
    }

    Image image;

    try {

        image = Image.getInstance(ImageIO.read(new File(AppPathService
                .getAbsolutePathFromRelativePath(AppPropertiesService.getProperty(PROPERTY_IMAGE_URL)))), null);
        image.setAlignment(
                DirectoryUtils.convertStringToInt(AppPropertiesService.getProperty(PROPERTY_IMAGE_ALIGN)));
        float fitWidth;
        float fitHeight;

        try {
            fitWidth = Float.parseFloat(AppPropertiesService.getProperty(PROPERTY_IMAGE_FITWIDTH));
            fitHeight = Float.parseFloat(AppPropertiesService.getProperty(PROPERTY_IMAGE_FITHEIGHT));
        } catch (NumberFormatException e) {
            fitWidth = 100f;
            fitHeight = 100f;
        }

        image.scaleToFit(fitWidth, fitHeight);

        try {
            document.add(image);
        } catch (DocumentException e) {
            AppLogService.error(e);
        }
    } catch (BadElementException e) {
        AppLogService.error(e);
    } catch (MalformedURLException e) {
        AppLogService.error(e);
    } catch (IOException e) {
        AppLogService.error(e);
    }

    directory.getTitle();

    Font fontTitle = new Font(
            DirectoryUtils.convertStringToInt(AppPropertiesService.getProperty(PROPERTY_POLICE_NAME)),
            DirectoryUtils
                    .convertStringToInt(AppPropertiesService.getProperty(PROPERTY_POLICE_SIZE_TITLE_DIRECTORY)),
            DirectoryUtils.convertStringToInt(
                    AppPropertiesService.getProperty(PROPERTY_POLICE_STYLE_TITLE_DIRECTORY)));
    fontTitle.isUnderlined();

    Paragraph paragraphHeader = new Paragraph(new Phrase(directory.getTitle(), fontTitle));
    paragraphHeader.setAlignment(Element.ALIGN_CENTER);
    paragraphHeader.setSpacingBefore(DirectoryUtils.convertStringToInt(
            AppPropertiesService.getProperty(PROPERTY_POLICE_SPACING_BEFORE_TITLE_DIRECTORY)));
    paragraphHeader.setSpacingAfter(DirectoryUtils.convertStringToInt(
            AppPropertiesService.getProperty(PROPERTY_POLICE_SPACING_AFTER_TITLE_DIRECTORY)));

    try {
        document.add(paragraphHeader);
    } catch (DocumentException e) {
        AppLogService.error(e);
    }

    builderPDFWithEntry(document, plugin, nIdRecord, listEntry, listIdEntryConfig, locale,
            bExtractNotFilledField);
    document.close();
}