Search code examples
itextpdf-generation

iTextPDF: Setting Artbox & Trimbox for PDF


I am setting PDF/X conformance using iText.

Having trimbox and artbox is one of the requirement of PDF/X. How can it be set? Im using the following code to set page size, pageSize = new com.lowagie.text.Rectangle(height, width); document = new Document(pageSize, 0, 0, 0, 0);

Kindly Help.


Solution

  • Page boundaries can be set using the setBoxSize() method. For instance:

    writer.setBoxSize("art", new Rectangle(36, 36, 559, 806));
    writer.setBoxSize("trim", new Rectangle(36, 36, 559, 806));
    

    I don't know when the setBoxSize() method was introduced, but I see my name in your code sample. When I see my name in your code, I know that you are using a version of iText that is obsolete and therefore unsupported. The last version with my name in the packages dates from July 2009. Please understand that those versions also can't be used in a commercial context because of IP issues that were discovered after those versions were released under the LGPL.

    See Can iText 2.1.7 / iTextSharp 4.1.6 or earlier be used commercially? for more info.