<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: diego diego</title>
    <description>The latest articles on DEV Community by diego diego (@diego_diego_3992068b374b4).</description>
    <link>https://dev.to/diego_diego_3992068b374b4</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3829506%2F4b24096a-25fa-44bf-a074-b2ce3211d644.png</url>
      <title>DEV Community: diego diego</title>
      <link>https://dev.to/diego_diego_3992068b374b4</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/diego_diego_3992068b374b4"/>
    <language>en</language>
    <item>
      <title>I built a PDF editor… and realized most of them work in a way people wouldn’t expect</title>
      <dc:creator>diego diego</dc:creator>
      <pubDate>Tue, 17 Mar 2026 13:13:53 +0000</pubDate>
      <link>https://dev.to/diego_diego_3992068b374b4/i-built-a-pdf-editor-and-realized-most-of-them-work-in-a-way-people-wouldnt-expect-641</link>
      <guid>https://dev.to/diego_diego_3992068b374b4/i-built-a-pdf-editor-and-realized-most-of-them-work-in-a-way-people-wouldnt-expect-641</guid>
      <description>&lt;h1&gt;
  
  
  I built a PDF editor… and realized most of them work in a way people wouldn’t expect
&lt;/h1&gt;

&lt;p&gt;I’ve been working on a PDF editor recently, and I went down a rabbit hole I didn’t expect.&lt;/p&gt;

&lt;p&gt;At first, I thought building a “simple” PDF tool would be straightforward: upload a file → edit → download.&lt;/p&gt;

&lt;p&gt;But the deeper I went, the more I realized something surprising:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;most online PDF tools don’t work the way users think they do.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  The assumption everyone makes
&lt;/h2&gt;

&lt;p&gt;When you upload a PDF to an online editor, most people assume:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the file is processed instantly
&lt;/li&gt;
&lt;li&gt;maybe some light transformations happen
&lt;/li&gt;
&lt;li&gt;then it’s sent back
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In reality, a lot of tools:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;upload your file to a server
&lt;/li&gt;
&lt;li&gt;store it (sometimes longer than expected)
&lt;/li&gt;
&lt;li&gt;process it remotely
&lt;/li&gt;
&lt;li&gt;sometimes pass it through multiple services
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Not necessarily malicious — but definitely not always transparent.&lt;/p&gt;




&lt;h2&gt;
  
  
  The real technical challenge
&lt;/h2&gt;

&lt;p&gt;I tried to approach the problem differently.&lt;/p&gt;

&lt;p&gt;Instead of focusing on features first, I asked:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;what would a clean and predictable architecture for PDF editing look like?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That’s where things got interesting.&lt;/p&gt;




&lt;h2&gt;
  
  
  Problem #1: Rendering vs Editing
&lt;/h2&gt;

&lt;p&gt;PDFs are not like HTML.&lt;/p&gt;

&lt;p&gt;You don’t have:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;semantic structure
&lt;/li&gt;
&lt;li&gt;editable DOM
&lt;/li&gt;
&lt;li&gt;consistent fonts
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What you get instead is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;glyph positioning
&lt;/li&gt;
&lt;li&gt;embedded fonts
&lt;/li&gt;
&lt;li&gt;drawing instructions
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So editing text is not “editing text”.&lt;/p&gt;

&lt;p&gt;It’s more like:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;remove pixels and redraw something that looks identical&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Problem #2: Fonts are a nightmare
&lt;/h2&gt;

&lt;p&gt;This was by far the hardest part.&lt;/p&gt;

&lt;p&gt;Even if you extract the font:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;it may be subsetted
&lt;/li&gt;
&lt;li&gt;it may fail to load in the browser
&lt;/li&gt;
&lt;li&gt;it may render differently than in the original PDF
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So you end up dealing with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;fallback strategies
&lt;/li&gt;
&lt;li&gt;font matching heuristics
&lt;/li&gt;
&lt;li&gt;visual inconsistencies
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And yes… bold text randomly becoming non-bold is a real thing 😅&lt;/p&gt;




&lt;h2&gt;
  
  
  Problem #3: Pixel-perfect editing
&lt;/h2&gt;

&lt;p&gt;If you want a clean UX, you can’t just slap a contenteditable div on top.&lt;/p&gt;

&lt;p&gt;You need:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;canvas rendering for accuracy
&lt;/li&gt;
&lt;li&gt;hidden input handling for typing
&lt;/li&gt;
&lt;li&gt;custom caret drawing
&lt;/li&gt;
&lt;li&gt;manual selection logic
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Basically… rebuilding a mini text engine.&lt;/p&gt;




&lt;h2&gt;
  
  
  A different approach
&lt;/h2&gt;

&lt;p&gt;After experimenting with multiple architectures, I ended up with something like this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;render the PDF page as an image (canvas)
&lt;/li&gt;
&lt;li&gt;detect text blocks
&lt;/li&gt;
&lt;li&gt;mask original text when editing
&lt;/li&gt;
&lt;li&gt;redraw text manually using canvas
&lt;/li&gt;
&lt;li&gt;keep interaction logic separate from rendering
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This avoids a lot of inconsistencies between HTML and PDF rendering.&lt;/p&gt;




&lt;h2&gt;
  
  
  Client-side vs Server-side
&lt;/h2&gt;

&lt;p&gt;There’s also an interesting trade-off:&lt;/p&gt;

&lt;h3&gt;
  
  
  Client-side:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;better for privacy
&lt;/li&gt;
&lt;li&gt;no upload needed
&lt;/li&gt;
&lt;li&gt;limited by browser capabilities
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Server-side:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;more powerful
&lt;/li&gt;
&lt;li&gt;easier to control rendering
&lt;/li&gt;
&lt;li&gt;raises privacy concerns
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There’s no perfect solution — it depends on the use case.&lt;/p&gt;




&lt;h2&gt;
  
  
  What surprised me the most
&lt;/h2&gt;

&lt;p&gt;Honestly?&lt;/p&gt;

&lt;p&gt;How complex something as “simple” as editing a PDF actually is.&lt;/p&gt;

&lt;p&gt;It’s one of those problems that looks trivial from the outside, but gets messy very quickly.&lt;/p&gt;




&lt;h2&gt;
  
  
  Curious to hear your thoughts
&lt;/h2&gt;

&lt;p&gt;If you’ve worked with PDFs before:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;how did you handle font rendering?
&lt;/li&gt;
&lt;li&gt;did you go client-side or server-side?
&lt;/li&gt;
&lt;li&gt;any tricks for keeping visual consistency?
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I’d love to learn how others approached this.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>ai</category>
      <category>programming</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
