Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
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
140
Calling Rust from other languages
zsiciarz
3
630
An introduction to the Rust ecosystem
zsiciarz
5
1.9k
Python3-only Django project - the benefits
zsiciarz
1
370
My God, it's full of stars! (and planets and Python)
zsiciarz
0
3.3k
PostgreSQL & Django - a tasty mix
zsiciarz
2
440
IPython: tips, tricks & magic
zsiciarz
8
3.5k
ShiningPanda: simple CI hosting for Python
zsiciarz
1
110
requests, czyli HTTP dla ludzi
zsiciarz
1
120
Other Decks in Programming
See All in Programming
ワープロって実は計算機で
pepepper
2
1.3k
Flutterと Vibe Coding で個人開発!
hyshu
1
250
Comparing decimals in Swift Testing
417_72ki
0
170
No Install CMS戦略 〜 5年先を見据えたフロントエンド開発を考える / no_install_cms
rdlabo
0
480
Understanding Kotlin Multiplatform
l2hyunwoo
0
260
Nuances on Kubernetes - RubyConf Taiwan 2025
envek
0
170
CEDEC2025 長期運営ゲームをあと10年続けるための0から始める自動テスト ~4000項目を50%自動化し、月1→毎日実行にした3年間~
akatsukigames_tech
0
140
Terraform やるなら公式スタイルガイドを読もう 〜重要項目 10選〜
hiyanger
13
3.1k
React 使いじゃなくても知っておきたい教養としての React
oukayuka
18
5.7k
UbieのAIパートナーを支えるコンテキストエンジニアリング実践
syucream
2
400
AHC051解法紹介
eijirou
0
580
ゲームの物理
fadis
5
1.2k
Featured
See All Featured
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
VelocityConf: Rendering Performance Case Studies
addyosmani
332
24k
Testing 201, or: Great Expectations
jmmastey
45
7.6k
4 Signs Your Business is Dying
shpigford
184
22k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
358
30k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
53
2.9k
A better future with KSS
kneath
239
17k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
23
1.4k
GitHub's CSS Performance
jonrohan
1031
460k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
283
13k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
8
460
Become a Pro
speakerdeck
PRO
29
5.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!