Hi! Thanks a lot for your answer. My problem is setting paper size from code.
In a Report Disegner in a Printer Setup menu I had put A6 format, and the report is corretted, but when export Report in a pdf, if itsn't specificated papersize, the size is 11 x 8,50 inch (that it correspond at define PaperSize.PaperLetter  ). I'm making a web application and using c#.
For example:
ReportDocument crReportDocument; ExportOptions crExportOptions; DiskFileDestinationOptions crDiskFileDestinationOptions;
crReportDocument = new ReportDocument();
// A5 crReportDocument.Load(Request.PhysicalApplicationPath + " file://\\Report\\CrystalReport_A5.rpt - \\Report\\CrystalReport_A5.rpt "); crReportDocument.PrintOptions.PaperSize = PaperSize.PaperA5; crReportDocument.PrintOptions.PaperOrientation = PaperOrientation.Landscape; crReportDocument.RecordSelectionFormula = "({StampaEtichetta.id} = 1)"; // Sets the logon info matching tables to admin as the user name and pass as the password SetDatabaseLogonReport(crReportDocument, this);
//Export to PDF crDiskFileDestinationOptions = new DiskFileDestinationOptions(); //append a filename to the export path and set this file as the filename property for //the DestinationOptions class crDiskFileDestinationOptions.DiskFileName = Request.PhysicalApplicationPath + Session.SessionID.ToString() + ".pdf";
crExportOptions = crReportDocument.ExportOptions;
//set the required report ExportOptions properties crExportOptions.DestinationOptions = crDiskFileDestinationOptions; crExportOptions.ExportDestinationType = ExportDestinationType.DiskFile; crExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
//Once the export options have been set for the report, the report can be exported. The Export command //does not take any arguments try { // Export the report crReportDocument.Export(); crReportDocument.Close();
Response.Clear(); Response.ClearContent(); Response.ClearHeaders();
Response.ContentType = "application/pdf"; Response.AddHeader("Content-disposition", "attachment; filename=\"Etichetta.pdf\""); Response.WriteFile(crDiskFileDestinationOptions.DiskFileName);
Response.Flush(); Response.Close();
System.IO.File.Delete(crDiskFileDestinationOptions.DiskFileName); } catch (Exception err) { Response.Write("<BR>"); Response.Write(err.Message.ToString()); }
|