I'm looking at ways to embed PDF viewing in a Flex application.
Currently the only option I've seen is by using the flash.html.HTMLLoader class, which only works if you're using AIR. This isn't a big deal -- I'm willing to use AIR if I have to -- but based on my experimentation with viewing a PDF this way it appears that AIR simply integrates the embedded Adobe PDF browser Plug-in for viewing, which not only shows the PDF page(s), but provides all of the manipulation controls as well (zooming, printing, etc.) which I don't want to see.
I'm looking for something that works somewhat along the lines of the JPedal library for Java -- an embedded component that simply renders the PDF alone.
Has anyone found a way to do this with either AIR's built-in component or via some other method?
There are a couple of ways, but neither actually have the PDF in the Flex App:
Convert the PDF to SWF. Use this tool or one like it to convert the file over.
Use HTMLComponent, a method that uses an iframe over your flash/flex to make it appear like an external page is in your app. There are a few downsides to this method however - most of them described in detail at Deitte.com.
What you want is possible with AIR and described in this Adobe article:
http://www.adobe.com/devnet/air/flex/quickstart/scripting_pdf.html
Take a look at http://www.adobe.com/devnet/flex/quickstart/embedding_assets/ and see if it helps.
I don't think you can embed PDF files directly (but I'm not really sure) but if you totally need to do it and you don't want to open a new window you could convert the PDF to another format that can be inserted in your app.
If your goal is to simply display the PDF in the Flex environment then you could use the IFrame approach. You can find an example here http://www.deitte.com/archives/2006/08/finally_updated.htm
By using this approach you can load any HTML content which includes PDF's.
Take a look.
Okay guys here is the exact one we're looking
http://subinsugunan.blogspot.com/2009/06/embed-pdf-in-flex-application.html
Related
I have a website with the following structure:
Tab Container - having 4 Tab panels
Each tab panels is having 4 gridviews which are separated by line break.
Now when i am in a particular tab, I want to use an 'export to pdf' button , which should generate a pdf having 4 gridviews visible in this tabpanel. Same for all other tabpanels.
I have searched enough, found may articles telling about using itextsharp, wkhtmltopdf, pdf generators etc, however I dont seems to find fully implemented functionality anywhere.
Can anyone guide/suggest anything ?
I always use wkhtmltopdf to convert a html page to pdf. (you will need server access to install it though)
It works very well, looks the same as the web site and saves text as actual text (in vectors).
I've used CutePDF's API and they seem to work pretty well.
http://www.cutepdf.com/Solutions/
You can do this in two ways, either handle it on your server or use a third party service.
If you want to convert a html page to a PDF on your server, you can use wkhtmltopdf (A simple shell utility to convert html to pdf using the webkit rendering engine, and qt.) I haven't used it with .NET however have seen many examples.
If you like to use a third-party service www.impdf.com could be used, It's a free service. You do not need to register even. I once have used it but not for a long time( I later switched to wkhtmltopdf get some performance gain).
It depends on your requirements which method you must use. In any case if using impdf is enough for you,
Convert this page to a PDF
A4 page: impdf.com?url=http://www.yourwebsite.com&--page-size=A4
Letter page: impdf.com?url=http://www.yourwebsite.com&--page-size=Letter
Adobe ColdFusion has a tag called <CFPDF> built in.
http://help.adobe.com/en_US/ColdFusion/10.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7995.html
Furthermore it has web services which which can bridge the gap to ASP.Net
We're currently generating reports for our web application using html5 / css3, and they look good on screen, but obviously when the user hits print who knows what is going to come out of the printer. So, what I would like to know is what is the best way to convert these reports to PDF for download / printing while maintaining the same visual quality of the on screen reports.
Update 2010-10-26 16:01: We're using both .NET and Perl
The only think I can think of that might work is wkHTMLtoPDF. It's a QT app that sits on top of WebKit to generate its PDF.
The good news is that it even evaluates JS so just about anything goes.
The other good news is that QT is available across a wide selection of platforms. Whatever you might be using, chances are you can use QT.
Try Prince XML, the results are pretty to look at.
If you are using some of the new HTML5 elements like Canvas, then probably even the popular PDF converter wont help you.
I suggest you to put suitable print-friendly version of your CSS. This could be achieved by using media="print" attribute in the <link rel="stylesheet"... tag of a separate CSS file, which is containing the definitions for print version.
Some options (all proprietary):
Aspose.Pdf for .NET: Expensive, very good though.
Winnovative HTML to PDF Converter: I've already use their tool, gets the job done.
ExpertPDF: Another good one.
For open-source alternatives, please see here:
Open Source HTML to PDF Renderer with Full CSS Support
ExpertPdf (www.html-to-pdf.net) supports html5 / css3.
You can try the online demo here:
http://www.html-to-pdf.net/free-online-pdf-converter.aspx
There is a node module html5-to-pdf that works pretty well.
Is free and open source.
It runs on Electron. There are some bugs (for example anchor tags render the hyperlink as well) - but it might be an easy fix.
I am using asp.net 2.0 with c#.
I have to convert my label text into pdf. For this I have used this tutorial
http://www.codeproject.com/KB/aspnet/Creating_PDF_documents_in.aspx
now I am facing two problems:
Every time it is creating 1.pdf, what if there are so many user wants to see the the pdf format of any page
As my label text contains HTML content, it is showing a HTMl output. I don't want HTML to be display in the pdf.
please let me know if you have any other way to create a pdf.
Thanks in advance.
Creating a PDF with HTML-formatted content is not entirely trivial, and the CodeProject sample code isn't quite suitable for that. You'll most likely want to look into a (commercial) third-party solution for this: I myself use Siberix Report Writer: it's flexible, quite affordable, works in partial-trust scenarios (nice for shared web hosting environments) and most importantly doesn't require a per-server license, so you can embed it in your product without redistribution issues.
Item 1) You cache your pdf files to disk. When a request is made for a pdf check if the pdf has been created (i.e. there is a file on disk) and if not generate it. Then send the pdf using the response.writefile command
Item 2) If you are trying to print formatted html into pdf then you will need something that is capable of rendering html. There are a number of html to pdf converters however I have not found them to be all that good. If you are comfortable with php then there are some pretty good converters you can use. Joomla supports html to pdf, so whilst it may not be the exact solution it maybe a good starting point.
I would also suggest you take a look at Aspose PDF.
I would suggest using RDLC Report or Crystal Reports as suggested by #Jeroen
Cete Pdf Generator has HtmlTextArea element and supports some limited HTML
http://www.cete.com/support/net_help_library/html/ceTeDynamicPDFPageElementsHtmlTextArea.htm
ABCpdf is another commercial component which converts html to pdf.
http://www.websupergoo.com/abcpdf-5.htm
You could try the itextsharp library. I've not used it but it has been highly commended by other developers I know. http://sourceforge.net/projects/itextsharp/
In regards to the caching issue. I would check the file system for a pdf named via a convention. If the file is found then serve it. Otherwise, call another method which generates the pdf and saves it to the drive. This way only the first ever request will cause the generation of the pdf. Naming conventions will be key here. The basic implementation wont be thread safe. But it's a good start.
I use CrystalReports. It can create a PDF on the fly and output it to disk or http directly.
Does anyone think it is possible to build a Google Docs style PDF document viewer, which will convert a document to a format that doesn't require Adobe Reader on the client machine?
If so, any references to point to? Either a place that had done it, or an explanation of how to do it.
I've done a lot of research regarding this matter and I hope I can help.
Good old Macromedia used to market Flash Paper, which was supposed to be a PDF Adobe Reader killer as it allowed any webmaster to embed and display PDF docs online using Flash. But that was before they sold out to Adobe and Flash Paper was soon put on a shelf and forgotten in favor of Adobe's priorities.
However, Today there are a so many ground-breaking alternatives...
As a user has mentioned above you can use Scribd.com (the wanna-be YouTube for documents). But they're not the only service (and certainly not the ones most ahead of the curve).
Here are my two favorites:
Issuu (http://www.issuu.com)
Mygazines (http://www.mygazines.com/)
I enjoy Mygazines's flash user interface the most (it's also faster) but it costs $99. It's pretty impressive. Depending on what you want to do that price tag can be worth it.
Issuu however, has won me over recently with their Smartlook Platform: http://issuu.com/smartlook
Here's a sample of Smartlook setup on a website:
http://www.ismartlook.com/
Plus it's completely free, which is nice.
A third alternative, which I've considered using myself is this free and open source code made by this guy named samurajdata. He calls it psview (PostScript Viewer). Anyone can download the source code and see it in action here:
http://view.samurajdata.se/
The converted PDFs losses quality as it converts to image fie, but it's fast and easy to setup.
I hope this helps!
You may try Doconut.com looks pretty same as Google Docs viewer. It is available for asp.net 4.0, apart from PDF it can also show all office formats, tiff, dwg, psd etc.. However it is a paid library.
If I understand you correctly you only want to view these files and not edit them.
Google already makes a best effort at providing PDF files found in it's search results as HTML. This doesn't always work. You can try it out by setting up a gmail account, mailing all your PDF files to it, and then using all the "View attachment as HTML" links in the messages.
Your other options are to take the source material and make it into HTML as say LaTeX2HTML does for LaTeX documents, or to convert the PDF into one of: a raster image (tiff, DjVu, etc), or a vector image (PostScript, SVG, SWF).
If the input to this process starts with the PDF files, you have very limited options, especially if the contents of the PDFs are just raster images (say scanned pages).
Personally I'd advocate for creating the PDFs from their source and trying to use Flash Paper to create an SWF out of them too as Flash Paper will pretend to be a printer. Because some 98% of browsers have Flash 9 or greater.
Have you seen Scribd?
You can just use the Google Docs Viewer which also supports PDF documents. It allows you to embed it in your web page and point to the URL where the PDF is located (which doesn't have to be on the Google servers).
Example:
http://docs.google.com/viewer?embedded=true&url=http%3A%2F%2Fwww.domain.com%2Fdocument.pdf
There is the Internet Archive BookReader available. It's a nice book viewer implemented in javascript (jQuery), so the client doesn't need a PDF reader nor Flash. Though it needs images for the book pages, you can easily connect it to your own image server, so you may try to convert a PDF to images via ASP.NET (or any other tool like XPDF). I found that this is simpler to implement than actually implementing an images viewer.
Also, it seems to support search highlighting (try it here), but I haven't investigated exactly which metadata are needed and in what format.
The last release file contains a simple example on how to use it. More details and examples can be found in the first link.
Try converting them from PDF to TIFF. Tiff supports multiple pages and is widely supported.
If formatting isn't that important, and your PDFs are structured right (ie actually contain text, not images of text), an alternate could be to convert to HTML. The tools from Aspose are pretty good.
I'm wondering why you would want to do that. PDF is such a general and widely supported format that if you try to avoid it you're limited to:
A more obscure or less well supported format (dvi, svg until it gets better support)
Converting to text/HTML like Google does with less than perfect results
Converting to an image format like TIFF which bumps up file sizes and removes all the niceties of PDF like real, selectable text and hyperlinks
If you don't want your users to have to install Adobe Reader (understandable), there are many free lightweight PDF viewers available (Foxit Reader for example), I'm sure many of these have browser embedding capabilities.
Am I missing something here? Google Docs DOES support PDF. Simply upload the PDF file.
Some other alternatives depending upon what you're looking to do:
RAD PDF - ASP.NET component for displaying PDF documents, forms, etc. Also allows PDF searching, bookmarks, text selection, and basic editing.
Atalasoft - ASP.NET component for image viewing, but also allows PDF use as an image. Doesn't support any PDF features beyond simple viewing.
Looking for a way to display a PDF in Flex. I'm sure there are several ways. Looking for the easiest to maintain / integrate / most user friendly. I'm guessing it's possible to display a browser window in the app and render it, but if it goes off of IE / FireFox it's not acceptable for this project.
Thanks...
This looks like a nice PDF viewer for flex http://www.devaldi.com/?p=212
We just did a large AIR app that used PDF quite a bit - make sure you save yourself some heartache and write some code to check the acrobat version or that it's even installed - if they don't have it you won't get an error, just a blank HTML control.
I know, it sounds obvious, but still...
Sorry to say so, but convertion PDF to kind of swf of flash things... doesn't that kill the PDF thoughts ?
I mean, PDF should be electronic paper right ? When creating a SWF file out of it, you just destroy that. No more editing, no more filling out a form.
The strange thing is, that PDF is an Adobe product... and Flex (Flash Builder) is a Adobe product.
Two products that Adobe wants to be world dominator off. But combining PDF into Flex... is not standard.
Check out: http://www.swftools.org/ for tools to convert your PDF to SWF, speifically pdf2swf- http://www.swftools.org/pdf2swf.html
Check out Share on Acrobat.com, there you can upload PDFs and make them embedable Flash files (sort of like YouTube for documents). Should be possible to load those into Flex. Not an ideal solution, but unfortunately you need to convert the PDF to an SWF somehow to be able to load it into a Flex application. I don't know of any good tools that do this. If someone else knows please share.
If you target AIR you can load a PDF into a HTML view, but that doesn't work when running in the browser (the HTML component is only available in AIR).
in Adobe Digital Edition, Adobe Load PDFs into flash (if you check the main file .exe you can see it), without any convert. therefore i think it is possible to do.
i decompiled it and found lot of classes related to pdf but i can't run it after recompiled it :(
if you solve this problem you should focus the Adobe Digital Edition product.
Oh sweet, this is an air app. I'll go with the HTML view. I can't convert them to SWF because the client will be uploading the files.
if AIR Application,
use HTMLLoader().