Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ name: Documentation
on:
release:
types: [published]
push:
branches: [main]

jobs:
deploy_docs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
xcodebuild -workspace . \
-scheme "TPPDF" \
-sdk iphonesimulator \
-destination "OS=16.0,name=iPhone 14 Pro" \
-destination "OS=16.2,name=iPhone 14 Pro" \
-configuration Debug \
-enableCodeCoverage YES \
-derivedDataPath /tmp/DerivedData \
Expand Down
9 changes: 9 additions & 0 deletions Source/API/Delegation/PDFGeneratorDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//
// PDFGeneratorImageDelegate.swift
// TPPDF
//
// Created by Chris Gonzales on 10/10/20.
//

/// Delegation protocol combining all delegates supported by the PDFGenerator
public typealias PDFGeneratorDelegate = PDFGeneratorImageDelegate
18 changes: 18 additions & 0 deletions Source/API/Delegation/PDFGeneratorImageDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// PDFGeneratorImageDelegate.swift
// TPPDF
//
// Created by Chris Gonzales on 10/10/20.
//

import CoreGraphics

public protocol PDFGeneratorImageDelegate: AnyObject {
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){}

}
3 changes: 3 additions & 0 deletions Source/API/PDFGenerator+Generation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,9 @@ extension PDFGenerator {
- throws: PDFError, if rendering fails
*/
internal func render(object: PDFRenderObject, in container: PDFContainer, in context: PDFContext) throws {
if let imageObject = object as? PDFImageObject {
delegate?.generator(willBeginDrawingImage: imageObject.image, with: context, in: object.frame)
}
try object.draw(generator: self, container: container, in: context)
}

Expand Down
3 changes: 3 additions & 0 deletions Source/API/PDFGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ public class PDFGenerator: PDFGeneratorProtocol, CustomStringConvertible {
Relative value tracking progress
*/
public let progress = Progress.discreteProgress(totalUnitCount: 3)

/// Object acts as a delegate during the generation process
public var delegate: PDFGeneratorDelegate?

/**
Font of each container.
Expand Down
6 changes: 5 additions & 1 deletion Source/API/Text/PDFAttributedText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,9 @@ public class PDFAttributedText: PDFText {
return true
}

// MARK: - Hasha
// MARK: - Hashable

public override func hash(into hasher: inout Hasher) {
hasher.combine(text)
}
}
5 changes: 5 additions & 0 deletions Source/API/Text/PDFSimpleText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,9 @@ public class PDFSimpleText: PDFText {
}

// MARK: - Hashable

override public func hash(into hasher: inout Hasher) {
hasher.combine(text)
hasher.combine(spacing)
}
}
3 changes: 2 additions & 1 deletion Source/API/Text/PDFText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
/// Protocol all text objects should implement
public class PDFText: PDFDocumentObject, CustomStringConvertible {

var copy: PDFText {
public var copy: PDFText {
fatalError()
}
}

16 changes: 16 additions & 0 deletions TPPDF.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
D49B05E82658E76C0084A0B7 /* PDFDocument.swift in Sources */ = {isa = PBXBuildFile; fileRef = D49B05E62658E76C0084A0B7 /* PDFDocument.swift */; };
D49B05E92658E76C0084A0B7 /* PDFDocumentBackground.swift in Sources */ = {isa = PBXBuildFile; fileRef = D49B05E72658E76C0084A0B7 /* PDFDocumentBackground.swift */; };
D4B30533293CA38600EA24C5 /* PDFPageFormat+NameConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4B30532293CA38600EA24C5 /* PDFPageFormat+NameConstants.swift */; };
D4E1FB2C294DE37800D654C7 /* PDFGeneratorImageDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4E1FB2A294DE37800D654C7 /* PDFGeneratorImageDelegate.swift */; };
D4E1FB2D294DE37800D654C7 /* PDFGeneratorDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4E1FB2B294DE37800D654C7 /* PDFGeneratorDelegate.swift */; };
OBJ_415 /* CwlCatchException.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_356 /* CwlCatchException.swift */; };
OBJ_417 /* CwlCatchExceptionSupport.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = "CwlCatchException::CwlCatchExceptionSupport::Product" /* CwlCatchExceptionSupport.framework */; };
OBJ_425 /* Package.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_362 /* Package.swift */; };
Expand Down Expand Up @@ -635,6 +637,8 @@
D49B05E62658E76C0084A0B7 /* PDFDocument.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PDFDocument.swift; sourceTree = "<group>"; };
D49B05E72658E76C0084A0B7 /* PDFDocumentBackground.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PDFDocumentBackground.swift; sourceTree = "<group>"; };
D4B30532293CA38600EA24C5 /* PDFPageFormat+NameConstants.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "PDFPageFormat+NameConstants.swift"; sourceTree = "<group>"; };
D4E1FB2A294DE37800D654C7 /* PDFGeneratorImageDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PDFGeneratorImageDelegate.swift; sourceTree = "<group>"; };
D4E1FB2B294DE37800D654C7 /* PDFGeneratorDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PDFGeneratorDelegate.swift; sourceTree = "<group>"; };
"Nimble::Nimble::Product" /* Nimble.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Nimble.framework; sourceTree = BUILT_PRODUCTS_DIR; };
OBJ_10 /* PDFExternalDocument.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PDFExternalDocument.swift; sourceTree = "<group>"; };
OBJ_101 /* PDFContext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PDFContext.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1111,6 +1115,15 @@
path = Document;
sourceTree = "<group>";
};
D4E1FB29294DE37800D654C7 /* Delegation */ = {
isa = PBXGroup;
children = (
D4E1FB2A294DE37800D654C7 /* PDFGeneratorImageDelegate.swift */,
D4E1FB2B294DE37800D654C7 /* PDFGeneratorDelegate.swift */,
);
path = Delegation;
sourceTree = "<group>";
};
OBJ_100 /* Graphics */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -1987,6 +2000,7 @@
OBJ_38 /* PDFGenerator+Generation.swift */,
OBJ_40 /* PDFGeneratorProtocol.swift */,
OBJ_41 /* PDFMultiDocumentGenerator.swift */,
D4E1FB29294DE37800D654C7 /* Delegation */,
D49B05E52658E76C0084A0B7 /* Document */,
OBJ_9 /* External */,
OBJ_11 /* Graphics */,
Expand Down Expand Up @@ -2651,6 +2665,7 @@
OBJ_659 /* CrossPlattformGraphics.swift in Sources */,
OBJ_660 /* PDFConstants.swift in Sources */,
OBJ_661 /* PDFCopy.swift in Sources */,
D4E1FB2D294DE37800D654C7 /* PDFGeneratorDelegate.swift in Sources */,
OBJ_662 /* PDFDocumentObject.swift in Sources */,
OBJ_663 /* PDFError.swift in Sources */,
OBJ_664 /* PDFRenderObject.swift in Sources */,
Expand Down Expand Up @@ -2686,6 +2701,7 @@
OBJ_694 /* PDFPageBreakObject.swift in Sources */,
OBJ_695 /* PDFPageLayout+Equatable.swift in Sources */,
OBJ_696 /* PDFSectionColumnContainer.swift in Sources */,
D4E1FB2C294DE37800D654C7 /* PDFGeneratorImageDelegate.swift in Sources */,
OBJ_697 /* PDFSpaceObject.swift in Sources */,
OBJ_698 /* PDFListObject.swift in Sources */,
OBJ_699 /* CGPoint+Math.swift in Sources */,
Expand Down