1

I am generating pdf from html. I am using dynamic html generator(Apache-velocity) and using jsoup for html parsing. I generate pdf successfully, issue is html content not aligned properly in pdf after generation. I already visited this question unluckily its unanswered.

Mohanraj
  • 396
  • 3
  • 8
  • 21
  • Your question seems to be about Flying Saucer, not about iText. – Amedee Van Gasse Feb 01 '18 at 08:00
  • sorry for that. – Mohanraj Feb 01 '18 at 09:08
  • Can you show the HTML used to generated the PDF, and explain what you mean by "not aligned properly" ? – obourgain Feb 01 '18 at 17:55
  • 1
    I am having sample pdf consist 3 pages.I converted it into `html` and I am generating pdf using that html file. Issue is generated pdf contains 4 pages.I am having 2 tables in html which are not aligned properly in pdf, like row of the table separately printed in different pages.I used`@page { margin-left: 1cm; margin-right: 1cm; } tr{ page-break-inside:avoid; }` in my html but it cheats me – Mohanraj Feb 02 '18 at 04:53

1 Answers1

1

Margin can be set in html in head tag using style tag. Sample for adding 1px margin is shown. In my case for flying saucer library it worked well with this.

<head><style>@page {size: Wpx 1px;margin:0px;}<style/><head/>
Brandon Kauffman
  • 1,515
  • 1
  • 7
  • 33