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
1.2k
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Building an online PDF editor from scratch
My talk at PyWaw #20.
http://www.pywaw.org/21-01-2013
Zbigniew Siciarz
January 21, 2013
More Decks by Zbigniew Siciarz
See All by Zbigniew Siciarz
What if Socrates was a dev?
zsiciarz
0
220
Calling Rust from other languages
zsiciarz
3
660
An introduction to the Rust ecosystem
zsiciarz
5
1.9k
Python3-only Django project - the benefits
zsiciarz
1
400
My God, it's full of stars! (and planets and Python)
zsiciarz
0
3.6k
PostgreSQL & Django - a tasty mix
zsiciarz
2
480
IPython: tips, tricks & magic
zsiciarz
8
3.6k
ShiningPanda: simple CI hosting for Python
zsiciarz
1
130
requests, czyli HTTP dla ludzi
zsiciarz
1
150
Other Decks in Programming
See All in Programming
AI 輔助遺留系統現代化的經驗分享
jame2408
1
1.2k
壊れたパーサから始める関数型設計と構成的なパーサ #fp_matsuri
raiga0310
2
330
Apache Hive: そしてCloud Native Lakehouseへ
okumin
1
140
才能?センス?知らん、 続けたもん勝ちだ。-- 結婚・出産・癌を越えてなお、私がプロダクトを創り続ける理由
16bitidol
2
870
Embedded SREと共に達成した会員管理システムのAWS移行 - SRE NEXT 2026 ランチスポンサーセッション
niftycorp
PRO
1
2.7k
AI時代の仕事技芸論〜ソフトウェア開発で「遊ぶように働く」職人的熟達のすすめ(スクフェス仙台 2026バージョン)
kuranuki
0
660
Go言語とトイモデルで学ぶTransformerの気持ち / fukuokago23-transformer
monochromegane
0
110
LLMによるContent Moderationの本番運用の裏側と品質担保への挑戦
suikabar
3
860
なぜ関数型プログラミングで「型」と「証明」が語られるのか #fp_matsuri
kajitack
3
960
20260623_Loop Engineeringで自分の分身の問い合わせBotを作る
ryugen04
0
220
Haskell/Servantを通してWebミドルウェアを捉え直す
pizzacat83
1
590
AI がコードを書く時代における新卒エンジニアの仕事風景 (2026) / New Graduate Engineers in the Era of AI Coding (2026)
sushichan044
0
220
Featured
See All Featured
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.1k
Color Theory Basics | Prateek | Gurzu
gurzu
0
390
Accessibility Awareness
sabderemane
1
160
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.9k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.5k
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
600
Believing is Seeing
oripsolob
1
170
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
Code Review Best Practice
trishagee
74
20k
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
1
2.1k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.6k
The Curious Case for Waylosing
cassininazir
1
430
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!