Hey all,

I am trying to create a site that produces a PDF or something similar based upon user input through radio buttons. For example say there are three categories A, B, and C. Each category has two options, 1 and 2. So a diagram with option A = 1, B = 2, and C = 1 would generate the number 121, which would then pull 121.pdf -- making it available for download.

Is javascript the way to go with this? I have basic programming abilities with some HTML experience, but I know there are many different languages and options available. Maybe there is one that would make more sense to use? Any direction would be very helpful!

Thanks!

Do the pdfs already exist or are they actually going to dynamically generated?

Do the pdfs already exist or are they actually going to dynamically generated?

Only about 100 exist at the moment. The PDFs are actually diagrams with several options which result in thousands of combinations. I did not know that creating PDFs dynamically would be feasible so this is definitely something I am going to explore. Originally we were going to use a Visual Basic script to generate the files then just reference them.

If I get break up the options into individual images should I be able to suppress/unsuppress and position them to create the diagram on the fly?

I'm completely new to php. I think I will be able to get my way through it, but the first hurdle is just getting a basic script to run. Our host is based for ASP which I know is similar but not interchangeable. After uploading a php file to the server it sort of worked but displayed a bunch of random text below and above the expected output.

Ya you are definitely going to want to generate these on the fly, that is unless you want to create thousands of pdfs manually.

Run this on your server to see if pdflib is installed.

if(!extension_loaded("pdf"))
{
	echo "pdflib is not installed";
}

You will want this installed since it is the most popular and the most documented pdf extension. I have heard that there are other extensions you can use instead, but this is by far the most widely used.

You will want this installed since it is the most popular and the most documented pdf extension. I have heard that there are other extensions you can use instead, but this is by far the most widely used.

Ran the code and apparently "pdflib is not installed." :(

Do I need a new host or is there a way for me to install it?

> Is javascript the way to go with this?

No, AFAIK it can't be done in Javascript irrespective of whether the PDF's are pre-generated / generated on fly. The way to do it would be process the user input at the server and set the response headers accordingly when the response is thrown out.

A little update on my progress and a little more information on the project:

I tried using FPDF to create the diagrams on the fly. It worked pretty much as expected but the quality of the PDF is only as good as the PNG files that are used, which turns out to be a big problem. The final product will have to be printed and pretty versatile to different print sizes. What I got to work had to be printed on an 8.5x11 sheet and not even scaled down to fit the page. Any resizing would make the print quality very poor.

The original file format for these diagrams is DWG, which is an AutoCAD format. It is possible to export to a PDF directly from DWG which yields a high quality PDF that can be printed on any size sheet. Since I do not think there is a way to manipulate PDFs as far as layering goes (similar to what FPDF does) I think I will have to go back to original idea of having all the PDFs already generated. Through the use of Visual Basic, I think I'll be able to automate the generation of files. Then I'm planning to still use PHP to control the form and put together the string that will reference the PDF filename. Am I on the right track or am I missing something? Just wanted to throw this out there before spending time putting this all together.

It entirely hinges on what exactly 'generated on fly' means. If it means that depending on each request the format / content of the report might change, then you would be in a big pinch if you statically generate files and keep them on your server. Depending on the number of users / hits, you might easily run out of space!

The important thing here is identifying the lower and upper bounds of the number of reports you can have. If by analyzing the problem domain, you feel that there is as such no upper bound, then you can't use statically generated PDF's as they won't scale to the requirements. AFAIK, PDF files normally use vector fonts so the quality would not have been an issue if it were not for the PNG files used to generate the PDF's (in the end, you are just embedding the image inside PDF). Normally for such things, a Reporting Engine is used (something like Crystal Reports) which can be hooked to a stored procedure to pull out data.

Maybe you should look out for some reporting tool which allows you to import Autocad files so that your task of automatic PDF generation can be simplified to a great extent. Then again, not much can be said without answering the questions posed above or before understanding the exact requirements.

Format will not change, but specific "blocks" or layers of content will.

I found a perfect example. I need something like this: http://wiring.rotork.com/wiringdiagram/survey/form/

It seems like they already have their PDFs created and stored on the server.

That is my belief too, that PDFs are vectors and therefore going from AutoCAD to PDF will yield a perfect result. FPDF does not support any format remotely suitable other than PNG/JPG which, like you said, dramatically reduces quality.

Also, in AutoCAD we already have a VB interface that allows us to turn on/off layers. Basically acts exactly like that website above, but in a VB/AutoCAD environment. So my thought was that I could throw that whole process in a loop to output the different combinations to a file. Then use basic PHP to create the filename and pull up the already created PDF. Hopefully, that clarifies the problem a bit. I do not think server space will be an issue. If possible, just some information about the site above would be greatly appreciated.

> If possible, just some information about the site above would be greatly appreciated.

Finding out what happens behind the scenes is kind of difficult. In your case if quality is of prime importance, generating PDF's out of images is out of the picture. Another option as I mentioned in my previous post is to look for some reporting tool which accepts Autocad files and converts it into native format. But this is more work than it is worth considering that the number of combinations is well known to you.

So IMO, the best option in your case would be to use the VB/Autocad environment to generate the fixed number of PDF's with the file name depending on the input / combination used.

Sounds like we are on the same page. Thank you for your help. I've already gotten PHP to handle my form to generate the string for the filename. I also found a script that can take that and download the respective file off the server. Now I just need to make it a bit more robust and figure out VB to generate all the PDFs.

Thanks again!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.