Generate beautiful .pdf Files from xib

Overview

Description

The Library generates a PDF directly from interface builder with Auto-layouted views! Swift Version of UIView_2_PDF.

Installation

Download and drop SwiftPDFGenerator.swift in your project.

Usage

1. Make a xib file.

Your xib file should only consist of UILabels and/or UIImageViews and/or other UIView subviews. Use views that are 1 pixel high or wide to create lines. Set the tag of a UIView to 1 to have it draw filled or zero to draw as just a 1 pixel bordered box.

2. Load your xib like this

let pageOneView = NSBundle.mainBundle().loadNibNamed("PageOneView", owner: self, options: nil).last as! PageOneView
let pageTwoView = NSBundle.mainBundle().loadNibNamed("PageTwoView", owner: self, options: nil).last as! PageTwoView

3. Then generate your PDF like this

let filePath = SwiftPDFGenerator.generatePDFWithPages(pages)

See demo project for details.

License

swift-pdf is released under the MIT license. See 'LICENCE.md' for details.

You might also like...
PdfBuilder: a swift library made to make creation of the Pdf file from code simpler
PdfBuilder: a swift library made to make creation of the Pdf file from code simpler

PdfBuilder PdfBuilder is a swift library made to make creation of the Pdf file f

Mephisto - A command line tool to convert Comic Book Zip archives to PDF and share them over AirDrop
Mephisto - A command line tool to convert Comic Book Zip archives to PDF and share them over AirDrop

mephisto A command line tool written in Swift to convert Comic Book Zip archives

Small utility to import PDF slides as vector images into Keynote for iOS.
Small utility to import PDF slides as vector images into Keynote for iOS.

Small utility to import PDF files into Keynote for iOS. This utility is especially helpful when presenting slideshows created by LaTeX

Draw Week Time Table on PDF using PDFKit in iOS Swift
Draw Week Time Table on PDF using PDFKit in iOS Swift

DrawPDFTimeTable Draw Week Time Table on PDF using PDFKit in iOS Swift. Image Info This is the pdf of time table drawn using PDFKit in iOS Swift with

TPPDF is a simple-to-use PDF builder for iOS
TPPDF is a simple-to-use PDF builder for iOS

TPPDF is a fast PDF builder for iOS & macOS using simple commands to create advanced documents! Created and maintained by Philip Niedertscheider and a

Localization/I18n: Incrementally update/translate your Strings files from .swift, .h, .m(m), .storyboard or .xib files.
Localization/I18n: Incrementally update/translate your Strings files from .swift, .h, .m(m), .storyboard or .xib files.

Installation • Configuration • Usage • Build Script • Donation • Migration Guides • Issues • Contributing • License BartyCrouch BartyCrouch incrementa

PDF generator using UIViews or UIViews with an associated XIB

Description Create UIView objects using any method you like, including interface builder with Auto-layout and size classes enabled. Then generate a PD

A Static Library to be embedded on iOS applications to display pdf documents derived from Fast PDF

FastPdfKit This repository contains the FastPdfKit iOS library with some sample projects. FastPdfKit is a library that let you show pdf documents in i

Command-line utility that checks comments for localizations in iOS interface files (.xib, .storyboard)

Localizations Comments Checker It's really easy to overlook and don't add comment for localization in interface file (.storyboard or .xib). This comma

A command line tool to parse pricing from a pdf and generate an updated csv file for House Call Pro

A command line tool to parse pricing from a pdf and generate an updated csv file for House Call Pro

Merges a given number of PDF files into one file using the PDFKit framework

Titanium iOS PDF Merge Merges a given number of PDF files into one file using the PDFKit framework Requirements iOS 11+ Titanium SDK 9+ API's Methods

Swift package that uses WebKit to render PDF files from URLs

Swift package for generating a PDF file from a URL (rendered by WebKit)

PLHKit: A Swift DSL for Rendering and creating PDF Files.
PLHKit: A Swift DSL for Rendering and creating PDF Files.

PLHKit PLH is a tribute to Portsaid Light House, Port Said Lighthouse was the first building in the world created with reinforced concrete. 🌊 PLHKit

Annotation - Generate files to train with Object Detection by Create ML
Annotation - Generate files to train with Object Detection by Create ML

CreateML Annotation Generate files to train with Object Detection by Create ML.

Generate Swift and SwiftUI symbols for localized strings files.
Generate Swift and SwiftUI symbols for localized strings files.

localized-strings-symbols An SPM and Xcode build plugin for creating Swift symbols for localized string keys. What It Does This is a very simple build

Find common xib and storyboard-related problems without running your app or writing unit tests.
Find common xib and storyboard-related problems without running your app or writing unit tests.

IBAnalyzer Find common xib and storyboard-related problems without running your app or writing unit tests. Usage Pass a path to your project to ibanal

Setting up application specific localized string within xib file.
Setting up application specific localized string within xib file.

