Changing text line spacing

According to the PDF specification, the distance between the baseline of two lines is called the leading. In iText, the default leading is 1.5 times the size of the font. For instance: the default font size is 12 pt, hence the default leading is 18. You can change the leading of a Paragraph by using … Read more

Invalidpdfexception pdf header signature not found

If a file doesn’t start with %PDF- then there’s nothing to fix: the file isn’t a PDF file. However, there may be another problem: maybe you’re trying to access a file that has zero length due to some problem while creating the InputStream. Another context in which I’ve seen this happen, is a PDF loaded … Read more

Manipulate paths, color etc. in iText

Now, what’s the way to go with manipulating things and writing them back to the PDF? Do I have to construct an entirely new PDF document and copy everything over (in manipulated form), or can I somehow manipulate the read PDF data directly? In essence you are looking for a class which is not merely … Read more

iText 5 HTML+CSS to PDF/A-2 : Helvetica font not embedded error

We are using our very own PrintFontProvider. This should get you going: private static final CSSResolver cssResolver = XMLWorkerHelper.getInstance().getDefaultCssResolver(true); private static final HtmlPipelineContext htmlContext = new HtmlPipelineContext(null); static { htmlContext.setTagFactory(Tags.getHtmlTagProcessorFactory()); htmlContext.autoBookmark(false); // Our own PrintFontProvider provides Fonts as needed… htmlContext.setCssAppliers(new CssAppliersImpl(new PrintFontProvider())); // We apply some default styles to the pdf generation… try { String … Read more

How to fit a String inside a rectangle?

There are three options: Either you provide a bigger rectangle, so that the content fits inside, or you reduce the content (e.g. smaller font, less text),… Keep the size of the rectangle, keep the font size, etc… but add the content that doesn’t fit on the next page. How do you know if the content … Read more