Skip to content

How do I create PDFs at the right page size? #3

@lhr0909

Description

@lhr0909

Hi,

I am checking in after doing integration with the library. So far it is working very well, and we could render very high quality PDFs, which is great!

When we were checking the size of the PDF (width and height), and found that it was way larger than what it was set at render time (A4). We are looking at a number that is almost like a A0 size from MacOS preview.

We found this issue when we were trying to merge existing PDFs together and found that our renders were way larger than A4s.

I am sending an example output from our code:

        let document = PDFViewKit.PDFDocument {
            ReceiptPDFContentView(
                data: exportData,
                attachmentImage: attachmentImage,
                hasPDFAttachment: isPDFAttachment
            )
        }

        try await MainActor.run {
            try PDFRenderer.render(
                document: document,
                to: destinationURL,
                atPageSize: DIN.a4
            )
        }
Image Image

We now had to scale the attached PDF to make it look right, so it is less than ideal, but not the end of the world.

Please advice if there is a better way to render it. I have been checking the lib source code and we were not wrapping our content view with PDFPage and I am not sure if we need to in order to control the output size. Cheers!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions