Symptom
- Designing the report:
- When creating a custom paper size for a printer you can give it a name. The OS then assigns a random ENUM value for that paper size, typically above 256.
- This ENUM is saved in the Crystal Reports RPT file.
- Tthe issue:
- User installs the printer driver on his/her local PC and creates the same custom paper size. The ENUM is likely different...
- Sending the report to another user and/or opening the report in a custom application the ENUM value for that paper size likely will not be the same as the original peper size ENUM.
- What happens:
- CR Designer and .NET application will look for the printer and customer paper size and it can't be found, because the ENUM is the wrong value.
- CR then indicates the design printer cannot be found and defaults to the users default printer removing formatting, orientation ( possibly ) and defaulting typically to letter size paper.
Environment
- Crystal Reports Developer for Visual Studio, Service Pack 8
- Crystal Reports Designer 2011
- Crystal Reports Designer 2013
Resolution
- When Designing reports use a printer that best fits your output destination and format.
- Save the printer with the report.
- As you can see below You can get the Customer Paper Size ENUM as well as the Customer paper size name along with the printer name saved in the report.
4. With this info you can now use CopyTo/CopyFrom in both RAS and the ClientDocument to set the printer and custom paper size as defined in the report.
5. Only requirements are the Printer is installed on the work station and the custom paper size name is exactly the same as what is saved in the report.
Code sample:
rptClientDoc = rpt.ReportClientDocument;
CrystalDecisions.Shared.PrintLayoutSettings PrintLayout = new CrystalDecisions.Shared.PrintLayoutSettings();
CrystalDecisions.ReportAppServer.ReportDefModel.PrintOptions rptPRT = new CrystalDecisions.ReportAppServer.ReportDefModel.PrintOptions();
CrystalDecisions.ReportAppServer.ReportDefModel.PrintOptions rptPRTCloned = new CrystalDecisions.ReportAppServer.ReportDefModel.PrintOptions();
PrinterSettings ps = new PrinterSettings();
PageSettings pgs = new PageSettings();
rptPRT = rptClientDoc.PrintOutputController.GetPrintOptions();
rptPRTCloned = rptPRT.Clone();
PrintLayout.Scaling = PrintLayoutSettings.PrintScaling.DoNotScale;
if (rpt.PrintOptions.SavedPrinterName.Length != 0)
{
btnSavedPrinterName.Text = rpt.PrintOptions.SavedPrinterName.ToString();
}
else
btnSavedPrinterName.Text = rptPRT.SavedPrinterName.ToString();
//SP 8
try{
if (rptPRT.DriverName != "DISPLAY")
{
btnPaperSizeName.Text = rptPRT.PaperName.ToString();
if (rptPRT.PaperName.ToString() == "")
{
btnPaperSizeName.Text = "Printer not installed";
}
}
else
btnPaperSizeName.Text = "Printer is Display";
}
catch (Exception ex)
{
btnSQLStatement.Text = "ERROR: " + ex.Message;
return;
}
//rpt.PrintOptions.DissociatePageSizeAndPrinterPaperSize = false;
//rpt.PrintOptions.CopyTo(ps, pgs);
CRPaperSize.Text = rptPRT.PaperSize.ToString();
CRPrinterName.Text = ps.PrinterName;
// New API in SP4
CRPrinterName.Text = rptPRT.SavedPrinterName.ToString();
- Also note: this update has been done for printcontrol.dll and can be used in BI 4.x.
- Update the reports so the printer info is saved and then re-bublish them or update them in the Repository.
- When printing the user should see the defaults as defined client side.
See Also
Open the attached sample application to use CopyTo/CopyFrom the printer info from the report and copy to the SystemPrinter selected.
Keywords
CRVS CR NET printer special RAS Crystal 2010 2012 , KBA , BI-DEV-NET-SDK , .NET SDK / COM SDK , Product Enhancement
Product
SAP Crystal Reports, developer version for Microsoft Visual Studio