Category Archives: ReportViewer

[RESOLVED] webpage to Pdf without third party tools

HI Everybody...

I am working on a website in which I am  sending a Quotation to customers through email as an attachment.

quotation format on webpage are following below.

1.Company logo

2.to and from address

3.Datagrid with product Info and prices.

once he click on submit button on that page  it will send email as pdf to customer.

Q. 1. Is it Possible to Convert web page to pdf and attaching to the Email and sedning? with out using third party tools?

 I googled it   but none of them are clear.

can any one give me clear Idea how to do it?

THanks in advance.



The only way I know of that you can generate a PDF without using a "third party" library is to use Sql Server Reporting Services: http://iraza.net/blog/post/Generate-PDF-using-SSRS.aspx




<div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">Hi jibarra,</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">

</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">You might need to convert rendred html of the div in to a pdf file and attach it.</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">Converting html to pdf following are the avilable methods</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">Reference: http://forums.asp.net/p/1143759/1849142.aspx</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">Solution 1: Use an open-source .NET PDF library. Sample list:</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">ASP.NET FO PDF at SourceForge.net - generates XSL-FO from DataTable to render PDF</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">iTextSharp at SourceForge.net</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">Examples and Tutorial: http://itextsharp.sourceforge.net/</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">Also see this article: Create PDF on the fly with .NET and iTextSharp by Valerio Fornito, DoPostBack.com</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">PDFCreator at GotDotNet - design PDF document visually using Visual Studio IDE</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">Report.NET at SourceForge.net</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">Solution 2: Use a commercial .NET PDF library. Sample list:</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">ABCpdf .NET by WebSupergoo - free license also available</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">Syncfusion PDF – by Syncfusion</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">Apoc XSL-FO by Chive Software - generates PDF using XSL-FO</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">Aspose.Pdf by Aspose</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">DynamicPDF by ceTe Software</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">PDF4NET by O2 Solutions</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">PDFLib by PDFLib GmbH</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">TallPDF.NET by TallComponents - able to create PDF documents either programmatically using an object model or from XML.</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">Tutorial: Create and manipulate PDF documents - 100% .NET by Frank Rem (CodeProject.com)</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">XMLPDF by Visual Programming - converts XML to PDF</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">Solution 3: Use activePDF WebGrabber to convert any URL output to PDF on-the-fly.</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">Solution 4: Use a report generator like Crystal Reports or SQL Server Reporting Services to render to PDF.</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">How to Create PDF from ASP.NET pages by Edward Tanquay (DeveloperFusion.com) - using Crystal Reports</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">Crystal Reports: Add Professional Quality Reports to Your Application with Visual Studio .NET by Andrew Burst (MSDN Magazine)</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">
</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">Please check the following link:</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">http://forums.asp.net/t/1595839.aspx</div>

Hi jibarra,


You might need to convert rendred html of the div in to a pdf file and attach it.

Converting html to pdf following are the avilable methods

Reference: http://forums.asp.net/p/1143759/1849142.aspx

Solution 1: Use an open-source .NET PDF library. Sample list:

ASP.NET FO PDF at SourceForge.net - generates XSL-FO from DataTable to render PDF

iTextSharp at SourceForge.net

Examples and Tutorial: http://itextsharp.sourceforge.net/

Also see this article: Create PDF on the fly with .NET and iTextSharp by Valerio Fornito, DoPostBack.com

PDFCreator at GotDotNet - design PDF document visually using Visual Studio IDE

Report.NET at SourceForge.net

Solution 2: Use a commercial .NET PDF library. Sample list:

ABCpdf .NET by WebSupergoo - free license also available

Syncfusion PDF – by Syncfusion

Apoc XSL-FO by Chive Software - generates PDF using XSL-FO

Aspose.Pdf by Aspose

DynamicPDF by ceTe Software

PDF4NET by O2 Solutions

PDFLib by PDFLib GmbH

TallPDF.NET by TallComponents - able to create PDF documents either programmatically using an object model or from XML.

Tutorial: Create and manipulate PDF documents - 100% .NET by Frank Rem (CodeProject.com)

XMLPDF by Visual Programming - converts XML to PDF

Solution 3: Use activePDF WebGrabber to convert any URL output to PDF on-the-fly.

Solution 4: Use a report generator like Crystal Reports or SQL Server Reporting Services to render to PDF.

How to Create PDF from ASP.NET pages by Edward Tanquay (DeveloperFusion.com) - using Crystal Reports

