public void PrintPDFFile(string pdfFile, double dblPWidth, double dblPHeight, int intCopies) { int intPrintOPT; string strCustomPrinter; string dllFile = isIDE ? @"d:\My Work\Visual Studio\DLL.NET\QPL\DLL\DebenuPDFLibraryDLL1811.dll" : $@"{exePath}\DebenuPDFLibraryDLL1811.dll"; DPL_v1811.PdfModule pdfLib = new DPL_v1811.PdfModule(dllFile, dplKey); pdfLib.LoadFromFile(pdfFile, ""); int docId = pdfLib.SelectedDocument(); pdfLib.NormalizePage(0); pdfLib.CombineContentStreams(); intPrintOPT = pdfLib.PrintOptions(0, 0, Application.ProductName); strCustomPrinter = GetCustomPrinterConfig(ref pdfLib, dblPWidth, dblPHeight, intCopies); pdfLib.PrintDocument(strCustomPrinter, 1, pdfLib.PageCount(), intPrintOPT); pdfLib.RemoveDocument(docId); pdfLib.ReleaseLibrary(); }
private string GetCustomPrinterConfig(ref DPL_v1811.PdfModule objRPDF, double dblPageWidth, double dblPageHeight, int intCopies) { string strPrinterConfig; int intWidth, intHeight, intLayout; intWidth = (int)Math.Round(25.4d * dblPageWidth * 10d); intHeight = (int)Math.Round(25.4d * dblPageHeight * 10d); intLayout = intWidth < intHeight ? 1 : 2; intLayout = 1; strPrinterConfig = objRPDF.NewCustomPrinter(objRPDF.GetDefaultPrinterName()); objRPDF.SetupCustomPrinter(strPrinterConfig, 1, 0); // REM custom paper size objRPDF.SetupCustomPrinter(strPrinterConfig, 2, intHeight); // REM custom paper height objRPDF.SetupCustomPrinter(strPrinterConfig, 3, intWidth); // REM custom paper width objRPDF.SetupCustomPrinter(strPrinterConfig, 4, intCopies); // REM number of copies objRPDF.SetupCustomPrinter(strPrinterConfig, 5, 300); // REM quality 1 = high, 2 = medium, 3 = low, 4 = draft, Or Exact DPI objRPDF.SetupCustomPrinter(strPrinterConfig, 6, 2); // REM Color 1 = monochrome, 2 = Color objRPDF.SetupCustomPrinter(strPrinterConfig, 11, intLayout); // REM 1 = portrait, 2 = landscape return strPrinterConfig; }
and following line call the print funcion: PrintPDFFile(filePath, 8.50, 11, 3);
|