LocalizedView ##What is this? LocalizedView is a helper class for setting up application specific localized string within Xib file. Here is a video de

Easiest way to load view classes into another XIB or storyboard.
Easiest way to load view classes into another XIB or storyboard.

LoadableViews Easiest way to load view classes into another XIB or storyboard. Basic setup Subclass your view from LoadableView Create a xib file, set

This app can translate the MainMenu.xib automatically
This app can translate the MainMenu.xib automatically

Main Menu Translator This app can translate the MainMenu.xib automatically. Desc

Comments
  • Library simplified

    Library simplified

    Hey @kayoslab, I'd like you to take a look at my fork. I simplified the library folders and files to make it really easy for the devs to install and use the library as easy and quickly as possible.

    What do you think?

    opened by lfarah 1
  • UITextView.text always with default Values

    UITextView.text always with default Values

    The font and textColor Properties are not set when PdfFileGenerator.drawPageWithContext(page:UIView, context: CGContextRef) is called. The query always returns false and continues with default Values.

    opened by kayoslab 1
  • .ScaleAspectFit query could be more lucid

    .ScaleAspectFit query could be more lucid

    Very confusing implementation of the .ScaleAspectFit behaviour. This could be more lucid.

    if (subview.isKindOfClass(UIImageView)) {
        if let image = imageView.image {
            if (imageView.contentMode == .ScaleAspectFit) {
                if (image.size.width > imageView.frame.size.width || image.size.height > imageView.frame.size.height) {
                    if (image.size.width < image.size.height) {
                        // Landscape format
                        if (ratioWidth > imageView.frame.size.width) {
                            // Portrait does not fit into subview:UIImageView
                        } else {
                            // Portrait fits into subview:UIImageView
                        }
                    } else {
                        // Portrait format
                        if (ratioHeight > imageView.frame.size.height) {
                            // Landscape does not fit into subview:UIImageView
                        } else {
                            // Landscape fits into subview:UIImageView
                        }
                    }
                } else {
                    // Image is smaller than subview:UIImageView
                }
            } else {
                 // contentMode is not .ScaleAspectFit
            }
        }
    }
    
    opened by kayoslab 0
Releases(v1.0.0)
Owner
Simon C. Krüger
»Never put off until run time what you can do at compile time.« (David Gries, in "Compiler Construction for Digital Computers", ca 1969)
Simon C. Krüger
A Static Library to be embedded on iOS applications to display pdf documents derived from Fast PDF

FastPdfKit This repository contains the FastPdfKit iOS library with some sample projects. FastPdfKit is a library that let you show pdf documents in i

Dimension 1.2k Dec 22, 2022
Swift package that uses WebKit to render PDF files from URLs

Swift package for generating a PDF file from a URL (rendered by WebKit)

aaronland 1 Feb 25, 2022
PLHKit: A Swift DSL for Rendering and creating PDF Files.

PLHKit PLH is a tribute to Portsaid Light House, Port Said Lighthouse was the first building in the world created with reinforced concrete. ?? PLHKit

null 10 Sep 2, 2022
A simple generator of PDF written in Swift.

Features | Requirements | Installation | Usage | Communication | LICENSE PDFGenerator PDFGenerator is a simple PDF generator that generates with UIVie

Suguru Kishimoto 712 Dec 29, 2022
SimplePDF is a wrapper of UIGraphics PDF context written in Swift.

SimplePDF is a wrapper of UIGraphics PDF context written in Swift. You can: add texts, images, spaces and lines, table set up page layout, adjust cont

Nutchaphon Rewik 238 Dec 29, 2022
An iOS PDF viewer and annotator written in Swift that can be embedded into any application.

Requirements iOS 9 or above Xcode 8 or above Swift 3.0 Note This project is still in early stages. Right now the PDF reader works both programmaticall

UXM Studio 269 Dec 11, 2022
PDF Reader Core for iOS

PDF Reader Core for iOS This project is no longer supported or maintained. It is only here for historical reasons. Please see the UXReader PDF Framewo

Julius Oklamcak 4.3k Jan 6, 2023
TPPDF is a simple-to-use PDF builder for iOS

TPPDF is a fast PDF builder for iOS & macOS using simple commands to create advanced documents! Created and maintained by Philip Niedertscheider and a

techprimate 582 Jan 6, 2023
UIImage PDF extensions.

UIImagePlusPDF UIImage extensions to use PDF files. Using UIImagePlusPDF you can avoid a lot png images files (1x, 2x, 3x sizes) and simply replace ea

Dmytro Mishchenko 35 Jan 4, 2023
Estrutura Simples para Navegacao Web e Download PDF

Download-PDF-WebView Projeto desenvolvido em Swift com a função de criar uma estrutura simples para navegação Web em seu Aplicativo, permitindo a visu

Josué Rodrigues 1 Nov 30, 2021