Welcome to the SwiftUI PDF Generator sample project! This project demonstrates how to create and share a PDF from a SwiftUI view using the ImageRenderer. Whether you want to document your SwiftUI designs, create polished presentations, or share visual content, this sample project is here to guide you through the process.
Follow these steps to integrate SwiftUI PDF generation into your project:
git clone https://github.com/emomchilov/SwiftUI-PDF.git
Open the project in Xcode:
cd SwiftUI-PDF
xed .
Check PDFView.swift for an example SwiftUI view (PDFView) that you want to convert into a PDF. Adjust the view content, layout, and styling based on your requirements. Configure PDF parameters:
Adjust the values in the Constants struct in PDFView.swift for page dimensions and dots per inch.
Open PDFCreator.swift to see how the PDF is generated using UIGraphicsPDFRenderer and ImageRenderer. Customize the metadata and format according to your needs.
Check SharePDFView.swift for an example of how to use ShareLink to share the generated PDF. Modify the PDFInfo array with your desired PDF content.
Test the PDF generation and sharing by running the app in the simulator.
Integrate the PDF generation and sharing logic into your own SwiftUI project.
Contributions are welcome! If you find any issues or have improvements to suggest, feel free to open an issue or create a pull request.