Crystal Reports: Add Professional Quality Reports to Your Application with Visual Studio .NET by Andrew Burst (MSDN Magazine)

Please check the following link:

http://forums.asp.net/t/1595839.aspx

Hi Friends,

Try this, it is very interesting,

 

http://www.phdesign.com.au/programming/create-a-pdf-using-the-net-reportviewer-control/

 

thanks,

vendan

[RESOLVED] Accessing master page or content page from normal webform

Hi, all, as iam new to this forum as well as new to asp.net, i want to know how to access a session[""] that is in a master page or content page. Iam developing a web application and there , i have one master page, several content pages, normal webforms also thats the default asp pages which not linked to master page. I want to know how to access a session variable thats in a master page or content page from normal webforms.

 

this is  peace of my coding ,

[code]

using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

using CrystalDecisions.CrystalReports.Engine;//
using CrystalDecisions.Shared;//


public partial class Default2 : System.Web.UI.Page
{
    public string connection = System.Configuration.ConfigurationManager.ConnectionStrings["AmanaConnection"].ConnectionString;
   
    protected void Page_Load(object sender, EventArgs e)
    {
        Transaction rtp =(Transaction)Session["TransactionView"];
               
        CrystalReportViewer1.ReportSource = LoadTransactionReport(rtp.userName,rtp.date1,rtp.date2,rtp.accountNo,connection);
        CrystalReportViewer1.DataBind();
       
    }

[/code]

 

 

 

 

could you clarify what you mean by "access a session variable thats in a master page or content page from normal webforms."

Session variables are stored on the server and are accesible throughout the entire application.

"Export"-formatting in ReportViewer

I am using the ReportViewer to display a remote report deployed on a Reporting Server. When viewing the report through the browser I get a dropdownlist with options next to a "Export"-link but on my ASP.NET page with the ReportViewer I get a clickable icon with the export options. My question is how to display the link and dropdownlist in the ReportViewer control instead of the icon?

Can u please provide a screen shot of what you need.. ie what exactly u need to appear on the screen!?

How to upload an image..? I want to customize the look of the out-of-the-box export button, which looks like some kind of "Save"-icon with no text next to it.

Anyone??

[RESOLVED] How to Print Directly a .pdf file from MemoryStream

Hi,

I am using Visual Studio 2008 and developing ASP.Net Website.

Now, on one of my WEBFORM, on click of an icon, I am generating pdf file from crystal report and showing Open/Save option.

Everything is working fine.

Now, rather than displaying that open/save option, I need to send this pdf file straight to user's Printer or have to display printer options same when we give print command ( where it displays all the printers and setup before printing )

I have this pdf file stored in MemoryStream like this.

========================================================================================

 

using System.IO;

MemoryStream objStream_PDF_Main_File_Attachment = new MemoryStream();

