From 526e4f43dca6e226f859fa20c46f7ecf6eff74a1 Mon Sep 17 00:00:00 2001 From: Philip Niedertscheider Date: Tue, 7 Dec 2021 09:52:44 +0100 Subject: [PATCH 1/4] Updated gems --- Gemfile.lock | 66 +++++++++++++++++++++++++++------------------------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 90ae0c7c..671db149 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,12 +1,14 @@ GEM remote: https://rubygems.org/ specs: - CFPropertyList (3.0.3) - activesupport (5.2.6) + CFPropertyList (3.0.5) + rexml + activesupport (6.1.4.1) concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) addressable (2.8.0) public_suffix (>= 2.0.2, < 5.0) algoliasearch (1.27.5) @@ -15,10 +17,10 @@ GEM atomos (0.1.3) claide (1.0.3) clamp (1.3.2) - cocoapods (1.10.2) - addressable (~> 2.6) + cocoapods (1.11.2) + addressable (~> 2.8) claide (>= 1.0.2, < 2.0) - cocoapods-core (= 1.10.2) + cocoapods-core (= 1.11.2) cocoapods-deintegrate (>= 1.0.3, < 2.0) cocoapods-downloader (>= 1.4.0, < 2.0) cocoapods-plugins (>= 1.0.0, < 2.0) @@ -29,42 +31,42 @@ GEM escape (~> 0.0.4) fourflusher (>= 2.3.0, < 3.0) gh_inspector (~> 1.0) - molinillo (~> 0.6.6) + molinillo (~> 0.8.0) nap (~> 1.0) - ruby-macho (~> 1.4) - xcodeproj (>= 1.19.0, < 2.0) - cocoapods-core (1.10.2) - activesupport (> 5.0, < 6) - addressable (~> 2.6) + ruby-macho (>= 1.0, < 3.0) + xcodeproj (>= 1.21.0, < 2.0) + cocoapods-core (1.11.2) + activesupport (>= 5.0, < 7) + addressable (~> 2.8) algoliasearch (~> 1.0) concurrent-ruby (~> 1.1) fuzzy_match (~> 2.0.4) nap (~> 1.0) netrc (~> 0.11) - public_suffix + public_suffix (~> 4.0) typhoeus (~> 1.0) cocoapods-deintegrate (1.0.5) - cocoapods-downloader (1.4.0) + cocoapods-downloader (1.5.1) cocoapods-plugins (1.0.0) nap cocoapods-search (1.0.1) - cocoapods-trunk (1.5.0) + cocoapods-trunk (1.6.0) nap (>= 0.8, < 2.0) netrc (~> 0.11) cocoapods-try (1.2.0) colored2 (3.1.2) concurrent-ruby (1.1.9) escape (0.0.4) - ethon (0.14.0) + ethon (0.15.0) ffi (>= 1.15.0) - ffi (1.15.3) + ffi (1.15.4) fourflusher (2.3.1) fuzzy_match (2.0.4) gh_inspector (1.1.3) httpclient (2.8.3) - i18n (1.8.10) + i18n (1.8.11) concurrent-ruby (~> 1.0) - jazzy (0.14.0) + jazzy (0.14.1) cocoapods (~> 1.5) mustache (~> 1.1) open4 (~> 1.3) @@ -74,39 +76,38 @@ GEM sassc (~> 2.1) sqlite3 (~> 1.3) xcinvoke (~> 0.3.0) - json (2.5.1) + json (2.6.1) liferaft (0.0.6) mini_portile2 (2.6.1) minitest (5.14.4) - molinillo (0.6.6) + molinillo (0.8.0) mustache (1.1.1) nanaimo (0.3.0) nap (1.1.0) netrc (0.11.0) - nokogiri (1.12.3) + nokogiri (1.12.5) mini_portile2 (~> 2.6.1) racc (~> 1.4) open4 (1.3.4) public_suffix (4.0.6) - racc (1.5.2) + racc (1.6.0) redcarpet (3.5.1) rexml (3.2.5) rouge (2.0.7) - ruby-macho (1.4.0) + ruby-macho (2.5.1) sassc (2.4.0) ffi (~> 1.9) - slather (2.7.1) + slather (2.7.2) CFPropertyList (>= 2.2, < 4) activesupport clamp (~> 1.3) - nokogiri (~> 1.11) - xcodeproj (~> 1.7) + nokogiri (~> 1.12) + xcodeproj (~> 1.21) sqlite3 (1.4.2) - thread_safe (0.3.6) typhoeus (1.4.0) ethon (>= 0.9.0) - tzinfo (1.2.9) - thread_safe (~> 0.1) + tzinfo (2.0.4) + concurrent-ruby (~> 1.0) xcinvoke (0.3.0) liferaft (~> 0.0.6) xcodeproj (1.21.0) @@ -118,6 +119,7 @@ GEM rexml (~> 3.2.4) xcpretty (0.3.0) rouge (~> 2.0.7) + zeitwerk (2.5.1) PLATFORMS ruby From 8d5e6273d4c2a6763fbcc4a9e6ce10f6088d29d2 Mon Sep 17 00:00:00 2001 From: Philip Niedertscheider Date: Sun, 27 Feb 2022 17:02:08 +0100 Subject: [PATCH 2/4] Updated Ruby dependencies --- Gemfile.lock | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 671db149..f7dbf655 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -3,7 +3,7 @@ GEM specs: CFPropertyList (3.0.5) rexml - activesupport (6.1.4.1) + activesupport (6.1.4.6) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -15,7 +15,7 @@ GEM httpclient (~> 2.8, >= 2.8.3) json (>= 1.5.1) atomos (0.1.3) - claide (1.0.3) + claide (1.1.0) clamp (1.3.2) cocoapods (1.11.2) addressable (~> 2.8) @@ -59,12 +59,12 @@ GEM escape (0.0.4) ethon (0.15.0) ffi (>= 1.15.0) - ffi (1.15.4) + ffi (1.15.5) fourflusher (2.3.1) fuzzy_match (2.0.4) gh_inspector (1.1.3) httpclient (2.8.3) - i18n (1.8.11) + i18n (1.10.0) concurrent-ruby (~> 1.0) jazzy (0.14.1) cocoapods (~> 1.5) @@ -78,15 +78,15 @@ GEM xcinvoke (~> 0.3.0) json (2.6.1) liferaft (0.0.6) - mini_portile2 (2.6.1) - minitest (5.14.4) + mini_portile2 (2.8.0) + minitest (5.15.0) molinillo (0.8.0) mustache (1.1.1) nanaimo (0.3.0) nap (1.1.0) netrc (0.11.0) - nokogiri (1.12.5) - mini_portile2 (~> 2.6.1) + nokogiri (1.13.3) + mini_portile2 (~> 2.8.0) racc (~> 1.4) open4 (1.3.4) public_suffix (4.0.6) @@ -119,7 +119,7 @@ GEM rexml (~> 3.2.4) xcpretty (0.3.0) rouge (~> 2.0.7) - zeitwerk (2.5.1) + zeitwerk (2.5.4) PLATFORMS ruby From a013b4513e60a839961863a0dc5b6aca7a9cf99c Mon Sep 17 00:00:00 2001 From: Philip Niedertscheider Date: Tue, 19 Apr 2022 08:13:13 +0200 Subject: [PATCH 3/4] Updated Ruby dependencies --- Gemfile.lock | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index f7dbf655..c68dd3b6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -3,7 +3,7 @@ GEM specs: CFPropertyList (3.0.5) rexml - activesupport (6.1.4.6) + activesupport (6.1.5) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -17,10 +17,10 @@ GEM atomos (0.1.3) claide (1.1.0) clamp (1.3.2) - cocoapods (1.11.2) + cocoapods (1.11.3) addressable (~> 2.8) claide (>= 1.0.2, < 2.0) - cocoapods-core (= 1.11.2) + cocoapods-core (= 1.11.3) cocoapods-deintegrate (>= 1.0.3, < 2.0) cocoapods-downloader (>= 1.4.0, < 2.0) cocoapods-plugins (>= 1.0.0, < 2.0) @@ -35,7 +35,7 @@ GEM nap (~> 1.0) ruby-macho (>= 1.0, < 3.0) xcodeproj (>= 1.21.0, < 2.0) - cocoapods-core (1.11.2) + cocoapods-core (1.11.3) activesupport (>= 5.0, < 7) addressable (~> 2.8) algoliasearch (~> 1.0) @@ -46,7 +46,7 @@ GEM public_suffix (~> 4.0) typhoeus (~> 1.0) cocoapods-deintegrate (1.0.5) - cocoapods-downloader (1.5.1) + cocoapods-downloader (1.6.3) cocoapods-plugins (1.0.0) nap cocoapods-search (1.0.1) @@ -55,7 +55,7 @@ GEM netrc (~> 0.11) cocoapods-try (1.2.0) colored2 (3.1.2) - concurrent-ruby (1.1.9) + concurrent-ruby (1.1.10) escape (0.0.4) ethon (0.15.0) ffi (>= 1.15.0) @@ -66,7 +66,7 @@ GEM httpclient (2.8.3) i18n (1.10.0) concurrent-ruby (~> 1.0) - jazzy (0.14.1) + jazzy (0.14.2) cocoapods (~> 1.5) mustache (~> 1.1) open4 (~> 1.3) @@ -85,11 +85,11 @@ GEM nanaimo (0.3.0) nap (1.1.0) netrc (0.11.0) - nokogiri (1.13.3) + nokogiri (1.13.4) mini_portile2 (~> 2.8.0) racc (~> 1.4) open4 (1.3.4) - public_suffix (4.0.6) + public_suffix (4.0.7) racc (1.6.0) redcarpet (3.5.1) rexml (3.2.5) From d44ef294fb93779400c232d3d339830581d7fb2a Mon Sep 17 00:00:00 2001 From: Patrick Date: Fri, 22 Apr 2022 17:28:25 +0400 Subject: [PATCH 4/4] Add name property on PDFPageFormat --- .../PDFPageFormat+NameConstants.swift | 153 +++++++++++++ Source/API/Page Format/PDFPageFormat.swift | 18 ++ .../PDFPageFormat+NameConstants_Spec.swift | 203 ++++++++++++++++++ 3 files changed, 374 insertions(+) create mode 100644 Source/API/Page Format/PDFPageFormat+NameConstants.swift create mode 100644 Tests/TPPDFTests/Page Format/PDFPageFormat+NameConstants_Spec.swift diff --git a/Source/API/Page Format/PDFPageFormat+NameConstants.swift b/Source/API/Page Format/PDFPageFormat+NameConstants.swift new file mode 100644 index 00000000..0cc2e24b --- /dev/null +++ b/Source/API/Page Format/PDFPageFormat+NameConstants.swift @@ -0,0 +1,153 @@ +#if os(iOS) +import UIKit +#elseif os(macOS) +import AppKit +#endif + +/** + This extension includes all name constants defined by their corresponding standard. + Source for names: https://www.papersizes.org + */ +public extension PDFPageFormat { + + /** + Returns the defined US names if this format is a US format. + If it is not a US format, it will check other constants for correct name + */ + var usName: String { + switch self { + case .usHalfLetter: + return "US Half Letter" + case .usLetter: + return "US Letter" + case .usLegal: + return "US Legal" + case .usJuniorLegal: + return "US Junior Legal" + case .usLedger: + return "US Ledger" + default: + return name + } + } + + /** + Returns the defined ANSI name if this format is a ANSI format. + If it is not a ANSI format, it will check other constants for correct name + */ + var ansiName: String { + switch self { + case .ansiA: + return "ANSI A" + case .ansiB: + return "ANSI B" + case .ansiC: + return "ANSI C" + case .ansiD: + return "ANSI D" + case .ansiE: + return "ANSI E" + default: + return name + } + } + + /** + Returns the defined A-Series name if this format is a A-Series format. + If it is not a A-Series format, it will check other constants for correct name + */ + var aName: String { + switch self { + case .a0: + return "A0" + case .a1: + return "A1" + case .a2: + return "A2" + case .a3: + return "A3" + case .a4: + return "A4" + case .a5: + return "A5" + case .a6: + return "A6" + case .a7: + return "A7" + case .a8: + return "A8" + case .a9: + return "A9" + case .a10: + return "A10" + default: + return name + } + } + + /** + Returns the defined B-Series name if this format is a B-Series format. + If it is not a B-Series format, it will check other constants for correct name + */ + var bName: String { + switch self { + case .b0: + return "B0" + case .b1: + return "B1" + case .b2: + return "B2" + case .b3: + return "B3" + case .b4: + return "B4" + case .b5: + return "B5" + case .b6: + return "B6" + case .b7: + return "B7" + case .b8: + return "B8" + case .b9: + return "B9" + case .b10: + return "B10" + default: + return name + } + } + + /** + Returns the defined C-Series name if this format is a C-Series format. + If it is not a C-Series format, it will check other constants for correct name + */ + var cName: String { + switch self { + case .c0: + return "C0" + case .c1: + return "C1" + case .c2: + return "C2" + case .c3: + return "C3" + case .c4: + return "C4" + case .c5: + return "C5" + case .c6: + return "C6" + case .c7: + return "C7" + case .c8: + return "C8" + case .c9: + return "C9" + case .c10: + return "C10" + default: + return name + } + } +} diff --git a/Source/API/Page Format/PDFPageFormat.swift b/Source/API/Page Format/PDFPageFormat.swift index 5d12f576..7907ca11 100644 --- a/Source/API/Page Format/PDFPageFormat.swift +++ b/Source/API/Page Format/PDFPageFormat.swift @@ -107,4 +107,22 @@ public enum PDFPageFormat: String, CaseIterable { public var landscapeSize: CGSize { CGSize(width: size.height, height: size.width) } + + /** + Name defined in constants + */ + public var name: String { + switch self { + case .usHalfLetter, .usLetter, .usLegal, .usJuniorLegal, .usLedger: + return usName + case .ansiA, .ansiB, .ansiC, .ansiD, .ansiE: + return ansiName + case .a0, .a1, .a2, .a3, .a4, .a5, .a6, .a7, .a8, .a9, .a10: + return aName + case .b0, .b1, .b2, .b3, .b4, .b5, .b6, .b7, .b8, .b9, .b10: + return bName + case .c0, .c1, .c2, .c3, .c4, .c5, .c6, .c7, .c8, .c9, .c10: + return cName + } + } } diff --git a/Tests/TPPDFTests/Page Format/PDFPageFormat+NameConstants_Spec.swift b/Tests/TPPDFTests/Page Format/PDFPageFormat+NameConstants_Spec.swift new file mode 100644 index 00000000..8e755a9f --- /dev/null +++ b/Tests/TPPDFTests/Page Format/PDFPageFormat+NameConstants_Spec.swift @@ -0,0 +1,203 @@ +import CoreGraphics +import Quick +import Nimble +@testable import TPPDF + +class PDFPageFormat_NameConstants_Spec: QuickSpec { + + override func spec() { + describe("PDFPagename") { + + context("NameConstants") { + + context("US Series") { + + it("has a US Half Letter name") { + expect(PDFPageFormat.usHalfLetter.name) == "US Half Letter" + } + + it("has a US Letter name") { + expect(PDFPageFormat.usLetter.name) == "US Letter" + } + + it("has a US Legal name") { + expect(PDFPageFormat.usLegal.name) == "US Legal" + } + + it("has a US Junior Legal name") { + expect(PDFPageFormat.usJuniorLegal.name) == "US Junior Legal" + } + + it("has a US Ledger name") { + expect(PDFPageFormat.usLedger.name) == "US Ledger" + } + } + + context("ANSI Series") { + + it("has a ANSI A name") { + expect(PDFPageFormat.ansiA.name) == "ANSI A" + } + + it("has a ANSI B name") { + expect(PDFPageFormat.ansiB.name) == "ANSI B" + } + + it("has a ANSI C name") { + expect(PDFPageFormat.ansiC.name) == "ANSI C" + } + + it("has a ANSI D name") { + expect(PDFPageFormat.ansiD.name) == "ANSI D" + } + + it("has a ANSI E name") { + expect(PDFPageFormat.ansiE.name) == "ANSI E" + } + } + + context("A Series") { + + it("has a A0 name") { + expect(PDFPageFormat.a0.name) == "A0" + } + + it("has a A1 name") { + expect(PDFPageFormat.a1.name) == "A1" + } + + it("has a A2 name") { + expect(PDFPageFormat.a2.name) == "A2" + } + + it("has a A3 name") { + expect(PDFPageFormat.a3.name) == "A3" + } + + it("has a A4 name") { + expect(PDFPageFormat.a4.name) == "A4" + } + + it("has a A5 name") { + expect(PDFPageFormat.a5.name) == "A5" + } + + it("has a A6 name") { + expect(PDFPageFormat.a6.name) == "A6" + } + + it("has a A7 name") { + expect(PDFPageFormat.a7.name) == "A7" + } + + it("has a A8 name") { + expect(PDFPageFormat.a8.name) == "A8" + } + + it("has a A9 name") { + expect(PDFPageFormat.a9.name) == "A9" + } + + it("has a A10 name") { + expect(PDFPageFormat.a10.name) == "A10" + } + } + + context("B Series") { + + it("has a B0 name") { + expect(PDFPageFormat.b0.name) == "B0" + } + + it("has a B1 name") { + expect(PDFPageFormat.b1.name) == "B1" + } + + it("has a B2 name") { + expect(PDFPageFormat.b2.name) == "B2" + } + + it("has a B3 name") { + expect(PDFPageFormat.b3.name) == "B3" + } + + it("has a B4 name") { + expect(PDFPageFormat.b4.name) == "B4" + } + + it("has a B5 name") { + expect(PDFPageFormat.b5.name) == "B5" + } + + it("has a B6 name") { + expect(PDFPageFormat.b6.name) == "B6" + } + + it("has a B7 name") { + expect(PDFPageFormat.b7.name) == "B7" + } + + it("has a B8 name") { + expect(PDFPageFormat.b8.name) == "B8" + } + + it("has a B9 name") { + expect(PDFPageFormat.b9.name) == "B9" + } + + it("has a B10 name") { + expect(PDFPageFormat.b10.name) == "B10" + } + } + + context("C Series") { + + it("has a C0 name") { + expect(PDFPageFormat.c0.name) == "C0" + } + + it("has a C1 name") { + expect(PDFPageFormat.c1.name) == "C1" + } + + it("has a C2 name") { + expect(PDFPageFormat.c2.name) == "C2" + } + + it("has a C3 name") { + expect(PDFPageFormat.c3.name) == "C3" + } + + it("has a C4 name") { + expect(PDFPageFormat.c4.name) == "C4" + } + + it("has a C5 name") { + expect(PDFPageFormat.c5.name) == "C5" + } + + it("has a C6 name") { + expect(PDFPageFormat.c6.name) == "C6" + } + + it("has a C7 name") { + expect(PDFPageFormat.c7.name) == "C7" + } + + it("has a C8 name") { + expect(PDFPageFormat.c8.name) == "C8" + } + + it("has a C9 name") { + expect(PDFPageFormat.c9.name) == "C9" + } + + it("has a C10 name") { + expect(PDFPageFormat.c10.name) == "C10" + } + } + } + } + } + +}