Margin of a Document iTextPdf

Asked

Viewed 1,032 times

1

I am working with an existing PDF file, follow the small line of code:

    //Código...

    document = new Document(PageSize.A4);
    PdfWriter writer = PdfWriter.getInstance(document, fOut);
    document.open();
    PdfContentByte cb = writer.getDirectContent();
    // Load existing PDF
    PdfReader reader = new PdfReader(arquivo);
    PdfImportedPage page = writer.getImportedPage(reader, 1);
    document.setPageSize(reader.getPageSize(1));

    //Código...

My problem is this, I’m using the element Paragraph of iTextPdf and aligning each String in its proper place in existing PDF file using these methods:

    paragraph.setIndentationLeft(94f); //Movimenta horizontal
    paragraph.setLeading(14f); //Movimenta vertical

However, by placing a String more to stretch or right is as if there existed a margin, a space of approximately one inch that I can not overcome, the String break and continue below it or on the same line, I suspect it is some configuration of the element Document, I used the following methods unsuccessfully:

    document.setMargins(0, 0, 0, 0);
    document.setMarginMirroring(true);

Would anyone know how to RESET that margin??? I want to add one String right on the "edge" of the archive.

1 answer

1


The Document.setMargins() only acts on the next page. To act on the first page it is necessary to call it before the open.

  • Thank you very much my friend! I had not called me from this detail, I am very grateful because it worked perfectly!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.