Can we download the form (created using ASP/HTML) in a pdf format. I am wondering how can this be achieved since i am trying to add this functionality in my web page. Please advise.
Download the Asp form in pdf format
Collapse
X
-
Tags: None
-
1) Take a screenshot of the form.
2) Convert that picture to PDF format.
3) Post the PDF file on your website for users to download. -
Thanks for the reply folk!!
Infact i tried this but the pdf gets openup in a new IE. But, once the hyperlink is clicked i want to see a new window opened with 2 options "OPEN" and "Save". how can i achieve this.? Please advise
Thanks for your knowledge!!
Regards
ChandhsekeComment
-
This is because IE has a plugin installed for reading PDF files. Most websites get around the problem by telling their users to "right click on the link and choose save target as...". Unfortunately I don't know of any way to simulate this effect using javascript. This problem is quite unique to PDFs and images, by the way, so a .doc format would perhaps work better.Comment
-
The above functionality does not work for the situations where if the form is in approval process and contains the values entered/picked from the database.
I need a functionality, when a button is pushed then the form should get saved in the pdf format with the values entered. In other words, the form should be saved in the same status when the button was pushed. Please help.
Any help would be greatly appreciated. Thanks in advance.
Regards,
ChandhsekeComment
-
What you want to do, if I understand you correctly, is modify a preset PDF file at runtime to include form text. Or generate a PDF file using a client side script? Both of these are bad ideas. Option 1 is near impossible because of the way PDF compression works. Option 2 would take FOREVER. Both options would not allow you to download the file, rather only display the file.Comment
-
Agree. Let me explain again what i am expecting from the team.
Lets say, i have a hyperlink placed on my webform "DownLoad in PDF" if i click on the link then a client side script should take a snap shot of the current form with values in a pdf format/file.
For Example: If the current window(bytes) has that option then upon clicking on it the current window with how muchever values we have entered should come up in a pdf file.
I am not looking for Option 1 but need option 2 with just display the file.
Please help,
Warm Regards,
ChandhsekeComment
-
Taking a snapshot of the screen is impossible. Taking a snapshot of the browser window is technically also impossible. The nearest you could get is to parse your own HTML code. This could be sped up somewhat because the only areas that you need to change are the areas inside the form.
BUT then changing this semi-predetermined image into a PDF file is the problem. Just to reiterate, until very recently only Adobe held the secret to encoding PDF files, and it's really quite complicated.
If you are totally awesome and can think of a faster way to use javascript to encode PDF files, when all the world's best computer scientists have been trying to optimize the approach for years, go ahead (and make it open source please) - the file format specification is at http://www.adobe.com/devnet/livecycl...iew_format.pdf ...
NOTE: The online tool Pdfvue can edit PDFs using a server side script. I'm not sure how they do it but it's not javascript, my guess is that it's an executable running off their server.Comment
-
Hi,
So you mean that, there is no functionality ever built by anyone to download the browser window or a webform in PDF format?
Regards,
ChandhsekeComment
-
a clientside script in a webpage couldn't create pdf-screenshots ... the nearest you could get is something like this ... which will create an image that you might upload (similar ActiveX-solutions might be available for IE) ... but that is just one specific and not really usable method ... you should follow the advice to do that serverside ...
kind regardsComment
-
In general, Javascript has no functionality whatsoever. Browsers support various add-on libraries collectively called DOM. They manipulate document objects, and any text within those objects. There is nothing else Javascript can do - you can't save a file to the server for downloading, you can't convert hypertext to PDF (at least not with any speed), and you can't properly capture a screen shot cause various browsers interpret CSS differently.Comment
-
that's just the half of the truth ... with JavaScript you can! create documents (html/xml/plain text for example) and submit that to the server via a XMLHttpRequest ... so you could create and upload a file to the server. this could even be used for a 'png-screenshot' that might be created with the example code shown above. Those solutions might not be cross-browser compatible or work in all browsers ... so often you might just use that in 'closed' environments like intranets ...
so the best way - as for the OPs problem would be to create the 'screenshot' serverside ... therefor the document in question might be parsed and 'PDFed' ... but even a screenshot would be possible ... i.e. when it would be a Linux-server, you could write a simple shell script that would open another x-session - start a browser with the URL and make a screenshot then ... which will create a png or whatever image ... this could now be 'PDFed' or whatever ...
The real potential of JavaScript could be easyly imagined when you have a look at Firefox ... which uses XUL for its UI. with that you could create apps that uses enhanced privileges and perform like 'desktop' applications and everything behind the scenes at clientside could be done with JavaScript.
But for Webapps that need to run in the public and in different browsers the possibilities are limited ... mainly for security reasons ... and then it is true that JavaScript should only be used to enhance the UI's (document's) user experience ...
kind regardsComment
-
"start a browser with the URL and make a screenshot"
I say bad idea if you want it to look like a proper screenshot. Particularly Linux has issues with rendering the same as, for instance, a client running under a Windows enviroment, let alone cross-browser problems. I still think it's easier to just render the HTML into a javascript array, particularly since the fonts will be known in advance. And the output would be better. But it might be slower (although you could pre-render most of the form). You could also provide status feedback.
PNG is also a silly format. Use bitmaps cause they're easy to manipulate (no compression).
PDFing is, I repeat, a slow process that should NEVER be attempted with javascript unless you are actually god. Even on intranets. Which really begs the question - why are we still discussing this? Sorry.
"with JavaScript you can! create documents" ... elaborate, please - I'm fascinated... can this be used to create a persistent database somehow? (I know that's off topic but I've never even thought of the concept...)Comment
-
Hi all,
IMHO this shouldn't be attempted with client-side code. There are stacks of HTML-to-PDF libraries for .NET and PHP that can do the job of taking a webpage (form data and all) and turning that into a dynamically-generated PDF for a user to download.
Google is your friend.
codegeckoComment
-
With regards to getting it downloaded as an attachment, you need to add a Content-Disposition:att achment;filenam e=MyPDF.pdf header to the response - this can be done server-side with PHP or ASP.NET.Comment
Comment