Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Strange behavior with spawned template on manually inserted pages

Status
Not open for further replies.

RustyAfro

Programmer
Jan 12, 2005
332
US
Adobe Pro 7.0 / .Net 2.0

Using vb.net PDF interfaces and GetJSObject when necessary I wrote a program that adds a background template, page numbers, and custom bookmarks for each page in any PDF.

The background template is a PDF created in Designer with a few textfields added at the top and bottom of the document that I can change at runtime in the program.

It was working great until I ran it against a PDF where I had manually inserted a few pages from another PDF.

For some reason the text fields that are normally horizontal flip to vertical and move to a strange almost center position on just those pages when the snippet of code below is run. It's baffling me because the text fields are horizontal on all the other pages. I can't see anything different in page size or layout on any of the pages but clearly something is different in how those other pages were created or it's a plain bug in the adobe software.

Anyone have any ideas/tips to resolve?

Dim template As Object

'Create a template from the inserted background document
template = PDDoc.GetJSObject.CreateTemplate("background", PDDoc.GetNumPages - 1)

'Place the template as a background to all pages
For i = 0 To PDDoc.GetNumPages - 2
template.Spawn(i, True, True, template)
Next
 
Never got a response to this, but I did figure out that Adobe does not allow dynamic PDFs (PDFs created in Designer) to be used as templates because of their XML structure. If you try to manually insert a dynamic PDF into a regular PDF you will get an access denied error.

It's an oddity that it can't be done manually but it can be done programmatically. I assume that it was just an oversight that Adobe allowed it to be done in code and my strange behavior noted above probably stems from inserting the dynamic PDF directly into the regular PDF. Can't say I really understand why, but there you have it. The solution therefore is to print the dynamic PDF to a static PDF and then insert it. That seems to have fixed the problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top