Planet PDF Forum Archive

Planet PDF ForumWowsers! This is page is old, head to the LIVE Planet PDF Forum. It features more than 10 conferences, covering everything from beginner to in-depth developer and pre-press discussions. If you wish to continue... one & two archive covers 1999-2011 (160,000 pages).

New Forum | Previous | Next | (P-PDF) Developers

Topic: Re: Batch Search and Replace
Conf: (P-PDF) Developers, Msg: 56533
From: LeonardR
Date: 5/29/2002 05:20 PM

At 06:00 PM 6/12/2001 -0400, p-pdf-developer Listmanager wrote:
>Hi, I need to do a search and replace on PDF files. I would like to
>create a CGI program that will search a PDF file for a given string
>(stra), replace with another string (strb), and save the resulting file to
>a PDF file.

Will these strings be the same size/length? What do you plan to
do in the case where they are not, since PDF files don't reflow?

>I chose to do it this way so I could provide a tool to the people that
>need to do the search & replace (there are lots of files) as opposed to
>doing them myself. They would visit a web page, upload a PDF, then
>receive the resulting/converted PDF.

That's nice of you, but you are probably getting in over your head!

>I think I could do this if all the text was readily-readable in the PDF,
>but it is not. In Acrobat reader, it is selectable, and when I paste it
>into notepad it looks file. My guess is that it is compressed?

Not only is it compressed, BUT it may also not be in logical order
or contiguous. For example, in PDF the you could draw the string "foo" in
any of the following ways (of which there are others!):

[(f)-100(o)-100(o)] TJ
(f)Tj (o)Tj (o)Tj

>So then I think my question is, is there a tool that will uncompress the
>parts of it and essentially save the entire file uncompressed, then I will
>search & replace it, then another utility that will convert the
>uncompressed file as compressed?

Yes, there are tools that could do this BUT these tools wouldn't
also maintain all the styling information and that would be bad! Even
trying to do search & replace "inline" to the PDF is a VERY difficult
process (which is why you don't see many tools that can do this).

If you REALLY want to do this, expect to invest a good 50-100K in
software licenses to purchase the necessary libraries that can offer such
functionality. AND THEN you can start to write the software to do what you

I am NOT trying to dissuade you from this venture, I just want you
to know what you are getting involved in.


Leonard Rosenthol
Director of Software Development (215) 922-3509 (voice)
Appligent, Inc. (formerly Digital Applications) (610) 284-4233 (fax)

PGP Fingerprint: 8CC9 8878 921E C627 0BC1 15BB FC19 64A9 0016 1397

PDF In-Depth Free Product Trials Ubiquitous PDF

Debenu Aerialist

The ultimate plug-in for Adobe Acrobat. Advanced splitting, merging, stamping, bookmarking, and link...

Download free demo

Debenu PDF Tools Pro

It's simple to use and will let you preview and edit PDF files, it's a Windows application that makes...

Download free demo

Five visions of a PDF Day

In the world of PDFs or as we like to say Planet (of) PDF, a year isn't a real PDF year without an intense few days of industry knowledge sharing.

May 15, 2018
Platinum Sponsor

Search Planet PDF
more searching options...
Planet PDF Newsletter
Most Popular Articles
Featured Product

Debenu PDF Aerialist

The ultimate plug-in for Adobe Acrobat. Advanced splitting, merging, stamping, bookmarking, and link control. Take Acrobat to the next level.


Adding a PDF Stamp Comment

OK, so you want to stamp your document. Maybe you need to give reviewers some advice about the document's status or sensitivity. This tip from author Ted Padova demonstrates how to add stamps with the Stamp Tool along with related comments.