I have many PDF documents in binary format which is in the SQL Server 2008 database. I have a gridview in my ASP.net page. When a user clicks on any ID column of the record I need to open the pdf in the browser.
Are there any free PDF viewer controls out there? How can I convert the binary PDF file and display as PDF in the browser.
Thanks
Just return the data to the client with a Content-Type of application/pdf. The client will open it in Adobe Reader or whatever PDF viewer is installed.
If you want a consistent experience without wondering how the user's browser will choose to handle the file (i.e. display it inline, launch Acrobat, or try to save it, etc)...
Google has made its own web-based PDF viewer available for free for embedding. You might use the iframe version in your website.
(This is a sample I created using their web viewer. They make available zoom, thumbnail and page controls - enough to get around the documents easily)
You will have to make an ASP.NET page that delivers the PDF binary stream, then give Google's viewer the URL of that page.
To stream a PDF through an ASPX page you'll want to Google and search for articles like these :
http://support.microsoft.com/default.aspx?scid=kb;en-us;307603
http://support.microsoft.com/default.aspx?scid=kb;en-us;326502
etc.
Basically it's about HTTP and manipulating the MIME type, page headers, etc and writing binary data to the Response stream using available ASP.NET mechanisms.
It might be worthwhile to post a separate question specifically about streaming PDF data through an ASPX page because the current question can be construed as a two-part question or being more oriented toward PDF viewers.
When using modern Webbrowser (with HTML5 Canvas support) you can try PDFJS library (https://mozilla.github.io/pdf.js/)
Related
I have a PDF document storted as binary in the SQL Server database. I have rendered the binary document as PDF inside an iFrame using HTTP Handler.
Now, I want to allow the users to edit the data in the PDF file shown inside the iFrame and also populate some of the fields in the PDF automatically on clicking a button.
After all the fields are populated, the filled PDF document in the iFrame should be saved back as binary in the database.
How can this be implemented using ASP.NET 4.0?
I think you're looking for http://www.radpdf.com/
I have implemented this by adding HTTP Submit button inside the Adobe Acrobat (interactive) form. When the submit button is clicked, the PDF document will be posted to the server (an ASPX page). ASPX page will read the PDF document posted as stream, convert that into bytes and store in the database.
This is the difficult part of your question:
Now, I want to allow the users to edit the data in the PDF file shown inside the iFrame and also populate some of the fields in the PDF automatically on clicking a button.
You're going to need a third party tool that provides an API for filling form fields in a PDF. There are a few cheap ones and a few expensive ones. The only ones I've ever used successfully are
activePDF
Aspose
But there is also some open source projects:
iText ("iTextSharp") (example)
These tools can be used to fill in the fields of a PDF, as well as for other basic edits to PDFs, but things like editing text outside of form fields is very tough to do. There are entire software suites built around PDF authoring (think Adobe Acrobat). They should all provide ways to give you the new PDF (as a file, a byte array, a stream) so you can persist it back to the database.
You might have better luck allowing users to download and edit Word documents (or whatever equivalent you choose) and converting the end result into PDF. Aspose again could help with filling form fields in a document as well as the conversion from Doc to PDF.
I am not affiliated with Aspose in any way -- it just seems to be the tool of the trade for these sort of tasks.
The basic question is how can I click a button on a asp.net web page and it should show the download file box with open or save using Microsoft Word 2007?
I'm using OpenXML SDK v 2.0 and can, by clicking on a button, create (server-side) a docx document from a template, add in custom xml to populate Content controls and create a new Word docx document. However, my problem is then trying to send the document content in the http response object which will recognise the content as a Word 2007 document and, with the appropriate mime type, ask the user if they want to open the file with Word 2007 (which they have installed on their machine). No matter which option I try (about a dozen so far) I get either a 'Error parsing near 'PK ..' or an Error parsing near '
I've read just about all that seems to be online in the OpenXML Developer.org site, Eric White's blog, the MSDN articles, etc, etc but none seem to work when it comes to sending the document content to the client. I don't want to open the document in the browser, simply give the user the option to open the document (for further editing) in Word 2007.
I understand most of the Word 2007 file structure stuff and realise that the errors above relate to trying to parse the apparent zip file of docx or the xml (I have tried various permutations of Response.ContentType). It seems to me that the 'difficult' stuff of server-side document generation is done but the simple part of sending the content to the client is eluding me.
I hope someone who has managed to do this can help.
My company purchased ActivePDF WebGrabber a couple of years ago to convert a classic ASP created HTML page into a PDF form. The only drawback with the tool that we continually run into is that the outputted HTML links are not hot. Are there any tools that do include hot-links within the HTML to PDF output?
According to the ActivePDF FAQ for Does WebGrabber convert hyperlinks into usable links in the output PDF?, the answer is no. There is a phrase confusing me at the end of the answer:
"To implement links in the final PDF,
the application would search for links
prior to the Postscript generation,
and append them once the PDF has been
generated using Toolkit."
Does that mean this is how to achieve it, or is this their theoretical but not tested solution? If this is the solution, has anyone done this that might be able to post some sample (pseudo-)code?
Edit: I should mention that we're open to a different tool, and we need it to be accessible via classic ASP and ASP.NET. I would prefer a solution in which the links are automatically hot-linked during PDF generation.
Looks like you can do it with the activepdf toolkit after the pdf is generated. I think this is what they are referring to.
Use the AddHyperlink function on the resultant pdf
AddHyperlink instructs Toolkit to add
a hyperlink in the current output file
that connects to a specified URL.
When clicked, the URL opens in a new
browser window.
edit
It would be easier to get a tool that actually does this here are some links
Open Source HTML to PDF Renderer with Full CSS Support
https://stackoverflow.com/questions/3178448/list-of-html-to-pdf-converters
In the old days, activePDF Server was the engine behind activePDF WebGrabber. activePDF Server is a Print-to-PDF program (hence the reference to Postscript) so the links were not live.
Beginning with the WebGrabber 2009 release, the dependancy on Server was removed and WebGrabber will now (versions 2009 & 2010) output intelligent PDFs that include hot-links within the HTML to PDF output.
If you can call into a web service then try the PDF Conversion Services. We are currently looking for beta testers for the html to pdf bit, just drop a line via the contact page.
I know it is an old question, but nowadays it should be sufficient to use
converter.PreserveLinks = true;
Where converter is a WebGrabber instance.
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Directly convert .aspx to .pdf
Is there any way to generate PDF document from asp.net directly from the page output. My requirement is, when user visits a page on my website, there should be a provision to get the same page / report in PDF format. Using iTextSharp, we need to built layout logic agin to generate PDF. If there are any changes in page output in future, I again need to work on logic to generate PDF. Instead I want to generate PDF directly from the page output just by setting "Response.ContentType" property.
One strategy I use is to develop reports using SQL Server Reporting Services. SSRS reports support export to PDF out of the box.
If you use SSRS 2008, you can even assign arbitrary HTML to a text box and the reporting engine will interpret it fairly well. This allows you to retrieve a snippet of HTML from any page, and present it in a report that will export to PDF without having to manually generate PDF document elements with iTextSharp.
If you go the SSRS 2008 route, check out this thread: http://forums.asp.net/t/1443965.aspx
I hope this helps.
Happy Coding!
You can set a button on your page that, if clicked, starts rendering a HTML page to PDF - only that the page you're asking it to render is exactly the page the user has clicked the button on. Once you got the PDF you can just send it in the normal way.
This of course requires a program that can render arbitrary HTML pages to pdf. You might want to check out ABCpdf which has always worked for me like a charm, but it's not free.
http://princexml.com/
They offer an application that converts html to pdf.
We use ActivePDF WebGrabber - which is designed to do exactly what you described. http://www.activepdf.com/products/serverproducts/webgrabber/
I want to allow an Excel report to be viewed embedded in a WebPage... is there a way?
I don't want to use an ActiveX, or OWC (Office Web Components), I just want to open an existing file from the internet explorer application.
I don't want users to download and then open it.
Using an iframe wouldn't be a problem, but my preliminary tests weren't successful
Any ideas? Is it at all possible?
This has to do with the local person's browser set up and not really anything you can do on your end. If they click a link with the .xls(x) extension, the browser determines if it wants to open it itself or in a new window.
Here 2 microsoft pages on how to change these settings:
http://support.microsoft.com/.../how-to-configure-internet-explorer-to-open-office-documents-in-the-app
http://support.microsoft.com/.../embed-your-excel-workbook-on-your-web-page-or-blog-from-sharepoint-or-onedrive-for-business
You should try using the Excel Web App Embed feature that lets you embed tables and charts from Excel directly on your Web Page. You can even let users interact with the spreadsheet so that they can sort and filter data and use your spreadsheets formulas to calculate make their own calculations all without altering the source.
The Excel Web App and storage is all free from Microsoft. Any data you embed on your Web page can be viewed by all the major destkop and mobile browsers and when you update your spreadsheet the data on your web pages is automatically updated as well.
I think your best bet is going to be extracting the data out of the Excel file and displaying it in a regular HTML table. Excel isn't exactly safe to invoke from a web page and not everyone has it anyway.
Take a look at scribd iPaper Viewer - this is a Flash based Viewer of XLS (and other) docs.
MOSS 2007 has a nifty feature called Excel Services which might fit the bill...
Excel Web App allows embedding "live" interactive spreadsheets on a web page. For an example, see http://datawiz.wordpress.com/2011/01/10/how-to-embed-excel-on-a-web-page/
in your comments you say that the Excel file is on the client's filesystem, not on the webserver. i think the security model of sane browsers forbid this; but wouldn't be surprised if setting high permissions to your pages could allow this.
<iframe src="file:\\yourpath\yourfile.xls" width="100%" height="500"></iframe>
Well this is a bit crude but sort of fits the bill.
Select the area of the spreadsheet you wish to display.
Copy this area into MS Paint.
Select the area in Paint and use the Edit/Copy to/ function to save this as a bitmap.
Now load the bitmap as you would any other pic.