Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
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
230
Calling Rust from other languages
zsiciarz
3
670
An introduction to the Rust ecosystem
zsiciarz
5
1.9k
Python3-only Django project - the benefits
zsiciarz
1
410
My God, it's full of stars! (and planets and Python)
zsiciarz
0
3.7k
PostgreSQL & Django - a tasty mix
zsiciarz
2
490
IPython: tips, tricks & magic
zsiciarz
8
3.6k
ShiningPanda: simple CI hosting for Python
zsiciarz
1
140
requests, czyli HTTP dla ludzi
zsiciarz
1
150
Other Decks in Programming
See All in Programming
FreeBSDでZabbixを動かす
kenkino
0
360
Embedded Swiftで作る自作USBデバイス によるiOSデバイスの自動テスト / iOSDC Japan 2026 glassfiber
glassfiber
0
290
Turning Architecture into Unit Tests in the AI Era (NSSpain XIV)
steliosf
PRO
1
130
半永久的に提供し続けられるプライベートクラウドを目指して ― 利用者の認知負荷を抑えるAPI抽象化とハードウェア世代交代の基盤設計
tomokon
0
440
ゲームコントローラやキーボードのファームウェアをSwiftで書く
kishikawakatsumi
1
280
Agents on Rails - Rails at Scale 2026
irinanazarova
0
330
wkhtmltopdfの次どうするか問題2026
willnet
2
1.8k
SalesForceを内製化!? ~ HR事業を支える顧客管理基盤のインフラを大公開 ~
oku053
0
120
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
520
APNsからLive Activityを開始する話
yumnumm
0
150
技術的負債を組織課題として解く-増えすぎたマイクロサービスとの戦い-
reimaru
1
2.8k
The Rails Doctrine Decade
koic
2
500
Featured
See All Featured
SEO for Brand Visibility & Recognition
aleyda
0
4.8k
4 Signs Your Business is Dying
shpigford
187
23k
Building Applications with DynamoDB
mza
96
7.2k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
12k
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
580
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
570
Rebuilding a faster, lazier Slack
samanthasiow
85
9.7k
The Curious Case for Waylosing
cassininazir
1
550
Everyday Curiosity
cassininazir
0
340
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
18k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
210
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!