dart_pdf
dart_pdf copied to clipboard
IOS 15 ignore PdfPageFormat
When I try to use Printing.layoutPdf with IOS 15 it looks like format of my page is ignoring so I get a very long result.

For example, if I print saved pdf file via sharing, the result is ok. In that case I see paper size option.

Printing works ok in IOS 14 and lower. What do you think? any idea?
@Oleksandr32 any code to share?
@DavBfr here how I use this plugin
final format = PdfPageFormat(
50 * PdfPageFormat.mm,
54 * PdfPageFormat.mm,
marginAll: 2 * PdfPageFormat.mm,
);
Uint8List data = await Printing.convertHtml(
format: format,
html: response.body, // here result of api call
baseUrl: '',
);
return Printing.layoutPdf(
format: format,
onLayout: (format) {
return data;
},
dynamicLayout: true,
);
I have fixed that by adding this code to ios plugin implementation PrintJob
class
// Workaround
public func printInteractionController(_ printInteractionController: UIPrintInteractionController, choosePaper paperList: [UIPrintPaper]) -> UIPrintPaper {
if currentSize == nil {
return paperList[0]
}
return UIPrintPaper.bestPaper(forPageSize: currentSize!, withPapersFrom: paperList)
}
where currentSize
is size from
func printPdf(name: String, withPageSize size: CGSize, andMargin margin: CGRect, withPrinter printerID: String?, dynamically dyn: Bool)
I found this workaround here https://developer.apple.com/forums/thread/30197
@DavBfr This behaviour I only notice in IOS 15. Please let me know if you will investigate this.
Looks good, can you create a PR?
@DavBfr of course, here PR https://github.com/DavBfr/dart_pdf/pull/944
I have same Problem. Any news about the PR?
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days
Closing this stale issue because it has no activity.