These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Creating PDF's on the fly

scarface
Registered: Jan 8 2010
Posts: 4

I have developed a website that needs to create a number of reports in PDF format using data produced in PHP. I also need to create debit and credit notes based in PDF based on information calculated by the website.

I have tried a method of developing templates in QuarkXpress, exporting as PDF, with data tags in the positions where that I want populated by data from the website i.e. data_account_no where I need the account number to be.

This has worked to a point, but is very unstable. Letters are omitted, numbers are missing etc.

Is there another way of doing this??

Thanks in advance

My Product Information:
Acrobat Pro 6.0, Unix/Linux
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
There are PDF libraries for PHP. Some of them are open source and free.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

stavola
Registered: Feb 18 2010
Posts: 3
Hi,

I'm looking for a solution to my problem here. Situation is something like this.

I've a remote server, where i do an ajax call to that server by sending xml request and as a response i get a pdf file. Now this pdf file is a binary data that is held in responseText property of ajax object. How can i render this binary pdf data into the iframe(a section of my layout screen)? Any help is greatly appreciated and thanks in advance.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Save the PDF data to a ".pdf" file on a local server folder. Then place an Object tag in the iFrame that points to the saved file using the "src" property. Also set the classid property: classid="clsid:CA8A9780-280D-11CF-A24D-444553540000".

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

stavola
Registered: Feb 18 2010
Posts: 3
Thanks thomp for the response. We thought of this solution, however, that application we developed is a test tool which is a thin client fully developed using jQuery. Basically we need to test the REST API's on a remote server. So, we send ajax request and expect a response which is a pdf file. So, i was wondering how can i render the pdf binary data directly. For example, if i receive an image as bin data, i can set the src of img tag to that bin data using javascript. is there anyway to do like that.

And how can i save the binary data to a pdf file, which i received via ajax responseText property (where browser doesn't prompt to save the file.) . By the way, my thin client is html application (hta).
I was thinking, instead of writing the files to disk and making the iframe point to this file so that it can render, is there any other way we can do this. As the data i get is binary pdf

Thanks once again for your prompt response. I really appreciate it.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
I'm not a web programmer, so I don't really know the details of the environment you're working in. However, if you can point the src property of an img tag to the binary data, then you aught to be able to point the src property of an object tag to the PDF data using the same technique.

The important bit is that PDF is rendered by Acrobat/Reader. So you have to do two things, Get the browser to load Acrobat into the iFrame and get you're PDF data into Acrobat. The object tag's classid property will get acrobat to open in the iFrame. But the only way I know how to feed it the PDF data is with a file reference. It seems like you already that this part of the problem worked out for images. Try the same thing with the PDF data.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script