Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

No print option in web forms viewer

Status
Not open for further replies.

Samuel12Sam

Programmer
Jun 11, 2003
15
US
Hi,
The web forms viewer doesn't have a print option. so in a .net web project how do i implement this print option. can i use another viewer instead? if so how? please let me know.
thanx
 
.NET viewer is a "zero-client" DHTML viewer (it's just HTML generated on the web server) and unlike the ActiveX viewer, which is installed on the client, cannot print to a client printer. The alternative is either to print from the web browser or to export report to PDF format and then print from the PDF plug-in (there has to be Adobe Acrobate on the client, otherwise the user will be prompted to download the file). Here is a sample code on how to export a report to PFD and display it in the web browser:

string sPDFTempDirPath = "C:\\WebReportPDFs\\";
string sPDFTempFilePath = sPDFTempDirPath + DateTime.Now.Ticks.ToString() + ".pdf";

ExportOptions oExOptions = new ExportOptions();
DiskFileDestinationOptions oDestOptions = new DiskFileDestinationOptions();

oExOptions = yourReport.ExportOptions;
oExOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
oExOptions.ExportDestinationType = ExportDestinationType.DiskFile;

if(!System.IO.Directory.Exists(sPDFTempDirPath))
{
System.IO.Directory.CreateDirectory(sPDFTempDirPath);
}

oDestOptions.DiskFileName = sPDFTempFilePath;
oExOptions.DestinationOptions = oDestOptions;
yourReport.Export();

Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "application/pdf";
Response.WriteFile(sPDFTempFilePath);
Response.Flush();
Response.Close();

System.IO.File.Delete(sPDFTempFilePath);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top