Hello guys,
Recently, I asked a question about how to print pdf to a printer. The link for reference is below.
https://community.dynamics.com/365/financeandoperations/f/dynamics-365-for-finance-and-operations-forum/426717/print-memorystream-to-screen-or-any-printer
I managed to convert it to memory stream and send to a printer, but what I didn't realize is that the solution provided is only working for me when Adobe is installed otherwise it fails.
Also, it opens adobe every time to send to the printer.
Anyone have any other approach or a way to fix this solution to not open adobe when the code is executed?
public static void sendPdfToPrinter(str _docName, str _printerName, str _base64Str, str _printerPath)
{
SRSPrintDestinationSettings srsPrintDestinationSettings = new SRSPrintDestinationSettings();
srsPrintDestinationSettings.printMediumType(SRSPrintMediumType::Printer);
srsPrintDestinationSettings.fileFormat(SRSReportFileFormat::PDF);
srsPrintDestinationSettings.printerName(_printerName);
srsPrintDestinationSettings.printerWhere(_printerPath);
srsPrintDestinationSettings.numberOfCopies(1);
srsPrintDestinationSettings.collate(false);
srsPrintDestinationSettings.printOnBothSides(SRSReportDuplexPrintingSetting::None);
srsPrintDestinationSettings.printAllPages(true);
srsPrintDestinationSettings.fromPage(0);
srsPrintDestinationSettings.toPage(0);
System.IO.MemoryStream stream = Binary::constructFromContainer(BinData::loadFromBase64(
_base64Str)).getMemoryStream() as System.IO.MemoryStream;
if (stream)
{
DocumentContract documentContract = DocumentContractFactory::Instance.Create(DocumentContractType::Pdf);
documentContract.Name = _docName;
documentContract.Contents = stream.ToArray();
documentContract.TargetType = TargetType::Printer;
documentContract.Settings = srsPrintDestinationSettings.printerPageSettings();
documentContract.ActivityID = newGuid();
SrsReportRunPrinter::sendDocumentContractToDocumentRouter(documentContract);
}
}Thanks,

Report
All responses (
Answers (