#include <ContentReplacer.h>
Public Member Functions | |
| ContentReplacer () | |
| ~ContentReplacer () | |
| void | AddImage (const Rect &target_region, SDF::Obj replacement_image) |
| void | AddText (const Rect &target_region, const UString &replacement_text) |
| void | AddString (const UString &template_text, const UString &replacement_text) |
| void | SetMatchStrings (const UString &start_str, const UString &end_str) |
| void | Process (Page &page) |
| void | Destroy () |
Public Attributes | |
| TRN_ContentReplacer | mp_impl |
ContentReplacer is a utility class for replacing content (text and images) in existing PDF (template) documents.
Users can replace content in a PDF page using the following operations:
The following code replaces an image in a target region. This code also replaces the text "[NAME]" and "[JOB_TITLE]" with "John Smith" and "Software Developer" respectively. Notice the square braces ('[' and ']') on the target strings in the original PDFDoc. These square braces are not included in the actual function calls below, as they're implicitly added.
Definition at line 40 of file ContentReplacer.h.
| pdftron::PDF::ContentReplacer::ContentReplacer | ( | ) |
Create a new ContentReplacer object, to which replacement rules will be added. The same object can be used to 'Process' multiple pages.
| pdftron::PDF::ContentReplacer::~ContentReplacer | ( | ) |
| void pdftron::PDF::ContentReplacer::AddImage | ( | const Rect & | target_region, |
| SDF::Obj | replacement_image | ||
| ) |
Replace the image that best fits into 'target_region' with 'replacement_image'.
| target_region | - The rectangle defining the area in which an image that best fits the rectangle will be replaced by 'replacement_image'. |
| replacement_image | - The 'SDF.Obj' of a 'PDF.Image' object. |
| void pdftron::PDF::ContentReplacer::AddString | ( | const UString & | template_text, |
| const UString & | replacement_text | ||
| ) |
Any text of the form "[template_text]" will be replaced by "replacement_text".
| template_text | - The text to remove. |
| replacement_text | - The new text that will appear in place of 'template_text'. |
| void pdftron::PDF::ContentReplacer::AddText | ( | const Rect & | target_region, |
| const UString & | replacement_text | ||
| ) |
All text inside 'target_region' will be deleted and replaced with 'replacement_text'.
| target_region | - The rectangle defining the area in which all text will be replaced by 'replacement_text'. |
| replacement_text | - The new text that will replace the existing text in 'target_region'. |
| void pdftron::PDF::ContentReplacer::Destroy | ( | ) |
Frees the native memory of the object.
| void pdftron::PDF::ContentReplacer::Process | ( | Page & | page | ) |
Apply the replacement instructions to the target page. Subsequent calls to 'Process' can be made on other pages, and it will apply the same rules.
| page | - The page to apply the content replacement instructions to. |
| void pdftron::PDF::ContentReplacer::SetMatchStrings | ( | const UString & | start_str, |
| const UString & | end_str | ||
| ) |
Change the delimiters from '[' and ']' to arbitary strings.
| start_str | - The starting delimiter string. |
| end_str | - The ending delimiter string. |
| TRN_ContentReplacer pdftron::PDF::ContentReplacer::mp_impl |
Definition at line 128 of file ContentReplacer.h.