0

I'm using an obsolete version of iText to create and merge documents. I use the abandoned HTMLWorker class to parse some business related contents. I would then merge or concatenate an existing PDF file at the end of this document. In the resulting file, that extra file gets rotated and cut off. This happens many times but not always. How can I prevent this?

document.newPage();
PdfImportedPage page = pdfw.getImportedPage(reader, i+1);
pcb.addTemplate(page, 0,0);
Bruno Lowagie
  • 75,994
  • 9
  • 109
  • 165
dev123
  • 11
  • 1
  • 5
  • This question is answered in [The Best iText Questions on StackOverflow](http://pages.itextpdf.com/ebook-stackoverflow-questions.html). You can find the answer [here](http://stackoverflow.com/questions/21731439/pdf-page-cutting-through-itext-api); unfortunately, I can't mark this question as duplicate, because nobody had the decency to accept/upvote my correct answer. Furthermore, you should understand that [you should not use "lowagie", you should use iText](http://stackoverflow.com/questions/25696851/can-itext-2-1-7-or-earlier-can-be-used-commercially). By the way, **I am Lowagie:** – Bruno Lowagie Feb 02 '15 at 09:14
  • Furthermore: `HTMLWorker` has been abandoned a long time ago because (1.) it was an ad hoc implementation of only a limited set of HTML tags, and (2.) the code was beyond repair. You should use [XML Worker](http://itextpdf.com/product/xml_worker) instead. – Bruno Lowagie Feb 02 '15 at 09:16
  • You are adding a new page to the `Document` with a certain page size. When you add a new page with *the same page size and rotation*, you throw away all interactivity that exists in that page, but otherwise all is well. When you add a new page with *a different page size and rotation*, you get the result you describe. Please read the documentation and stop using obsolete versions of iText and abandoned techniques. – Bruno Lowagie Feb 02 '15 at 09:33
  • 1
    Upvoted the answer in the first comment, because it looks (to my uninitiated eye) comprehensive and useful. Pity the original poster didn't accept it :-( – KenS Feb 02 '15 at 09:41
  • Thanks, now we can close this question. I've updated my original answer to make it even more comprehensive. Now I'm not only explaining how to solve the problem, but also what causes the problem. – Bruno Lowagie Feb 02 '15 at 09:51
  • Thanks Lowagie for your answers. Actually you had mentioned this issue occurs because of adding a different page size and rotation, if I use smartCopy will it take care of this issue? – dev123 Feb 09 '15 at 14:48

0 Answers0