473,387 Members | 1,344 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Download the Asp form in pdf format

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.
Feb 11 '10 #1
18 2731
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.
Feb 11 '10 #2
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
Chandhseke
Feb 12 '10 #3
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.
Feb 12 '10 #4
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,
Chandhseke
Feb 19 '10 #5
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.
Feb 20 '10 #6
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,
Chandhseke
Feb 22 '10 #7
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.
Feb 23 '10 #8
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,
Chandhseke
Feb 23 '10 #9
gits
5,390 Expert Mod 4TB
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 regards
Feb 23 '10 #10
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.
Feb 24 '10 #11
gits
5,390 Expert Mod 4TB
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 regards
Feb 24 '10 #12
"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...)
Feb 24 '10 #13
JamieHowarth0
533 Expert 512MB
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.

codegecko
Feb 24 '10 #14
JamieHowarth0
533 Expert 512MB
With regards to getting it downloaded as an attachment, you need to add a Content-Disposition:attachment;filename=MyPDF.pdf header to the response - this can be done server-side with PHP or ASP.NET.
Feb 24 '10 #15
Sorry - I didn't see a single dynamic HTML to PDF converter there. I only saw static ones that, while converting form data, would not convert current form input. Most of them rely on the script loading the page dynamically over HTTP, which invalidates form input. Or running through a loaded "source" and rendering each element - also not sufficient as it doesn't ever touch the values of the current page.
Feb 24 '10 #16
gits
5,390 Expert Mod 4TB
"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.
the OP has the problem to have a screenshot for HIS/HER page ... so he KNOWS how the page should render ... so it just needs to be a target browser that would render HIS/HER page properly ... so the crossbrowser argument is just no argument in that case ...

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.
whatfor should that be good? what should a JavaScript array do here? even an array wouldn't provide any sufficient structure for a document-tree ... while a JSON structure (basicly a string representation of a JavaScript Object) would be ... that object could be transfered to the server to use it as a base for 'PDFing'

PNG is also a silly format. Use bitmaps cause they're easy to manipulate (no compression).
when you ever have read the above linked 'canvas-screenshot'-EXAMPLE which shows ONE way to achieve something what the OP wants ... you might guess with your neverending wisdom that it seems quite tricky for a browser to create images that are not really 'webaware' what a bmp wouldn't be?

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.
nobody is discussing 'PDFing' at the client ... like these words: 'which will create an image that you might upload' ... might show?

"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...)
what about creating elements - so you could create entire xml-docs that just needs to be transfered to the server via a request ... the document IS created in memory of course ... but it is present ... you could add it to a new window or whatever ... when it is sent to the server in that current state ... this could be saved there and thus the document is then persistent THERE.

just to say that i'm quite disappointed by such ignorance and plain thinking only in ONE way i'm out of this discussion here ... certainly i don't know of what i speak ... and i bow low to such straight wisdom ...
Feb 24 '10 #17
jkmyoung
2,057 Expert 2GB
Confused as to the way this thread went.

Bad solution: there are commercial applications which allow you to flash/watermark images onto an existing pdf. You could dynamically create the images based on the user input and flash them accordingly.

Better(?) Clicking a button submits the form to the server. Based on the user response, the server generates an xml file, with the user data, which is merged with the form with xslt & xsl-fo giving pdf.
Need to find/configure the correct xsl-fo converter to work with your app
Need to be able to convert the form into the correct base xml.

There's probably better ways not using xslt, but that's what I know.
====
edit:
On the off chance we're looking for something silly like this:
Paste the screen shot into a word doc.
Use a word-pdf converter online, or buy the commercial version.
Feb 24 '10 #18
I do apologize for still trying to think in purely javascript terms. It just occurred to me that another easy way would be regenerating a new page with the initial values of the form set to the current values of the form and then sending this HTML code to a server-side script which processes it into a PDF. Again sorry for my over-complication.
Feb 24 '10 #19

Sign in to post your reply or Sign up for a free account.

Similar topics

13
by: dan roberts | last post by:
Folks, This is my first Python project so please bear with me. I need to download data from Yahoo Finance in CSV format. The symbols are provided in a text file, and the project details are...
6
by: Don Grover | last post by:
How can I force a download of a csv file by user clicking on hyperlink. Don
1
by: com | last post by:
Extreme Web Reports 2005 - Soft30.com The wizard scans the specified MS Access database and records information such as report names, parameters and subqueries. ......
3
by: Gary O'Malley | last post by:
Everytime I download a file from the web I get a nice animated dialogue box that shows the size of the file, how much has been received and the approximate remaining time. It also gives the...
8
by: Doominato | last post by:
good day, I was just wondering how can I download a web page as plain text from a certain web site. I have tried to use the OpenURL() method from INET control in my VB.NET app, but it returns...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
2
by: nandishp | last post by:
We need to automate download of Reports from Oracle CRM OnDemand. The reports in Siebel CRM OnDemand can be downloaded in the form of Excel, CSV, etc. We have a task of downloading several such...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
4
by: chandhseke | last post by:
Hi Folks, Can someone help me in achieving one of my requirement to complete my project. The requirement is : I need to introduce a functionality to download the current form that i am using...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.