Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
philprime committed Apr 22, 2024
1 parent 40d9e47 commit 42d171e
Show file tree
Hide file tree
Showing 96 changed files with 2,345 additions and 2,136 deletions.
2 changes: 1 addition & 1 deletion Documentation/Usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ Also each cell can have a `margin` which is the distance between the cell frame
document.add(table: table)
```

## Multi-Column Sections
### Multi-Column Sections

A multi-column section is a nested container. You create the section with an amount of columns and their relative width, add objects to each column and then add the whole section to the document.

Expand Down
31 changes: 18 additions & 13 deletions Shared/Examples/TableOfContentsExampleFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,32 @@
//

#if os(iOS)
import UIKit
import UIKit
#elseif os(macOS)
import AppKit
import AppKit
#endif
import TPPDF

class TableOfContentsExampleFactory: ExampleFactory {

func generateDocument() -> [PDFDocument] {
let document = PDFDocument(format: .a4)

// Define doccument wide styles
let titleStyle = document.add(style: PDFTextStyle(name: "Title",
font: Font.boldSystemFont(ofSize: 50.0),
color: Color(red: 0.171875, green: 0.2421875, blue: 0.3125, alpha: 1.0)))
let headingStyle1 = document.add(style: PDFTextStyle(name: "Heading 1",
font: Font.systemFont(ofSize: 15),
color: Color.black))
let headingStyle2 = document.add(style: PDFTextStyle(name: "Heading 2",
font: Font.systemFont(ofSize: 10),
color: Color.black))
let titleStyle = document.add(style: PDFTextStyle(
name: "Title",
font: Font.boldSystemFont(ofSize: 50.0),
color: Color(red: 0.171875, green: 0.2421875, blue: 0.3125, alpha: 1.0)
))
let headingStyle1 = document.add(style: PDFTextStyle(
name: "Heading 1",
font: Font.systemFont(ofSize: 15),
color: Color.black
))
let headingStyle2 = document.add(style: PDFTextStyle(
name: "Heading 2",
font: Font.systemFont(ofSize: 10),
color: Color.black
))

// Add a string using the title style
document.add(.contentCenter, textObject: PDFSimpleText(text: "TPPDF", style: titleStyle))
Expand Down Expand Up @@ -69,7 +74,7 @@ class TableOfContentsExampleFactory: ExampleFactory {
document.add(space: 10)

document.add(text: LoremIpsum.get(words: 10))

return [document]
}
}
14 changes: 8 additions & 6 deletions Source/API/Delegation/PDFGeneratorImageDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@

import CoreGraphics

/// Protocol used to delegate drawing of images
public protocol PDFGeneratorImageDelegate: AnyObject {
/**
* Called directly before a ``PDFImage`` is drawn into the graphics context
*
* As the `image` is a reference object, it is possible to read and manipulate the object before rendering.
*
* One use-case could be overlaying the ``PDFImage/image`` with a watermark, after it final frame is calculated.
*/
func generator(willBeginDrawingImage image: PDFImage, with context: PDFContext, in frame: CGRect)
}

public extension PDFGeneratorImageDelegate {

func generator(willBeginDrawingImage image: PDFImage, with context: PDFContext, in frame: CGRect) {}

}
Loading

0 comments on commit 42d171e

Please sign in to comment.