Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
philprime authored Nov 10, 2024
2 parents 109551a + 838ff8b commit 6d1f779
Show file tree
Hide file tree
Showing 19 changed files with 43 additions and 42 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ jobs:
[
{
sdk: "iphonesimulator",
destination: "platform=iOS Simulator,OS=18.0,name=iPhone 16 Pro",
destination: "platform=iOS Simulator,OS=18.1,name=iPhone 16 Pro",
action: "test",
runs-on: "macos-14",
runs-on: "macos-15",
},
{
sdk: "xros",
Expand Down
1 change: 1 addition & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ disabled_rules:
- large_tuple
- todo
- inclusive_language
- trailing_comma
excluded:
- Carthage
- Pods
Expand Down
8 changes: 0 additions & 8 deletions Dangerfile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,7 @@ let danger = Danger()

// Changelog entries are required for changes to library files.
let allSourceFiles = danger.git.modifiedFiles + danger.git.createdFiles
let noChangelogEntry = !allSourceFiles.contains("CHANGELOG.md")
let sourceChanges = allSourceFiles.contains { $0.hasPrefix("Source") }
let isNotTrivial = !danger.github.pullRequest.title.contains("#trivial")
if isNotTrivial && noChangelogEntry && sourceChanges {
danger.warn("""
Any changes to library code should be reflected in the Changelog.
Please consider adding a note there.
""")
}

// Make it more obvious that a PR is a work in progress and shouldn't be merged yet
if danger.github.pullRequest.title.contains("WIP") || danger.github.pullRequest.title.contains("Draft") {
Expand Down
18 changes: 13 additions & 5 deletions Example macOS/Example/UI/DetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,22 @@ struct DetailView: View {
@State var observer: NSObjectProtocol! = nil
@State var progressValue: Double = 0.5

@State var debug = false

var body: some View {
VStack(alignment: .leading, spacing: 0) {
HStack {
Text("\(example.name)")
.font(.headline)
Toggle(isOn: $debug) {
Text("Debug Mode")
}
.onChange(of: debug) { debug in
self.generatePDF(force: true, debug: debug)
}
Spacer()
Button(action: {
self.generatePDF(force: true)
self.generatePDF(force: true, debug: debug)
}, label: {
Text("Refresh")
})
Expand All @@ -36,12 +44,12 @@ struct DetailView: View {

PDFKitRepresentedView(url: url)
.onAppear {
self.generatePDF(force: false)
self.generatePDF(force: false, debug: debug)
}
}
}

func generatePDF(force: Bool) {
func generatePDF(force: Bool, debug: Bool) {
if url != nil && !force {
return
}
Expand All @@ -51,15 +59,15 @@ struct DetailView: View {
} else {
generator = PDFMultiDocumentGenerator(documents: docs)
}
generator.debug = true
generator.debug = debug

observer = generator.progress.observe(\.completedUnitCount) { progress, _ in
self.progressValue = progress.fractionCompleted
}

DispatchQueue.global(qos: .background).async {
do {
let url = try self.generator.generateURL(filename: "output.pdf")
let url = try self.generator.generateURL(filename: "output-\(UUID().uuidString).pdf")
DispatchQueue.main.async {
self.url = url
}
Expand Down
4 changes: 2 additions & 2 deletions Example macOS/Example_macOS-SPM.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.15;
MACOSX_DEPLOYMENT_TARGET = 11;
PRODUCT_BUNDLE_IDENTIFIER = com.techprimate.TPPDF.Example;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -554,7 +554,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.15;
MACOSX_DEPLOYMENT_TARGET = 11;
PRODUCT_BUNDLE_IDENTIFIER = com.techprimate.TPPDF.Example;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@ GEM
sassc (2.4.0)
ffi (~> 1.9)
securerandom (0.3.1)
slather (2.8.4)
slather (2.8.5)
CFPropertyList (>= 2.2, < 4)
activesupport
clamp (~> 1.3)
nokogiri (>= 1.14.3)
xcodeproj (~> 1.25)
xcodeproj (~> 1.27)
sqlite3 (1.7.3)
mini_portile2 (~> 2.8.0)
typhoeus (1.4.1)
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let package = Package(
platforms: [
.iOS(.v9),
.macOS(.v10_14),
.visionOS(.v1)
.visionOS(.v1),
],
products: [
.library(name: "TPPDF", targets: ["TPPDF"]),
Expand Down
2 changes: 1 addition & 1 deletion Source/API/Layout/PDFContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public enum PDFContainer: CaseIterable {
[
.headerLeft, .headerCenter, .headerRight,
.contentLeft, .contentCenter, .contentRight,
.footerLeft, .footerCenter, .footerRight
.footerLeft, .footerCenter, .footerRight,
]
}
}
2 changes: 1 addition & 1 deletion Source/API/Metadata/PDFInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public class PDFInfo {
kCGPDFContextSubject as String: subject,
kCGPDFContextKeywords as String: keywords,
kCGPDFContextAllowsPrinting as String: allowsPrinting,
kCGPDFContextAllowsCopying as String: allowsCopying
kCGPDFContextAllowsCopying as String: allowsCopying,
]

var creator = Bundle.main.infoDictionary?["CFBundleName"] as? String ?? "TPPDF"
Expand Down
2 changes: 1 addition & 1 deletion Source/API/PDFGenerator+Generation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ public extension PDFGenerator {
layout.margin.top + layout.heights.maxHeaderHeight(),
layout.margin.top + layout.heights.maxHeaderHeight() + document.layout.space.header,
document.layout.height - layout.margin.bottom - layout.heights.maxFooterHeight(),
document.layout.height - layout.margin.bottom - layout.heights.maxFooterHeight() - document.layout.space.footer
document.layout.height - layout.margin.bottom - layout.heights.maxFooterHeight() - document.layout.space.footer,
]

var lines: [PDFLineObject] = []
Expand Down
2 changes: 1 addition & 1 deletion Source/API/Utils/CrossPlattformGraphics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
}
}

extension NSEdgeInsets: Equatable {
extension NSEdgeInsets: @retroactive Equatable {
public static func == (lhs: NSEdgeInsets, rhs: NSEdgeInsets) -> Bool {
lhs.top == rhs.top && lhs.left == rhs.left && lhs.bottom == rhs.bottom && lhs.right == rhs.right
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Internal/External/PDFExternalPageObject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class PDFExternalPageObject: PDFRenderObject {
override func calculate(generator _: PDFGenerator, container: PDFContainer) throws -> [PDFLocatedRenderObject] {
frame = page.getBoxRect(.mediaBox)
return [
(container, self)
(container, self),
]
}

Expand Down
2 changes: 1 addition & 1 deletion Source/Internal/Graphics/PDFContextGraphics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ enum PDFContextGraphics {
var mediaBox = bounds
let boxData = NSData(bytes: &mediaBox, length: MemoryLayout.size(ofValue: mediaBox))
let pageInfo = [
kCGPDFContextMediaBox as String: boxData
kCGPDFContextMediaBox as String: boxData,
]
context.beginPDFPage(pageInfo as CFDictionary)

Expand Down
2 changes: 1 addition & 1 deletion Source/Internal/Group/PDFGroupObject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class PDFGroupObject: PDFRenderObject {
}

var groupedResult = [
[PDFLocatedRenderObject]()
[PDFLocatedRenderObject](),
]

// Set padding
Expand Down
20 changes: 10 additions & 10 deletions Source/Internal/Layout/PDFColumnLayoutState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,27 @@ class PDFColumnLayoutState: CustomStringConvertible {
self.currentColumn = [
.headerLeft: 0,
.contentLeft: 0,
.footerLeft: 0
.footerLeft: 0,
]
self.columnWidths = [
.headerLeft: [],
.contentLeft: [],
.footerLeft: []
.footerLeft: [],
]
self.columnSpacings = [
.headerLeft: [],
.contentLeft: [],
.footerLeft: []
.footerLeft: [],
]
self.wrapColumnsHeight = [
.headerLeft: 0,
.contentLeft: 0,
.footerLeft: 0
.footerLeft: 0,
]
self.inset = [
.headerLeft: (0, 0),
.contentLeft: (0, 0),
.footerLeft: (0, 0)
.footerLeft: (0, 0),
]
}

Expand All @@ -53,27 +53,27 @@ class PDFColumnLayoutState: CustomStringConvertible {
currentColumn = [
.headerLeft: 0,
.contentLeft: 0,
.footerLeft: 0
.footerLeft: 0,
]
columnWidths = [
.headerLeft: [],
.contentLeft: [],
.footerLeft: []
.footerLeft: [],
]
columnSpacings = [
.headerLeft: [],
.contentLeft: [],
.footerLeft: []
.footerLeft: [],
]
wrapColumnsHeight = [
.headerLeft: 0,
.contentLeft: 0,
.footerLeft: 0
.footerLeft: 0,
]
inset = [
.headerLeft: (0, 0),
.contentLeft: (0, 0),
.footerLeft: (0, 0)
.footerLeft: (0, 0),
]
}

Expand Down
2 changes: 1 addition & 1 deletion Source/Internal/Section/PDFSectionObject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class PDFSectionObject: PDFRenderObject {
// stores how many objects are in one column at max
let maxObjectsPerColumn = objectsPerColumn.reduce(0) { max($0, $1.value.count) }

/*
/*
* as soon as a column requests a page break, we need to stack subsequent objects of the very same column until the following is `true`:
* one or more columns do not have more objects and all other columns, which have more objects left, are requesting a page break
*/
Expand Down
4 changes: 2 additions & 2 deletions Source/Internal/Table/PDFTableObject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ class PDFTableObject: PDFRenderObject {
let attributes: [NSAttributedString.Key: AnyObject] = [
.foregroundColor: cellStyle.colors.text,
.font: cellStyle.font,
.paragraphStyle: paragraph
.paragraphStyle: paragraph,
]
return NSAttributedString(string: text, attributes: attributes)
}
Expand Down Expand Up @@ -617,7 +617,7 @@ class PDFTableObject: PDFRenderObject {
endPoint: CGPoint(x: frame.maxX, y: frame.maxY)),
PDFLineObject(style: borders.left,
startPoint: CGPoint(x: frame.minX, y: frame.minY),
endPoint: CGPoint(x: frame.minX, y: frame.maxY))
endPoint: CGPoint(x: frame.minX, y: frame.maxY)),
]
}

Expand Down
2 changes: 1 addition & 1 deletion Source/Internal/Text/PDFAttributedTextObject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ class PDFAttributedTextObject: PDFRenderObject {
return [
NSAttributedString.Key.font: style?.font ?? fonts[container]!,
NSAttributedString.Key.foregroundColor: style?.color ?? textColor[container]!,
NSAttributedString.Key.paragraphStyle: paragraphStyle
NSAttributedString.Key.paragraphStyle: paragraphStyle,
]
}

Expand Down
2 changes: 1 addition & 1 deletion Source/Internal/Utils/PDFSlicedObject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class PDFSlicedObject: PDFRenderObject {

override func calculate(generator _: PDFGenerator, container: PDFContainer) throws -> [PDFLocatedRenderObject] {
[
(container, self)
(container, self),
]
}

Expand Down

0 comments on commit 6d1f779

Please sign in to comment.