wxPDFdocument, replace a text in a pdf file.

Talk here about issues with one of the components hosted at wxCode, or suggest features for it.
Post Reply
ajm
Knows some wx things
Knows some wx things
Posts: 40
Joined: Thu Nov 25, 2010 12:48 pm

wxPDFdocument, replace a text in a pdf file.

Post by ajm »

Hi,

I am using wxPdfDocument to generate a pdf file. I am thinking to use template and just replace the text in this pdf, for example {name} --> Jack.

Is it possible?

Thank you
utelle
Moderator
Moderator
Posts: 1125
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: wxPDFdocument, replace a text in a pdf file.

Post by utelle »

ajm wrote:I am using wxPdfDocument to generate a pdf file. I am thinking to use template and just replace the text in this pdf, for example {name} --> Jack.

Is it possible?
No. wxPdfDocument allows to generate PDF files from scratch and it allows to reuse whole pages of existing PDF files. It has no direct support for manipulating the content of existing pages.

There are classes in wxPdfDocument which allow to access the various objects of an existing PDF file. However, replacing text within a page would require to parse the content stream of a page. The latter is definitely not supported by wxPdfDocument.

Regards,

Ulrich
ajm
Knows some wx things
Knows some wx things
Posts: 40
Joined: Thu Nov 25, 2010 12:48 pm

Re: wxPDFdocument, replace a text in a pdf file.

Post by ajm »

Thank you utelle.
ajm
Knows some wx things
Knows some wx things
Posts: 40
Joined: Thu Nov 25, 2010 12:48 pm

Re: wxPDFdocument, replace a text in a pdf file.

Post by ajm »

What about extracting the text? is it possible?
utelle
Moderator
Moderator
Posts: 1125
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: wxPDFdocument, replace a text in a pdf file.

Post by utelle »

ajm wrote:What about extracting the text? is it possible?
Again, this would require to parse the content stream of a page. And that is not supported by wxPdfDocument. So the answer to your question is No, unless you write a content parser yourself.

Extracting text from pages of a PDF file is not a trivial task, since you have to deal with text encodings related to the fonts used to create the document.

Regards,

Ulrich
ajm
Knows some wx things
Knows some wx things
Posts: 40
Joined: Thu Nov 25, 2010 12:48 pm

Re: wxPDFdocument, replace a text in a pdf file.

Post by ajm »

I think, I am not able to write a content parser. so i should find another library or else.

Thank you again.
Post Reply