Managing page breaks in a PDF generated via HTML [iOS]

I am trying to create a PDF using HTML content. Everything is fine, but I have one problem when a page break in a PDF is inserted between the content and makes it split between pages.

Example: A portrait image with a width> page width breaks the page between half and causes the half image on page 1 and the other half on page 2. This is just an example, the contents of my PDF file is dynamic, which means the user has control over the generation of the number content. Therefore, it is not necessary that the image is always on page 1, it could be anywhere on the document.

I also tried to find some libraries, but in my understanding of how PDF files are displayed in iOS, I don’t know how to manage content that is shared due to page breaks.

Platform: iOS 10, xcode 8, Objective-C

+4
source share
1 answer

Try adding something like the following to your css.

img { page-break-inside:avoid }

See also:

Print Styles: How to Ensure Your Image Does Not Cover a Page Break

+1
source

Source: https://habr.com/ru/post/1687695/


All Articles