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: Adding new text to PDF file from Visual Basic
Conf: (P-PDF) Developers, Msg: 82068
From: planetpdfusr
Date: 2/25/2003 11:02 PM

I am looking for a VB code example, illustrating a simple way to add arbitrary text at specified positions in a PDF file, using a specified font type and size (e.g. 12-point Courier-Bold), without using Acrobat Forms.
This limitation arises from the fact that forms cannot be used for making multipage documents, each containing different data for the same form, as fields are not automatically renamed when new copies of the same form are added to the PDF document, so that you end up with a number of identical forms with identical data.

Suppose, for example, you have a database table, containing a list of names and addresses of employees, and you want to create a multipage PDF document, where each page contains the name and address of a different employee.

Ideally, you might follow these steps:
a) start up Acrobat;
b) create a new, single-page PDF document, named "Master.pdf";
c) create the following fields: "FirstName", "SecondName", "Address";
d) save the file as "Master.pdf";
e) save a copy of this file as "Addresses.pdf";
f) open both documents in separate PDDoc objects from VB code;
g) create an AcroForm object;
g) read field values for the first employee into the AcroForm Fields;
h) insert the AcroForm page into the second PDF object;
i) repeat the two previous steps for each employee;
j) save the destination file.

The final result is a document with as many pages as the total number of employees plus one (as you started up with a single page, containing an empty form), each containing the same data, i.e. name and address of the last employee.
This is because you have many copies of same form, with identically-named fields, and you have no means to rename fields incrementally in run-time (which is the only way to resolve the omonimity problem).
Therefore, each time you assign a new value to a specific field, say "Address", you are actually updating all occurrences of that field (one per page).
Unfortunately, you cannot create a multipage form with unique name fields (i.e. "Name1" at page 1, "Name2" at page2, etc.), as this would be an endless job, and you might not know in advance how many forms are needed (i.e. the actual number of employees in the table at run-time).

I suppose the only possible solution is not to use AcroForms, but write data text directly into the target document, after mapping the document field positions to a record array, so you know exactly where to write each field data.
Unfortunately, I was unable to produce this behaviour with VB code (in fact, I was unable to locate the PDFEdit and PDEText objects too, which I assume are the required building bricks).
Anyone who can help?


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

Back to the past, 15 years ago! Open Publish 2002

Looking back to 2002, it's amazing how much of the prediction became a reality. Take a read and see what you think!

September 14, 2017
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.

Features

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.