sgr-ksmt / PDFGenerator

A simple generator of PDF written in Swift.
MIT License
757 stars 110 forks source link

Rendering an area of a scrollview on a DPI different than the default leads to unpredictable results #103

Open alinradut opened 5 years ago

alinradut commented 5 years ago

Steps to reproduce:

Modify the generate() call in SampleTableViewController.swift:generatePDF() to

try PDFGenerator.generate(PDFPage.viewArea(tableView, area: tableView.rect(forSection: 0)), to: dst, dpi: .dpi_300)

Instead of just the first section area the entire scroll view will be rendered.

Additionally, calling:

try PDFGenerator.generate(PDFPage.viewArea(tableView, area: tableView.rect(forSection: 1)), to: dst, dpi: .dpi_300)

will result in an empty page. My guess is that there's something wrong with the calculations taking place in PDFPageRenderable.swift:_render() when scaleFactor is different than 1.0.