4

I am trying to create a PDF using HTML content. Everything is fine but i have one problem where the page breaks on PDF get inserted between content and cause it to divide between pages.

Example: A portrait image with height>width get a page break half way in between and causes half image to be on page 1 and the other half to be on page 2. This is just an example, the content on my PDF is dynamic, meaning the user has control over generating amount of content. Therefore its not necessary that image be always on page 1 it could be anywhere on the document.

I have tried to search for some libraries also but as per my understanding of how PDF files are rendered in iOS, I don't have any clue how to manage content that gets divided due to the page breaks.

Platform: iOS 10, xcode 8, Objective-C

Rishabh
  • 465
  • 5
  • 14

1 Answers1

1

Try to add something like the following to your css.

img { page-break-inside:avoid }

See also:

Print styles: How to ensure image doesn't span a page break

michael - mlc
  • 376
  • 5
  • 5
  • 1
    doesnt seem to work, i read its something to do with the browser or something so this property is not recognised – Rishabh Oct 24 '17 at 12:01