Generate a PDF view with data for printing - asp.net

I'm currently working on a project that requires me to generate a printable report. I'm using a PDF reporting I found in code project, you can click here: PDF Reporting to get a better view.
The thing is that the report that I need to produce already has a form that needs to be followed that can be found here: FORM. I was planning on placing the form as a background image through CSS3, place the necessary data over the image and throw it to the PDF reporting controller. Problem is that when the pdf view has been generated, the background image is missing. Is it possible to actually pass an image to this PDF reporting? I already tried placing an img tag as mentioned in the site but it didn't work.
Is this a good solution or is it better if we recreate the form from scratch. If you have other approach to this problem, I'd be glad to hear your suggestions.
Oh and by the way, we are using mvc3, razor view.
Update: We are also using entity frame work and asp.net 4.1
Thanks in advance!

I would suggest you to think about Microsoft Report Viewer.
You have a proper designer, very easy to use, and you can generate PDF files as well.
You can find a good tutorial here.
In your situation it would be better to map each field of the report as a parameter so you do not have to create a dataset.

Related

Convert webpage from HTML to PDF?

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

Why should I choose Crystal Report or SSRS over plain HTML table?

I am using ASP.NET MVC. Sometimes I work with ASP.NET Web Forms too. I can pretty much create my queries using stored procs or LINQ and render my report just using a plain HTML table. With proper styling it should come out decent.
I don't know SSRS but I have some experience working with crystal from before. The only advantage I see from using crystal for my reports against just a simple HTML table is that it can export to PDF. But I could probably get some third-party library that can do that too. Regarding charts like pie and bar graphs there are a lot of javascript tools available out there that does that and they're free.
I guess I'm posting this to see what I'm missing with reporting tools like Crystal and SSRS.
EDIT: With ASP.NET MVC it is not particularly difficult to create the report. Just formulate the correct model, create the controller action and view with scaffolding (Detail) and you will have the code generated for you right away. With ASP.NET Web Forms it is probably easier, just use a GridView and you're done. For both cases all that is left is the CSS. With Crystal you also need to edit the layout you have generated the report, which is work still as well.
The reason we use SSRS for our internal reports is that our database guy can create reports without having any knowledge of how to format output using code.
your points are valid and I have been thinking about such things multiple times.
Personally I used CR in the past and SSRS more recently, but my absolutely best experience was with DevXpress XtraReports, super cool design and royalty free end user designer with or without Ribboned interface.
the difference between using a report engine or plain raw HTML is in the way you design the reports and the overall features.
in XtraReports for example, the lovely thing is that a report is simply a .cs file (C# class) and whatever you design with the UI designer is stored in that file exactly like the windows forms designer does ( or ASP.NET aspx and aspx.cs designer does ). So you see the report you are designing and you Drag & Drop controls and place them where needed. Then you have out of the box formulas, running totals, page breaks, as you mentioned export to pdf, excel, jpg, html, word and so much more.
if I was free to choice again I would go again for XtraReport and forget about plain and raw html table coding, let's focus on the real business of the application we write and not get nuts with page breaks, exporting things and in house implemented formulas or group/running totals... this is my idea and approach at least.
The biggest reason for me to use a reporting engine is for printing and page breaks. You can't always guarantee the way the HTML will format for all the various browsers and it's not great for setting hard page breaks. With a reporting solution, you can group things together to force page breaks to be more predictable.
This is especially important if you're looking for a more professional looking report.
as already stated above using another report generator can have much benefits. I've used very often List & Label. There is a completely different concept behind and depending on your needs it will be easier but still powerfull, especially for .NET reporting. It is worth to do a trial (there is even a free edition available).

Create pdf document in asp.net 2.0

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.

Convert my aspx page to png image

I am generating an aspx page which then I need to convert to png and store it somewhere.
A similiar situation with mine was asked before here but got still no response. I tried also the code that the Swapnil Fegade has asked but the code is looping continually making request to loading page and no conversion is actually being done.
I found some solutions on the web also but they require WebBrowser control which i understood can be used in windows form but i am building a web project.
Can you give me any hint or suggest any article that shows a full example doing this task.
Thank you guys in advance.
This one seems to do what you want:
http://www.codeproject.com/KB/IP/htmlimagecapture.aspx

Is there another way to integrate PDF viewing in a Flex application?

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

Resources