Hello,

I'm trying to edit existing pdf file. More precisely add new text or replace some text with another text.
When i try to replace some text with another the problem is that it simply overlays ontop of the field which is not what I need.
I need the text to cause the entire text to shift around. For example, if I replace the word "text" with "this is a long text", the replacement causes other text to be overlapped and run off the page. I need it as if I were editing a Word document - as I type, all the text in the rest of the document is arranged to fit the text I am adding.

I have tried different .net libraries but nothing helped me till now.
Can any one please halpe me?

Thank you in advance.

Recommended Answers

All 7 Replies

That's not how PDF files work. All of the calculations that take place in the layout stage are done and finalised (this sets PDF apart from Postscript).

You need to treat PDF files as if they are paper. If there's an update, reprint it from the new source. It's digital and free, much easier than printing out some words and try to glue them in the right place.

commented: And that's how it is. +15

Hello pty,

thank you for your answer.

Can you please suggest me any tool for inspecting (scanning ) a pdf file?
As you suggested i can reprint the pdf file, the problem is that i dont have the "source code".

thank you.

You do have a source of sorts. There are PDF to Word and other convertors so you do that first, edit the resulting text and then print it to PDF with one of the many PDF kits out there.

Editing a PDF is pretty much as pty suggests. It's just a hack job and some will want the resulting PDF to be without the usual flaws you find with today's PDF editors. I'm sure you googled this so I'll pause here.

Hello rproffitt,

thank you for your answer.

The pdf files that i am dealing are very complex, containing tables, checkboxes , radio buttons images etc. Im trying to use different libraries ( like Spire pdf ) and i have used the same "technique" as you suggested (converting pdf document to word and then editing) but the problem rimains the same ( For example, if I replace the word "text" with "this is a long text", the replacement causes other text to be overlapped and run off the page).
For this i was wondering if i can use something that gives me the "source code " of pdf file so i can riprint the pdf file with my changes, but i don't know if this could be possible...

@OP. Exactly as pty noted. There is no known PDF editor that let's us edit as if we had the source. Now if you are really devious you can make a replacement page and replace the better page but if this is "your" document it may be time to have your staff re-create the source.

One of the many reasons for PDFs is to protect the source. But I have some good news. Many researchers will supply you source if you ask. It's always been a small mystery to me that the few times I've run into folk face to face on this they refuse to ask the author and owner or the document for an editable version.

I'm using Foxit PhantomPDF from time to time.
Here is the tutorial for editing text.
It is not free software(less than 100$?) but IMO it is worth it.
Perhaps ask FOxit if they have a link with C#.

The pdf files that i am dealing are very complex, containing tables, checkboxes , radio buttons images etc

I wouldn't do this. Whoever came up with this was a masochist. Replace it and don't waste any more time trying to modify PDFs. That's not what they're for.

Trust me, I used to work in the translation industry. We had an entire department who did this kind of thing on an ad hoc basis (customer wants this PDF in French, Bulgarian and Mandarin by Tuesday). The process took about fifteen times longer than working with a text or Word file and was priced accordingly. The results were never perfect, especially for non-standard layouts. Text didn't reflow properly, things didn't always line up.

tl,dr; you're doing it wrong. Start again now you know why.

commented: +1 for YDIW. Sometimes that's it, plain and simple. +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.