Hey,
I had the same issue, setting a CGRect to a PDFPage does work with the .setBounds(pageRect, for: .mediaBox) method, but finding a proper size to input was an issue.
After some research, I found out the size should be expressed in PostScript Points
I'm using the size I found there for A4 and US Letter:
https://pdfkit.org/docs/paper_sizes.html
A4 (595.28 x 841.89)
LETTER (612.00 X 792.00)
App side I check NSLocale.current.usesMetricSystem to switch between the two.
Have a good one.
Adrien.