![]() You can then invoke the pdfData(actions:) of the renderer which provides you a block with the context that allows you to use drawing methods in CoreGraphics framework to start drawing texts or images etc, such as follows: let data = renderer. 13min read Generating PDF Reports dynamically can be extremely useful while developing Swift applications. ![]() Let renderer = UIGraphicsPDFRenderer(bounds:pageRect, format: format) Let format = UIGraphicsPDFRendererFormat()įormat.documentInfo = pdfMetaData as To instantiate it, you need to specify its bounds and an optional parameter for its format, as follows: let pdfMetaData = [kCGPDFContextCreator: "My First PDF File", To create PDF file with the PDFKit, all you need is instantiate the key class UIGraphicsPDFRenderer in PDFKit framework. ![]() This is especially useful for apps that need to generate receipts, bills, invoices or any other confidential or important documents. PDF is useful so we can generate files that cannot be modified and shared or sent to others. After diving in into the topic and some calculations based in the PDF documentation, I ended up with the magic number: let cm CGFloat (28.346), resulting in: let cm CGFloat (28.346) // 72.0 / 2.54, Resolution divided by conversion factor inch -> cm let a4Width CGFloat (21.0) // A4 width in cm let a4Height CGFloat (29.7) // A4 height in. PDFKit is the framework by Apple that you need to display and manipulate PDF files in your app. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |