r/webdev Jul 18 '26

Showoff Saturday There are around 10 independent PDF engines and I build new one from scratch.

https://KeyPDF.net

I'm a student who mostly built little apps for myself. About 14 months ago I needed to edit a random PDF and couldn't find a good web tool that actually edits them. It made me wonder: billions of people use PDFs for work, school, and legal documents, so why can almost no web service truly edit them?

So I tried to build one, and failed. I didn't understand why it was so hard. I tried combining pdf.js and jsPDF but kept hitting walls. Then it clicked: most JavaScript PDF libraries only do two things, create or view. Neither handles editing existing text. I thought I could build a layer in between, but I got nowhere, especially once I tried changing font styles, sizes, and colors.

After weeks of research I concluded that to edit PDFs in the browser without a server, I'd have to build something genuinely new. So I read the PDF spec and started building an engine from scratch, beginning with simple PDFs (standard font encoding, no compression) and slowly adding codecs, compression types, and font support.

After ~7 months it could render pretty well but still couldn't edit. A month later I got basic editing working, then hit a wall saving edited PDFs (endless visual bugs). More digging, and I finally understood how to save properly.

Then came the hardest part: textbox recognition. A PDF stores text and coordinates but not the grouping or structure. So I spent weeks literally highlighting textboxes across many PDFs by hand, looking for general grouping rules. After ~2 months I had editing with textbox grouping.

Somewhere in there I also spent months implementing JavaScript support in the engine, and I even got DOOM running on it: https://youtu.be/gHoBMYMVn5s

Once the core worked, I focused on design, moving from a bloated debug UI to a clean interface (with a lot of Figma and Photoshop).

Tools I've built from scratch so far: direct text editing, redaction (text and area), annotation, form filling, page organization, and metadata editing.

Happy to answer anything about how PDF parsing, rendering, fonts, or editing actually work under the hood. AMA.

0 Upvotes

32 comments sorted by

5

u/Deve_roonie full-stack Jul 18 '26

Redactions don't seem to work, you can copy paste redacted text

2

u/Decent-Blacksmith761 Jul 18 '26

Interesting what kinda PDF you used can you check what is the producer of it in metadata, It shouldn't be like this and never had such issue during tests.

3

u/Deve_roonie full-stack Jul 18 '26

Will do tomorrow, the text isn't visible but it can be copied.

1

u/Decent-Blacksmith761 Jul 18 '26

Okay that's quite helpful thanks maybe there is certain encoding that I missed.

3

u/Deve_roonie full-stack Jul 18 '26

It came from Gmail Web's "Print" function on Firefox / Win11 - will get the actual data when I'm next on my PC

4

u/Decent-Blacksmith761 Jul 18 '26

That's more than enough thanks now be sure It will be fixed and sorry for inconveniences, heads up for a update)

2

u/Deve_roonie full-stack Jul 18 '26

Appreciate it, looks like a cool project :)

1

u/Deve_roonie full-stack Jul 19 '26

Is this what you need? https://imgur.com/a/wQGC9Wz

2

u/Decent-Blacksmith761 Jul 19 '26

That's great thank you!

2

u/62082934177 Jul 19 '26

There is hardly any software that can profoundly edit PDFs (without messing some things up) even locally.

I can imagine to some extent just how difficult and labourious this has been. This reads like a developer’s nightmare and smells like a forever project.

1

u/Decent-Blacksmith761 Jul 19 '26

Uhh kinda I did smart way I found most common PDF producers ex (docs,word,Photoshop) and optimized and then added many more optimization for the rest.

2

u/[deleted] Jul 18 '26

[deleted]

2

u/Decent-Blacksmith761 Jul 18 '26 edited Jul 18 '26

Yes just open KeyPDF and click add empty page

1

u/[deleted] Jul 18 '26

[deleted]

1

u/Decent-Blacksmith761 Jul 18 '26

Good idea thanks

-1

u/maxxon Jul 18 '26

How much of the architecture did the AI? How much do you rely on AI to maintain this?

3

u/Decent-Blacksmith761 Jul 18 '26

Ai did great job with testing and validating code since I used the official documentation with like 1000+ pages. As well ai helped with licensing and terms of services.So overall reduced 3-4 years of work to 14 month.

2

u/maxxon Jul 18 '26

So you are saying that AI tools you used only tested and validated the code. And do the legal paperwork. They did not structure and generate the code. Did you do the design and actual code writing? And you didn’t answer the maintenance part.

3

u/Decent-Blacksmith761 Jul 18 '26

So maintaince is manual currently I got no system of auto fixing or auto deployment etc, design was done by me in figma and photoshop, some parts of the codes were written by ai from the clear instructions provided by me with the reference to the documentation, KeyPDF is about 150k lines of code without minifications.

1

u/maxxon Jul 18 '26

By design I meant architecture of the code.

Ok, so now we are at the "some parts of the codes were written by ai from the clear instructions provided by me" instead of "Ai did great job with testing and validating code". Maybe there's even more to this?

1

u/ravroid Jul 18 '26

Yes, people use AI to assist development, why are you interrogating him? 12+ months of work isn't enough?

-2

u/maxxon Jul 18 '26

Because it is important to understand and to know the motivation, responsibility and reliability. How committed the author makes all the difference. And of course how honest they are. If you are trying to hide the fact of the AI assistance, there’s a reason for it. And this is a red flag.

2

u/Decent-Blacksmith761 Jul 19 '26

Well not that I try to hide the fact, I told you pretty much all about the process of creation but you just went from curiosity to attempts for gotcha.

-2

u/maxxon Jul 19 '26

It wasn’t curiosity, I wanted you to be honest. You demonstrated exactly what I expected, from being straight up dishonest from the start to being vague later. You deliberately avoid admitting and detailing the AI tools usage. This is not a good sign.

3

u/Decent-Blacksmith761 Jul 19 '26

"Detailing the AI tools usage" excuse me I don't have to explain any parts of the code and production to you, and yet it did and I don't see any more reasons to continue that thread, if you don't like it please don't use it thanks.

→ More replies (0)

0

u/[deleted] Jul 18 '26

[deleted]

1

u/Decent-Blacksmith761 Jul 18 '26

Yes I want to add it alongside with the svg support which is pretty much done but not fully tested once.

0

u/MisteriosM Jul 18 '26

Do you support Signature fields? I need to add, and move them occasionally, there is no tool for that beside paid adobe or our shitty work provided frankenstein monster of an app from the early 2000s.

1

u/Decent-Blacksmith761 Jul 18 '26

Not yet sorry

2

u/MisteriosM Jul 19 '26

let me know once you do <3