0

PdfContentByte.addTemplate(pdfImportedPage, 0, 0) behaves strangely. For some static pdf files which I am adding to document, it works fine. But for one file or pdf page with same size as others, some of upper text get truncated and vertical position of content on that page moves upper.

PdfContentByte cb = pdfWriter.getDirectContent();
String pdfName = "MyStaticFile.pdf";
PdfReader reader = new PdfReader(pdfName);
PdfImportedPage page = pdfWriter.getImportedPage(reader, 1);
cb.addTemplate(page, 0, 0);
Kishor
  • 31
  • 1
  • 8
  • Share an example file for which you observe an issue. I would assume the problem to be differing media box and crop box values. – mkl Feb 03 '17 at 07:47
  • Adding pages using `PdfImportedPage` and `addTemplate()` is usually a bad idea. I have closed the question for that reason. – Bruno Lowagie Feb 03 '17 at 07:51
  • When I get page using getImportedPage method, returned page has bBox of size Rectangle: 612.0x1008.0 (rot: 0 degrees) (when I open same pdf and other pdf using Adobe and do right click, properties, it shows size as 8.5 X 11). But other pages has size Rectangle: 612.0x792.0 (rot: 0 degrees). – Kishor Feb 03 '17 at 09:27
  • Solved the problem by replacing pdf file with correct dictionary values. Now getImportedPage() method returns correct values as Rectangle: 612.0x792.0 (rot: 0 degrees) – Kishor Feb 03 '17 at 10:06

0 Answers0