Symptom
A NotSupportedException with the message "Specified method is not supported." is thrown by CrystalDecisions.CrystalReports.Engine.ReportDocument.PrintOptions.CopyFrom when used with a SATO CG212 printer.
For example:
CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
report.Load(@"SATO_PrinterTest.rpt");
PrinterSettings printerSettings = new PrinterSettings();
printerSettings.PrinterName = "SATO CG212";
MessageBox.Show("Will perform CopyFrom...", this.Text);
report.PrintOptions.CopyFrom(printerSettings, printerSettings.DefaultPageSettings); // The error occurs here
MessageBox.Show("Done.", this.Text);
Environment
Crystal Reports for Visual Studio
Reproducing the Issue
- Download the SATO CG212 printer driver located here: https://www.satoamerica.com/resource-library/software/windows- drivers.aspx
- Install the CG212 print driver to either NUL: or LPT1:. You do *not* need the actual printer.
- Ensure the name of the printer is "SATO CG212"
- Run SATO_PrinterTest.exe in the attached SATO_PrinterTest.zip file.
- Click Test.
- "Will perform CopyFrom..." will appear, click OK.
Note: "Specified method is not supported." is Expected: - "Done."
Resolution
The CopyFrom Method uses the DefaultPageSettings to set the values in the report.
For this printer when CR queries the System.Drawing.Printing.PaperSource property it is set to:
- Kind = 0
- RawKind = 0
- SourceName = "Unknown"
For other typical drivers this value looks like this:
- Kind = FormSource
- RawKind = 15
- SourceName = "automatically Selected"
Due to the SATO driver not setting this collection to the typical settings this generates the above error which is returned to Crystal by the OS System.
This is not a Crystal Reports for Visual Studio issue. Report the problem to SATO.
A work around is to use RAS to update the printer info as selected using the POC to update the printer info:
newOptsCloned.PageMargins.Bottom = 0;
newOptsCloned.PageMargins.Left = 0;
newOptsCloned.PageMargins.Right = 0;
newOptsCloned.PageMargins.Top = 0;
rptClientDoc.PrintOutputController.ModifyPrinterName("SATO CG212");
rptClientDoc.PrintOutputController.ModifyPaperOrientation(CrPaperOrientationEnum.crPaperOrientationPortrait);
rptClientDoc.PrintOutputController.ModifyPrinterName(newOptsCloned.PrinterName);
rptClientDoc.PrintOutputController.ModifyUserPaperSize(newOptsCloned.PageContentHeight, newOptsCloned.PageContentWidth);
rptClientDoc.PrintOutputController.ModifyPageMargins(newOptsCloned.PageMargins.Left, newOptsCloned.PageMargins.Right, newOptsCloned.PageMargins.Top,
rptClientDoc.PrintOutputController.ModifyPrintOptions(newOpts);
NOTE: above code is not complete and only is to show you typically how to use the POC to modify the printer selected.
Keywords
Crystal reports for visual studio, crforvs, Specified method is not supported, CopyFrom, SATO , KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , Problem