Hello!
I have a web application that generates documents as rtf files. The user can download these files from a webpage by clicking on a link to them.
I would like the files to be automatically downloaded as PDF files and not as RTF files.
How could I do that?
Thank you.
Loading
Sharon ThompsonPosted Apr 2, 2015, 4:45 AM
For example this is one of the simplest solutions to achieve the required conversion and also export that resulting PDF file to ASP.NET's client:
The code uses this .NET library for Word documents processing.
Pradip PandeyPosted Sep 13, 2012, 7:54 AM
This you can do by using this code:
1. Add reference for CrystalDecisions.CrystalReports.Engine.
2. Add assembly in your page like this
<%@ Register Assembly="CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"
Namespace="CrystalDecisions.Web" TagPrefix="CR" %>
3. Add CrystalReportViewer in you page deign like this
4. Create a Crystal Report by using a view e.g. vw_VendorList.
VB.Net Code:
Dim Rpt As New ReportDocument
Rpt.Load(Server.MapPath("abc.rpt"))
Dim ds As New Data.DataSet
Dim dt As New SqlDataAdapter("Select * from VW_VendorList", ConnString)
dt.Fill(ds, "VW_VendorList")
Rpt.SetDataSource(ds)
CRV.ReportSource = Rpt Rpt.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, True, "Vendor List Report")
After running this code, crystal report file will be exported in the form of Pdf.
Hope it will help.
Sharon WhitePosted Sep 13, 2012, 4:53 AM
Cyrille ReyPosted Sep 10, 2012, 8:22 AM
Thank you for your answer.
However, the documents are generated as rtf documents. What I want to do is for them to be converted to pdf when the user clicks download.
Is that possible?
How could I do it?
Thank you.
Kamal RawatPosted Sep 8, 2012, 1:37 AM
Dim FileName As String = Path.GetFileName(FullFileName) //Function provides file path
Response.ContentType = "application/octet-stream"
Response.AddHeader("Content-Disposition", "attachment; filename=" & FileName)
Response.WriteFile(FullFileName)
Response.[End]()
C# .NET
string FileName = Path.GetFileName(FullFileName); //Function provides file path Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment; filename=" + FileName); Response.WriteFile(FullFileName);
Response.End();
Please mark it as Accept, if it helps..
Rewant ChoudharyPosted Sep 7, 2012, 10:12 AM