PdfBuilder: a swift library made to make creation of the Pdf file from code simpler

Related tags

PDF PdfBuilder
Overview

PdfBuilder

PdfBuilder is a swift library made to make creation of the Pdf file from code simpler. It's inspired by SwiftUI and give similar declarative interface to design page layout.

Layout components

- Background
- ClipShape
- Divider
- Grid
- Image
- Padding
- PageBackground
- PageBreak
- PageCounter
- PageHeader
- Spacer
- Text
- VStack

StringAttributes

Alias for NSAttributedString.Key dictionary allows union multiple dictionaries in a shorter way

StringAttributes.caption().foregroundColor(.red)

Sample

Code Pdf preview
let builder = Pdf.Builder()

builder.items = [
    Pdf.PageHeader(top: [
        Pdf.Spacer( 8),
        Pdf.Text("Page header"),
        Pdf.Spacer( 8),
    ], bottom: [
        Pdf.Spacer( 8),
        Pdf.Text("Page footer"),
        Pdf.Spacer( 8),
    ], backgroundColorFill: .lightGray),

    Pdf.Background(color: .green, Pdf.Text("Some text")),
    Pdf.Divider(),

    Pdf.Text("Some text", attributes: .boldRed()),
    Pdf.Divider(),

    Pdf.Text([
        NSAttributedString(
            string: "Some",
            attributes: .bold()),
        NSAttributedString(
            string: "text",
            attributes: .boldRed())
    ].joined(with: " ")),

    Pdf.Spacer(20),

    Pdf.Grid(columns: [.fixed(v: 25), .flexible], items: [
        Pdf.Text("*"),
        Pdf.Text(lorem)
    ]),

    Pdf.Spacer(20),

    Pdf.Grid(columns: [.fixed(v: 25), .flexible], items: [
        Pdf.Text("* 1"),
        Pdf.Text(lorem),
        Pdf.Text("* 2"),
        Pdf.Text(lorem)
    ]),

    Pdf.PageHeader(top: [
        Pdf.Text("Second page header"),
        Pdf.Spacer( 8),
    ]),

    Pdf.Spacer(20),

    Pdf.Grid(
        columns: [
            .fixed(v: 25), .flexible,
            .fixed(v: 25), .flexible],
        items: [
            
            Pdf.Text("* 1"),
            Pdf.Text(lorem)
                .padding(16)
                .background(.orange),
            
            Pdf.Text("* 2"),
            Pdf.Padding(
                size: 16, Pdf.Background(
                    color: .green, Pdf.Text(lorem2))),
            
            Pdf.Text("* 3"),
            Pdf.Image(UIImage(systemName: "person")),
            Pdf.Text("* 4"),
            Pdf.VStack([
                Pdf.Text("Row 1"),
                Pdf.Text("Row 2"),
                Pdf.Text("Row 3"),
                Pdf.Text("Row 4")
            ]).padding(16)
    ])
]

let data = builder.generateNewPdf() as Data
You might also like...
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

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

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

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

📚 A Swift ePub reader and parser framework for iOS.
📚 A Swift ePub reader and parser framework for iOS.

FolioReaderKit is an ePub reader and parser framework for iOS written in Swift. Features ePub 2 and ePub 3 support Custom Fonts Custom Text Size Text

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

URLScheme router than supports auto creation of UIViewControllers for associated url parameters to allow creation of navigation stacks

IKRouter What does it do? Once you have made your UIViewControllers conform to Routable you can register them with the parameters that they represent

This app is a sample app that recognizes specific voice commands such as
This app is a sample app that recognizes specific voice commands such as "make it red", "make it blue", "make it green", and "make it black" and change the background color of the view in the frame.

VoiceOperationSample This app is a sample app that recognizes specific voice commands such as "make it red", "make it blue", "make it green", and "mak

Capacitor File Opener. The plugin is able to open a file given the mimeType and the file uri
Capacitor File Opener. The plugin is able to open a file given the mimeType and the file uri

Capacitor File Opener. The plugin is able to open a file given the mimeType and the file uri. This plugin is similar to cordova-plugin-file-opener2 without installation support.

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

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

A simpler way to work with NSLayoutAnchor
A simpler way to work with NSLayoutAnchor

SugarAnchor is syntactic sugar on NSLayoutAnchor to help us write more compact, readable and easy layout code. It wraps up all of NSLayoutXAxisAnchor,

Tools for making SwiftUI navigation simpler, more ergonomic and more precise.
Tools for making SwiftUI navigation simpler, more ergonomic and more precise.

SwiftUI Navigation Tools for making SwiftUI navigation simpler, more ergonomic and more precise. Motivation Tools Navigation overloads Navigation view

A simpler way to do cool UITableView animations! (╯°□°)╯︵ ┻━┻
A simpler way to do cool UITableView animations! (╯°□°)╯︵ ┻━┻

TableFlip (╯°□°)╯︵ ┻━┻ ┬──┬ ノ( ゜-゜ノ) Animations are cool. UITableView isn't. So why not make animating UITableView cool? The entire API for TableFlip

Date Formatter Pool - is a small utility that creates and stores your Date Formatter for simpler reuse
Date Formatter Pool - is a small utility that creates and stores your Date Formatter for simpler reuse

Date Formatter Pool Date Formatter Pool - is a small utility that creates and stores your Date Formatter for simpler reuse Installation is available i

CompositionalLayoutDSL, library to simplify the creation of UICollectionViewCompositionalLayout. It wraps the UIKit API and makes the code shorter and easier to read.
CompositionalLayoutDSL, library to simplify the creation of UICollectionViewCompositionalLayout. It wraps the UIKit API and makes the code shorter and easier to read.

CompositionalLayoutDSL CompositionalLayoutDSL is a Swift library. It makes easier to create compositional layout for collection view. Requirements Doc

Clocks made out of clocks made out of code

Clocks I came across this digital clock composed out of a set of analog clocks, created by Humans Since 1982, in a tweet, so I decided to remake it in

SmartString - A powerful and small library that will allow the creation of complex String Styles
SmartString - A powerful and small library that will allow the creation of complex String Styles

SmartString A powerful and small library that will allow the creation of complex

Comments
  • Licensing query

    Licensing query

    Hi there. This is a great repository - thanks for your work on it. I just checked and saw that there is no license file. I wanted to check if you are agreeable for the code to be used as open source, and if so, could a license file be added? With your permission I could submit a PR to add one.

    Thanks Chris

    opened by chriswilson1982 1
Releases(0.1.0)
Owner
null
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
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

Kushagra Chandra 6 Nov 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
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
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

null 34 Dec 17, 2022
Generate beautiful .pdf Files from xib

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

Simon C. Krüger 16 Dec 17, 2022
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