Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

ReportDocument PrintOptions.CopyFrom and PrintToPrinter

I have some confusion about using PrintOptions.CopyFrom(...) followed by PrintToPrinter(....)

We distribute our application and reports to various users with various printers. To get what printer to send to the application makes a call to a standard .NET PrinterDialog. At first I was just getting the printer name and then passing that to the ReportDocument, but then a user requested functionality to allow them to change printer settings at runtime such as select a different tray or adjust color quality (etc).

I had some trouble, that I think I got worked out - but I have some confusion as to why just using PrintOptions.CopyFrom(...) by itself did not work - see following example:

' Where cr is a PrinterDocument

' ATTEMPT 1

cr.PrintOptions.PrinterName = szPrinterName

cr.PrintOptions.CopyFrom(pPrinterSettings, pPageSettings)

' assume cr uses the settings in PrintOptions

cr.PrintToPrinter(1, False, 1, 100)

'RESULT: does NOT result in using the expected Printer Settings

' ATTEMPT 2

cr.PrintOptions.PrinterName = szPrinterName

cr.PrintOptions.CopyFrom(pPrinterSettings, pPageSettings)

' explicitly pass the settings

cr.PrintToPrinter(pSettings, pPageSettings, False)

' RESULT: DOES result in using the expected Printer Settings

The documentation says PrinterOptions.CopyFrom "Copies the values of PrinterSettings and PageSettings into this PrintOptions"

And I have seen examples in this KB where the user called PrintOptions.CopyFrom followed byPrintToPrinter (without explicit printer and page settings).

So the question is - using the example above -

Why doesn't cr.PrintToPrinter(1, False, 1, 100) use the values set via cr.PrintOptions.CopyFrom(...) ?

Former Member
Not what you were looking for? View more on this topic or Ask a question