Haroon
Haroon

Reputation: 3472

WkHtmlToPDF displays a tiny pdf if text is too long

I am not sure how to overcome this problem even though I have set the page size to be A4, I would assume that my page size would remain intact and my content would be wrapped correctly?

note I am using the wrapper WkHtmlToXSharp to create my pdf

enter image description here

Issue: If you enter strings that are not split, i.e. one long string - what I have showed in the image above will occur. How do I fix this? Is there some options for WkhtmlToPDF to wrap the text?

Upvotes: 5

Views: 4086

Answers (3)

Joel Peltonen
Joel Peltonen

Reputation: 13402

If you want a CSS solution, you could try setting a width for the element that overflows and then testing with word-wrap: break-word;, overflow:hidden; and white-space: nowrap to control the issue, some of these or a combination might work for you. As for a wkhtmltopdf solution that would be universal... If you find any, I want one too!

Upvotes: 1

netrox
netrox

Reputation: 5326

You need to break the pages. It's easy as adding this:

<div style='page-break-after:always'></div>

For example, if you have a long table, you can do like this pseudo-code:

 if ($row > 100) {
   echo "</table>"; 
   echo "<div style='page-break-after:always'></div>";
   echo "<table>"; }

Upvotes: 0

Related Questions