Skip to content

Commit

Permalink
#247, #248: Fixing empty external page
Browse files Browse the repository at this point in the history
  • Loading branch information
Philip Niedertscheider authored Jan 6, 2021
2 parents 36e346e + 05464c1 commit b405af6
Show file tree
Hide file tree
Showing 72 changed files with 3,897 additions and 2,160 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,6 @@ Example*/Pods/Swiftlint
# Xcode Schemes, so Carthage doesn't complain
!Example iOS/TPPDF.xcodeproj/xcsharedata/xcschemes/TPPDF.xcscheme
!Example iOS/TPPDF.xcodeproj/xcsharedata/xcschemes/TPPDF-Example.xcscheme

# Ruby Gems
vendor
2 changes: 1 addition & 1 deletion .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ identifier_name:
error: 2
warning: 2
included:
- ../Source
- Source
line_length: 150
reporter: xcode
type_body_length:
Expand Down
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
os: osx
osx_image: xcode11.6
osx_image: xcode12.2
language: objective-c
cache:
- bundler

env:
global:
- DESTINATION="OS=13.4,name=iPhone 11 Pro"
- DESTINATION="OS=14.2,name=iPhone 11 Pro"
- WORKSPACE="Example.xcworkspace"
- PROJECT="Example.xcodeproj"
- EXAMPLE_SCHEME="Example"
Expand Down Expand Up @@ -97,7 +97,7 @@ jobs:
before_script:
- cd "${ROOT_FOLDER}"
- echo 'github "techprimate/TPPDF" "'$(git rev-parse HEAD)'"' > Cartfile
- carthage update --platform ios --cache-builds
- ../scripts/carthage.sh update --platform ios --cache-builds
script:
- set -o pipefail
- xcodebuild -project "$PROJECT"
Expand Down Expand Up @@ -151,7 +151,7 @@ jobs:
-scheme ${EXAMPLE_SCHEME}
-clonedSourcePackagesDirPath .
-derivedDataPath ${TRAVIS_BUILD_DIR}/derived_data
-sdk macosx10.15
-sdk macosx
-configuration Debug
ONLY_ACTIVE_ARCH=YES
build | xcpretty
Expand Down
6 changes: 5 additions & 1 deletion Example iOS-SwiftPM/Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
D49855532461FB0B00D54270 /* Image-4.jpg in Resources */ = {isa = PBXBuildFile; fileRef = D49855372461FB0B00D54270 /* Image-4.jpg */; };
D49855542461FB0B00D54270 /* Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = D49855382461FB0B00D54270 /* Icon.png */; };
D49855562461FB9A00D54270 /* Examples.swift in Sources */ = {isa = PBXBuildFile; fileRef = D49855552461FB9A00D54270 /* Examples.swift */; };
D4B7EB0725A1D345007D09C7 /* sample-large.pdf in Resources */ = {isa = PBXBuildFile; fileRef = D4B7EB0525A1D32F007D09C7 /* sample-large.pdf */; };
D4D28D2323AA1A6D00028D5A /* ExamplesListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4D28D2223AA1A6D00028D5A /* ExamplesListViewController.swift */; };
/* End PBXBuildFile section */

