Skip to content

Commit 7bbf936

Browse files
Create config.py
1 parent ffe19c0 commit 7bbf936

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

indtall.md/scrips/config.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from pypdf import PdfReader, PdfWriter
2+
3+
reader = PdfReader("input.pdf")
4+
writer = PdfWriter()
5+
6+
# 1. Standardize to 720p Web Size
7+
WEB_WIDTH, WEB_HEIGHT = 1280, 720
8+
9+
for page in reader.pages:
10+
page.scale_to_size(WEB_WIDTH, WEB_HEIGHT)
11+
page.compress_content_streams() # Compress text/drawings
12+
writer.add_page(page)
13+
14+
# 2. STRIP METADATA: Set to None to remove all hidden info
15+
writer.add_metadata({}) # Clears existing entries
16+
17+
# 3. Final Optimization: Deduplicate images/fonts
18+
writer.compress_identical_objects(remove_identicals=True, remove_orphans=True)
19+
20+
with open("web_asset.pdf", "wb") as f:
21+
writer.write(f)

0 commit comments

Comments
 (0)