Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Building an online PDF editor from scratch
Search
Zbigniew Siciarz
January 21, 2013
Programming
3
1.1k
Building an online PDF editor from scratch
My talk at PyWaw #20.
http://www.pywaw.org/21-01-2013
Zbigniew Siciarz
January 21, 2013
Tweet
Share
More Decks by Zbigniew Siciarz
See All by Zbigniew Siciarz
What if Socrates was a dev?
zsiciarz
0
170
Calling Rust from other languages
zsiciarz
3
640
An introduction to the Rust ecosystem
zsiciarz
5
1.9k
Python3-only Django project - the benefits
zsiciarz
1
380
My God, it's full of stars! (and planets and Python)
zsiciarz
0
3.4k
PostgreSQL & Django - a tasty mix
zsiciarz
2
450
IPython: tips, tricks & magic
zsiciarz
8
3.6k
ShiningPanda: simple CI hosting for Python
zsiciarz
1
120
requests, czyli HTTP dla ludzi
zsiciarz
1
130
Other Decks in Programming
See All in Programming
実はマルチモーダルだった。ブラウザの組み込みAI🧠でWebの未来を感じてみよう #jsfes #gemini
n0bisuke2
2
1.1k
Why Kotlin? 電子カルテを Kotlin で開発する理由 / Why Kotlin? at Henry
agatan
2
7.2k
AIエージェントを活かすPM術 AI駆動開発の現場から
gyuta
0
410
dotfiles 式年遷宮 令和最新版
masawada
1
770
FluorTracer / RayTracingCamp11
kugimasa
0
230
AIの誤りが許されない業務システムにおいて“信頼されるAI” を目指す / building-trusted-ai-systems
yuya4
6
3.5k
從冷知識到漏洞,你不懂的 Web,駭客懂 - Huli @ WebConf Taiwan 2025
aszx87410
2
2.6k
TestingOsaka6_Ozono
o3
0
150
「コードは上から下へ読むのが一番」と思った時に、思い出してほしい話
panda728
PRO
38
26k
Rediscover the Console - SymfonyCon Amsterdam 2025
chalasr
2
160
LLMで複雑な検索条件アセットから脱却する!! 生成的検索インタフェースの設計論
po3rin
3
720
Findy AI+の開発、運用におけるMCP活用事例
starfish719
0
370
Featured
See All Featured
Building Adaptive Systems
keathley
44
2.9k
Building Flexible Design Systems
yeseniaperezcruz
330
39k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.1k
Git: the NoSQL Database
bkeepers
PRO
432
66k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3.1k
KATA
mclloyd
PRO
32
15k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
359
30k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
1.6k
For a Future-Friendly Web
brad_frost
180
10k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.3k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
3.2k
Making Projects Easy
brettharned
120
6.5k
Transcript
Building an online PDF editor from scratch PyWaw #20, 21.01.2013
Zbigniew Siciarz @zsiciarz http://siciarz.net
Why?
Disclaimer • still not a full-blown editor • proof of
concept • simple way to add rich media content to digital magazines
Current status
Links
Multimedia
Go to page
Everything is a link • website URLs (d’oh!) • multimedia
content (audio/video/galleries) • internal links („go to page”) • custom HTML5 widgets
Workflow 1. upload a PDF file 2. preprocessing on the
server 3. add widgets, links etc. in web editor 4. save and create package 5. publish to mobile devices 6. download package and display content Publisher
Preprocessing • run asynchronously as a queued task • extract
metadata from uploaded file • create page thumbnails (with ImageMagick) • find any existing links • mark as unpublished
Keep existing links! • extract links with PyPDF2 • store
in database as PdfLink objects • display in web editor
Dimensions and boxes • cartesian coordinate system • box is
a list of 4 floats: [x1, y1, x2, y2] • PDF units = 1/72”= pt x y (0, 0) (x1, y1) (x2, y2)
Dimensions and boxes • artBox
Dimensions and boxes • artBox • bleedBox
Dimensions and boxes • artBox • bleedBox • cropBox
Dimensions and boxes • artBox • bleedBox • cropBox •
mediaBox
Dimensions and boxes • artBox • bleedBox • cropBox •
mediaBox • trimBox
Dimensions and boxes • artBox • bleedBox • cropBox •
mediaBox • trimBox
PDF Encryption
Links • PDF annotations are messy • 4 (or more?)
different representations • indirect objects all the way down • reversed coordinates • peculiar edge cases still not covered
Watermarking • create blank PDF (watch out for page dimensions!)
• draw links with ReportLab • cross your fingers • merge with original file
Watermarking
Merging + =
Merging • PyPDF2 can’t properly merge PDFs with links :(
• ReportLab can’t extract links from PDFs* • several hours wasted on hacking PyPDF2 • pdftk…? • pdftk! *Open Source version
Merging • apply watermark page by page to original PDF
• does not work :( • works!
Final package • encrypted PDF + media assets • digitally
signed archive • publication = push notification to devices • mobile application downloads the package and displays content
Conclusion • sadly, 3 different toolkits are necessary to get
the job done PyPDF2 ReportLab pdftk Extract links Yes No* No Draw links No Yes No Merge and preserve links No No Yes *Open Source version
ReportLab PLUS? • „ Reuse your existing pdfs in new
and exciting ways” • might just work • pricey :(
Appendix
Appendix
Credits • Businessperson designed by Devochkina Oxana from The Noun
Project • Servers designed by Daniel Campos from The Noun Project • Maru - http://sisinmaru.blog17.fc2.com/
Questions?
Thank you!