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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Zbigniew Siciarz
January 21, 2013
Programming
1.2k
3
Share
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
210
Calling Rust from other languages
zsiciarz
3
650
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
470
IPython: tips, tricks & magic
zsiciarz
8
3.6k
ShiningPanda: simple CI hosting for Python
zsiciarz
1
130
requests, czyli HTTP dla ludzi
zsiciarz
1
140
Other Decks in Programming
See All in Programming
Inside Stream API
skrb
1
620
LLM Plugin for Node-REDの利用方法と開発について
404background
0
160
プラグインで拡張される Context をtype-safe にする難しさと設計判断
kazupon
2
570
ローカルLLMを使ってB2Bサービスを作っていての学び
yaotti
0
110
[2026年度第1回ORセミナー] 計画最適化ベンチャーと競技プログラミング人材
terryu16
0
240
JJUG CCC 2026 Spring: JSpecify で実現する Kotlin フレンドリーな Java API 設計
ternbusty
1
130
OSもどきOS
arkw
0
400
TypeScriptだけでAIエージェントを作る フロント・エージェント・インフラのフルスタック実践
har1101
6
1.3k
IBM Bobを活用したレガシーアプリの最新化
oniak3ibm
PRO
1
160
関係性から理解する"同一性"の型用語たち
pvcresin
2
630
AIとRubyの静的型付け
ukin0k0
0
530
気づいたらRubyで100作品 ー クリエイティブコーディングが生活の一部になるまで / 100 Ruby Sketches Later: How Creative Coding Became Part of My Life
chobishiba
3
530
Featured
See All Featured
Deep Space Network (abreviated)
tonyrice
0
160
GitHub's CSS Performance
jonrohan
1033
470k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.3k
We Are The Robots
honzajavorek
0
240
Context Engineering - Making Every Token Count
addyosmani
9
930
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
320
Google's AI Overviews - The New Search
badams
0
1k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
280
Raft: Consensus for Rubyists
vanstee
141
7.5k
Darren the Foodie - Storyboard
khoart
PRO
3
3.4k
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!