 string pdfFileName = "MYFILE.pdf" ;

//HERE I STORE GENERATED .PDF FILE INTO MEMORYSTREAM
// objStream_PDF_Main_File_Attachment = (MemoryStream)theReport.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);


Response.Clear();
pdfFileName = pdfFileName.Replace(" ", "%20");
                    Response.AddHeader("Content-Disposition", "attachment; filename=\"" + pdfFileName + "\"");
                    Response.AddHeader("Content-Length", objStream_PDF_Main_File_Attachment.Length.ToString());
                    Response.ContentType = "application/pdf";
                    Response.BinaryWrite(objStream_PDF_Main_File_Attachment.ToArray());
                    Response.End();

========================================================================================

And it is showing file's open/save dialog properly.

Now, rather than that, I need to send this pdf file from memorystream directly to the user's printer.

So I am looking for two things.

1. How can I send this pdf file to the printer from memorystream?

2. If I want to display that printer options (which it shows when we give print command ), How do I display that before printing so that user can set his preferences before printing as per his printer and also, in that case, what happen if use cancels printing from that printer's dialog box?

Thanks in advance

 

 

 

 

 

browsers do not support this feature.

you will have to write an active/x control and/or plugin for the browsers you wish to support this feature. 

hint: if you use .net to build the active/x control, it will not have enough permission to do this, so you should supply an installer that install the control in gac, and sets the permissions to trusted.

 

 

 

Thanks for reply

Is there any link where I can find working code for this?

or it seems like its not straight forward to open up print dialog through our webpage, from user's browser? 

Hi,

According to your description ,as bruce mentioned that you can print a report two ways with Crystal Reports for Visual Studio:

From the GUI, with the Print button on the toolbar that is provided with the CrystalReportViewer control on a Web or Windows Form.
From the SDK, with the ReportDocument object.

I would like to suggest you to check the link below for more information:

http://msdn.microsoft.com/en-us/library/ms225384(v=vs.90).aspx

Content of the article

Printing using the ActiveX control
In recent versions of Crystal Reports, you can specify the print mode using the new CrystalReportViewer.PrintMode property. It contains two enumerated types: ActiveX, and PDF.

When the property is set to PrintMode.PDF, the report is exported as a PDF on the Web server, and then streamed to the browser. The user is given the option to print directly to the printer. This option is cross-platform compatible.
When the property is set to PrintMode.ActiveX, an ActiveX printing control allows users to print the report directly to their local printer.

niravparekh

Is there any link where I can find working code for this?

Please check the links below for some articles which describe how to print Crystal Reports in ASP.NET automatically/Programmatically.

http://aspalliance.com/509

http://www.c-sharpcorner.com/UploadFile/mahesh/CRPrinting10062006161454PM/CRPrinting.aspx

Since the issue is related to Crystal Reports,I would recommend that please post the thread at Crystal Reports forums ,there are more Crystal Reports experts in that forums.

Hope it can help you.

perfect.

This is very good information.

Thanks again for providing working code as well.

[RESOLVED] Control does not exist in the current context

Hello:

I am having an issue with a Gridview control called ExportReport.  Here is my code

public static DataSet getRegistrations_Detail(string sessionid)
    {
        string connstring = ConfigurationManager.ConnectionStrings["ARCcon"].ToString();
        DataSet dsgetRegistrations_Detail = new DataSet();
        SqlConnection sqlcon = new SqlConnection(connstring);
        SqlCommand sqlcom = new SqlCommand("proc_report_getFormRegistrations_Detail", sqlcon);
        sqlcom.CommandType = CommandType.StoredProcedure;
        //SqlParameter ParWebID, ParStartDate, ParEndDate;
        SqlParameter ParSessionId;
        ParSessionId = sqlcom.Parameters.Add("@SessionId", SqlDbType.VarChar);
        ParSessionId.Value = sessionid;
   

        try
        {
            sqlcon.Open();
            SqlDataAdapter sqladp = new SqlDataAdapter(sqlcom);
            sqladp.Fill(dsgetRegistrations_Detail);
        }
        catch (Exception ex)
        {
            arcEvent.logError("Error", "getFormRegistrations_Detail", ex.ToString());
        }
        finally
        {
            sqlcon.Close();
        }
        return dsgetRegistrations_Detail;
    }
    
    private void BindExportReport()
    {
        
                   string sessionid = Session.SessionID;

            
                   DataSet ds = getRegistrations_Detail(sessionid);

                   if (ds.Tables.Count > 0)
                   {
                      ExportReport.DataSource = ds; //the error is one this line.
                       ExportReport.DataBind();

                   }


            
    }

This is the aspx file code:

 <form id="form1" runat="server">
    <%--Only Include The ScriptManager in Form Pages that require submissions--%>
     <asp:GridView ID="ExportReport" runat="server" DataSourceID="SqlDataSource1"></asp:GridView>
.
.
.
</form>

What file is your C# code in?

in a seperate .cs file.  The code file is called in the aspx page

Could you share the firstline of the aspx page and the .cs file. Also, have you checked if dataset is null or not.

Could you share the firstline of the aspx page and the .cs file. Also, have you checked if dataset is null or not.

first line of aspx file

<%@ page language="C#" autoeventwireup="true" CodeFile="vengine.aspx.cs"inherits="vengine" %>

 

first line of cs file

using

System;

And what's the name of your code file where you have that code?

its vengine.aspx.cs

In code you are setting DataSource where in aspx you are setting DataSourceId... Only one of them can be used...Remove below line from aspx

DataSourceID="SqlDataSource1"

I have removed that line and re-added, no difference.

Please post your code from both .ASPX and .CS files.

What is the error that you are getting...Can you also check if you are getting data returned in DataSet....

Compiler Error Message: CS0103: The name 'ExportReport' does not exist in the current context

I am getting data back if not if wouldn't go into the if clause. 

And from where are you calling this BindExportReport method...

Is it possible for you to paste entire code of aspx and aspx.cs file

I resolved this.  It was my error.  The form I was calling on the webpage was a different aspx file that did not include the GridView ReportViewer.  Once I added, the error went away