Skip to content

Commit

Permalink
added custom size option
Browse files Browse the repository at this point in the history
  • Loading branch information
vinissou committed Oct 12, 2024
1 parent 206cbaf commit aa1dfcb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 30 deletions.
8 changes: 4 additions & 4 deletions modules/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ def options():
A8 B8
B10
ANSI
LETTER  [MORE FORMATS COMING SOON]
LETTER 
LEGAL
LEDGER 
TABLOID 
EXECUTIVE
ANSI_C
ANSI_D
ANSI_E
You can choose your custom size with the command: -c x y
"""
print(options_text)
Expand Down
25 changes: 3 additions & 22 deletions modules/paper_sizes.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# list based on https://www.prepressure.com/library/paper-size
# I was not able to confirm the others sizes listed in the above link
# As this was the only one listing the formats in points, more
# research will be needed
# I was not able to confirm the others sizes listed in the above link,
# and some categories like newspapers have varying sizes across the
# the world, so I included a custom size option.

ISO = {
"A0": {"x": 2384, "y": 3370},
Expand Down Expand Up @@ -52,22 +52,3 @@ def paper_size(standard):
else:
raise NameError("Not a standard")


# print(paper_size("aaaa")["x"])
# TODO confirm the following sizes:
# UK_PAPER = {
# "FOOLSCAP": {"x": 954, "y": 1188},
# "SMALL_POST": {"x": 1044, "y": 1332},
# "SHEET1-3_CAP": {"x": 954, "y": 1584},
# "SHEET1-2_CAP": {"x": 954, "y": 1782},
# "DEMY": {"x": 1116, "y": 1440},
# "LARGE_POST": {"x": 1188, "y": 1512},
# "SMALL_MEDIUM": {"x": 1260, "y": 1584},
# "MEDIUM": {"x": 1296, "y": 1656},
# "SMALL_ROYAL": {"x": 1368, "y": 1728},
# "ROYAL": {"x": 1440, "y": 1800},
# "IMPERIAL": {"x": 1584, "y": 2160},
# }
# UK_PRINTING
# US_PRINTING
# NEWSPAPER
16 changes: 12 additions & 4 deletions pdf_page_size_fixer.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ def parsing_args():
parser.add_argument(
"--size", "-s", type=str, help="select the paper, default is A4"
)
parser.add_argument(
"--custom", "-c", nargs=2, type=str, help="select the paper size manually in PostScript points"
)
return parser.parse_args()


def main():
args = parsing_args()

Expand All @@ -39,9 +41,15 @@ def main():
page_size = args.size
else:
page_size = "A4"

page_x = paper_size(page_size)["x"] # this wil be a dedicated
page_y = paper_size(page_size)["y"] # function

if (args.custom):
print(args.custom[0])
print(args.custom[1])
page_x = int(args.custom[0])
page_y = int(args.custom[1])
else:
page_x = paper_size(page_size)["x"]
page_y = paper_size(page_size)["y"]

for page in src:
imglist = src.get_page_images(page.number)[0]
Expand Down

0 comments on commit aa1dfcb

Please sign in to comment.