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
78 changes: 40 additions & 38 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
GEM
remote: https://rubygems.org/
specs:
CFPropertyList (3.0.3)
activesupport (5.2.6)
CFPropertyList (3.0.5)
rexml
activesupport (6.1.5)
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)
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.10.2)
addressable (~> 2.6)
cocoapods (1.11.3)
addressable (~> 2.8)
claide (>= 1.0.2, < 2.0)
cocoapods-core (= 1.10.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)
Expand All @@ -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.3)
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.6.3)
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)
concurrent-ruby (1.1.10)
escape (0.0.4)
ethon (0.14.0)
ethon (0.15.0)
ffi (>= 1.15.0)
ffi (1.15.3)
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.10)
i18n (1.10.0)
concurrent-ruby (~> 1.0)
jazzy (0.14.0)
jazzy (0.14.2)
cocoapods (~> 1.5)
mustache (~> 1.1)
open4 (~> 1.3)
Expand All @@ -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)
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.3)
mini_portile2 (~> 2.6.1)
nokogiri (1.13.4)
mini_portile2 (~> 2.8.0)
racc (~> 1.4)
open4 (1.3.4)
public_suffix (4.0.6)
racc (1.5.2)
public_suffix (4.0.7)
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)
Expand All @@ -118,6 +119,7 @@ GEM
rexml (~> 3.2.4)
xcpretty (0.3.0)
rouge (~> 2.0.7)
zeitwerk (2.5.4)

PLATFORMS
ruby
Expand Down
153 changes: 153 additions & 0 deletions Source/API/Page Format/PDFPageFormat+NameConstants.swift
Original file line number Diff line number Diff line change
@@ -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
}
}
}
18 changes: 18 additions & 0 deletions Source/API/Page Format/PDFPageFormat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Loading