Expand Down Expand Up @@ -81,6 +82,7 @@
D49855372461FB0B00D54270 /* Image-4.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = "Image-4.jpg"; sourceTree = "<group>"; };
D49855382461FB0B00D54270 /* Icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Icon.png; sourceTree = "<group>"; };
D49855552461FB9A00D54270 /* Examples.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Examples.swift; sourceTree = "<group>"; };
D4B7EB0525A1D32F007D09C7 /* sample-large.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = "sample-large.pdf"; sourceTree = "<group>"; };
D4D28D2223AA1A6D00028D5A /* ExamplesListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExamplesListViewController.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -197,6 +199,7 @@
D498552F2461FB0B00D54270 /* Documents */ = {
isa = PBXGroup;
children = (
D4B7EB0525A1D32F007D09C7 /* sample-large.pdf */,
D49855302461FB0B00D54270 /* sample.pdf */,
);
path = Documents;
Expand Down Expand Up @@ -310,6 +313,7 @@
607FACDB1AFB9204008FA782 /* Main.storyboard in Resources */,
607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */,
607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */,
D4B7EB0725A1D345007D09C7 /* sample-large.pdf in Resources */,
D49855512461FB0B00D54270 /* Image-3.jpg in Resources */,
D498554F2461FB0B00D54270 /* PortraitImage.jpg in Resources */,
D49855542461FB0B00D54270 /* Icon.png in Resources */,
Expand All @@ -333,7 +337,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if which swiftlint >/dev/null; then\n \"swiftlint\" --config ../.swiftlint.yml\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n";
shellScript = "if which swiftlint >/dev/null; then\n if [-z \"$CI\"]; then\n echo \"Skipping SwiftLint as running on CI...\"\n else\n cd ../\n \"swiftlint\" --config .swiftlint.yml\n fi\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n";
};
/* End PBXShellScriptBuildPhase section */

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,40 @@
{
"object": {
"pins": [
{
"package": "CwlCatchException",
"repositoryURL": "https://github.com/mattgallagher/CwlCatchException.git",
"state": {
"branch": null,
"revision": "f809deb30dc5c9d9b78c872e553261a61177721a",
"version": "2.0.0"
}
},
{
"package": "CwlPreconditionTesting",
"repositoryURL": "https://github.com/mattgallagher/CwlPreconditionTesting.git",
"state": {
"branch": null,
"revision": "02b7a39a99c4da27abe03cab2053a9034379639f",
"version": "2.0.0"
}
},
{
"package": "Nimble",
"repositoryURL": "https://github.com/Quick/Nimble",
"state": {
"branch": null,
"revision": "2b1809051b4a65c1d7f5233331daa24572cd7fca",
"version": "8.1.1"
"revision": "e491a6731307bb23783bf664d003be9b2fa59ab5",
"version": "9.0.0"
}
},
{
"package": "Quick",
"repositoryURL": "https://github.com/Quick/Quick",
"state": {
"branch": null,
"revision": "09b3becb37cb2163919a3842a4c5fa6ec7130792",
"version": "2.2.1"
"revision": "0038bcbab4292f3b028632556507c124e5ba69f3",
"version": "3.0.0"
}
}
]
Expand Down
8 changes: 7 additions & 1 deletion Example macOS/Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
D48C53D924A26C0000D7A3DD /* Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = D48C53BD24A26C0000D7A3DD /* Icon.png */; };
D48C53DC24A26E5400D7A3DD /* TPPDF in Frameworks */ = {isa = PBXBuildFile; productRef = D48C53DB24A26E5400D7A3DD /* TPPDF */; };
D48C53DE24A27A0100D7A3DD /* PDFView+SwiftUI.swift in Sources */ = {isa = PBXBuildFile; fileRef = D48C53DD24A27A0100D7A3DD /* PDFView+SwiftUI.swift */; };
D4B7EB0B25A1DAD2007D09C7 /* sample-large.pdf in Resources */ = {isa = PBXBuildFile; fileRef = D4B7EB0A25A1DACE007D09C7 /* sample-large.pdf */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand Down Expand Up @@ -87,6 +88,7 @@
D48C53BC24A26C0000D7A3DD /* Image-4.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = "Image-4.jpg"; sourceTree = "<group>"; };
D48C53BD24A26C0000D7A3DD /* Icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Icon.png; sourceTree = "<group>"; };
D48C53DD24A27A0100D7A3DD /* PDFView+SwiftUI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PDFView+SwiftUI.swift"; sourceTree = "<group>"; };
D4B7EB0A25A1DACE007D09C7 /* sample-large.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = "sample-large.pdf"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -210,6 +212,7 @@
D48C53B424A26C0000D7A3DD /* Documents */ = {
isa = PBXGroup;
children = (
D4B7EB0A25A1DACE007D09C7 /* sample-large.pdf */,
D48C53B524A26C0000D7A3DD /* sample.pdf */,
);
path = Documents;
Expand Down Expand Up @@ -266,7 +269,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 1150;
LastUpgradeCheck = 1160;
LastUpgradeCheck = 1230;
ORGANIZATIONNAME = "techprimate GmbH & Co. KG";
TargetAttributes = {
D48C538424A269F400D7A3DD = {
Expand Down Expand Up @@ -303,6 +306,7 @@
D48C539324A269F500D7A3DD /* Main.storyboard in Resources */,
D48C539024A269F500D7A3DD /* Preview Assets.xcassets in Resources */,
D48C538D24A269F500D7A3DD /* Assets.xcassets in Resources */,
D4B7EB0B25A1DAD2007D09C7 /* sample-large.pdf in Resources */,
D48C53D624A26C0000D7A3DD /* Image-3.jpg in Resources */,
D48C53D424A26C0000D7A3DD /* PortraitImage.jpg in Resources */,
D48C53D924A26C0000D7A3DD /* Icon.png in Resources */,
Expand Down Expand Up @@ -386,6 +390,7 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
Expand Down Expand Up @@ -446,6 +451,7 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,40 @@
{
"object": {
"pins": [
{
"package": "CwlCatchException",
"repositoryURL": "https://github.com/mattgallagher/CwlCatchException.git",
"state": {
"branch": null,
"revision": "f809deb30dc5c9d9b78c872e553261a61177721a",
"version": "2.0.0"
}
},
{
"package": "CwlPreconditionTesting",
"repositoryURL": "https://github.com/mattgallagher/CwlPreconditionTesting.git",
"state": {
"branch": null,
"revision": "02b7a39a99c4da27abe03cab2053a9034379639f",
"version": "2.0.0"
}
},
{
"package": "Nimble",
"repositoryURL": "https://github.com/Quick/Nimble",
"state": {
"branch": null,
"revision": "72f5a90d573f7f7d70aa6b8ad84b3e1e02eabb4d",
"version": "8.0.9"
"revision": "e491a6731307bb23783bf664d003be9b2fa59ab5",
"version": "9.0.0"
}
},
{
"package": "Quick",
"repositoryURL": "https://github.com/Quick/Quick",
"state": {
"branch": null,
"revision": "33682c2f6230c60614861dfc61df267e11a1602f",
"version": "2.2.0"
"revision": "0038bcbab4292f3b028632556507c124e5ba69f3",
"version": "3.0.0"
}
}
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1160"
LastUpgradeVersion = "1230"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -28,6 +28,26 @@
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "TPPDFIntegrationTests"
BuildableName = "TPPDFIntegrationTests"
BlueprintName = "TPPDFIntegrationTests"
ReferencedContainer = "container:..">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "TPPDFTests"
BuildableName = "TPPDFTests"
BlueprintName = "TPPDFTests"
ReferencedContainer = "container:..">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
Expand Down
11 changes: 10 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.2
// swift-tools-version:5.3

import PackageDescription

Expand All @@ -21,6 +21,15 @@ let package = Package(
"TPPDF",
"Quick",
"Nimble"
], resources: [
.copy("resources/sample.pdf"),
]),
.testTarget(name: "TPPDFIntegrationTests", dependencies: [
"TPPDF",
"Quick",
"Nimble"
], resources: [
.copy("resources/50-pages.pdf"),
]),
]
)
2 changes: 1 addition & 1 deletion Shared iOS/UI/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class ViewController: UIViewController {
do {
let url = try generator.generateURL(filename: "Example.pdf")
print("Output URL:", url)

/* ---- Execution Metrics ---- */
print("Generation took: " + TimeUtils.stringFromTimeInterval(interval: CFAbsoluteTimeGetCurrent() - startTime))
/* ---- Execution Metrics ---- */
Expand Down
Binary file added Shared/Data/Documents/sample-large.pdf
Binary file not shown.
15 changes: 7 additions & 8 deletions Shared/Examples/ExperimentFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,19 @@
//

import TPPDF
import Foundation

class ExperimentFactory: ExampleFactory {

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

let table = PDFTable(rows: 3, columns: 4)
table.content = [
["0,0", "0,1", "0,2", "0,3"],
["1,0", "1,1", "1,2", "1,3"],
["2,0", "2,1", "2,2", "2,3"],
]
table.rows.allRowsAlignment = [.left, .left, .right, .right]
document.add(table: table)
document.pagination = .init(container: .footerRight)

let externalDocument = PDFExternalDocument(url: Bundle.main.url(forResource: "sample-large", withExtension: "pdf")!)
document.add(externalDocument: externalDocument)

document.add(text: "END")

return [document]
}
Expand Down
2 changes: 1 addition & 1 deletion Shared/Examples/ExternalDocumentExampleFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ExternalDocumentExampleFactory: ExampleFactory {
document.add(text: "This is more text after the external pdf file")

// Add same sample again
externalDocument = PDFExternalDocument(url: Bundle.main.url(forResource: "sample", withExtension: "pdf")!, pages: 1, 3)
externalDocument = PDFExternalDocument(url: Bundle.main.url(forResource: "sample", withExtension: "pdf")!, pages: 2, 4)
document.add(externalDocument: externalDocument)

// Add more text after externalDocument
Expand Down
4 changes: 2 additions & 2 deletions Source/API/Image/PDFImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public class PDFImage: PDFDocumentObject {

// MARK: - Equatable

public override func isEqual(to other: PDFDocumentObject) -> Bool {
override public func isEqual(to other: PDFDocumentObject) -> Bool {
guard super.isEqual(to: other) else {
return false
}
Expand Down Expand Up @@ -129,7 +129,7 @@ public class PDFImage: PDFDocumentObject {

// MARK: - Hashable

public override func hash(into hasher: inout Hasher) {
override public func hash(into hasher: inout Hasher) {
hasher.combine(image)
hasher.combine(caption)
hasher.combine(size.width)
Expand Down
4 changes: 2 additions & 2 deletions Source/API/List/PDFList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public class PDFList: PDFDocumentObject {
/// - lhs: One instance of `PDFList`
/// - rhs: Another instance of `PDFList`
/// - Returns: `true`, if `levelIndentations` and `items` equal; otherwise `false`
public override func isEqual(to other: PDFDocumentObject) -> Bool {
override public func isEqual(to other: PDFDocumentObject) -> Bool {
guard super.isEqual(to: other) else {
return false
}
Expand All @@ -142,7 +142,7 @@ public class PDFList: PDFDocumentObject {

// MARK: - Hashable

public override func hash(into hasher: inout Hasher) {
override public func hash(into hasher: inout Hasher) {
super.hash(into: &hasher)
for (pre, post) in levelIndentations {
hasher.combine(pre)
Expand Down
4 changes: 2 additions & 2 deletions Source/API/List/PDFListItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public class PDFListItem: PDFDocumentObject {
/// - lhs: One instance of `PDFListItem`
/// - rhs: Another instance of `PDFListItem`
/// - Returns: `true`, if `attributes`, `tag`, `content`, `children` and `symbol` equal; otherwise `false`
public override func isEqual(to other: PDFDocumentObject) -> Bool {
override public func isEqual(to other: PDFDocumentObject) -> Bool {
guard super.isEqual(to: other) else {
return false
}
Expand All @@ -108,7 +108,7 @@ public class PDFListItem: PDFDocumentObject {

// MARK: - Equatable

public override func hash(into hasher: inout Hasher) {
override public func hash(into hasher: inout Hasher) {
super.hash(into: &hasher)
hasher.combine(content)
hasher.combine(children)
Expand Down
Loading

0 comments on commit b405af6

Please sign in to comment.