Beispiel #1
0
        static void Main(string[] args)
        {
            // Create a PDF Document Processor instance and load a PDF into it.
            using (PdfDocumentProcessor documentProcessor = new PdfDocumentProcessor()) {
                documentProcessor.LoadDocument(@"..\..\Demo.pdf");

                // Declare the PDF printer settings.
                PdfPrinterSettings settings = new PdfPrinterSettings();

                // Specify the page numbers to be printed.
                settings.PageNumbers = new int[] { 1, 2, 3, 4, 5, 6 };

                // Handle the PrintPage event to specify print output.
                documentProcessor.PrintPage += OnPrintPage;

                // Handle the QueryPageSettings event to customize settings for a page to be printed.
                documentProcessor.QueryPageSettings += OnQueryPageSettings;

                // Print the document using the specified printer settings.
                documentProcessor.Print(settings);

                // Unsubscribe from PrintPage and QueryPageSettings events.
                documentProcessor.PrintPage         -= OnPrintPage;
                documentProcessor.QueryPageSettings -= OnQueryPageSettings;
            }
        }
Beispiel #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // Create a PDF Viewer instance and load a PDF into it.
            PdfViewer pdfViewer = this.pdfViewer1;

            pdfViewer.LoadDocument(@"..\..\Demo.pdf");

            // If required, declare and specify the system printer settings.
            PrinterSettings printerSettings = new PrinterSettings();

            printerSettings.PrinterName   = "Microsoft XPS Document Writer";
            printerSettings.PrintToFile   = true;
            printerSettings.PrintFileName = @"..\..\Demo.xps";

            // Declare the PDF printer settings.
            // If required, pass the system settings to the PDF printer settings constructor.
            PdfPrinterSettings pdfPrinterSettings = new PdfPrinterSettings(printerSettings);

            // Specify the PDF printer settings.
            pdfPrinterSettings.PageOrientation = PdfPrintPageOrientation.Auto;
            pdfPrinterSettings.PageNumbers     = new int[] { 1, 3, 4, 5 };
            pdfPrinterSettings.ScaleMode       = PdfPrintScaleMode.CustomScale;
            pdfPrinterSettings.Scale           = 90;

            // Print the document using the specified printer settings.
            pdfViewer.Print(pdfPrinterSettings);
        }
Beispiel #3
0
        public bool Print(string filePath, PrinterSettings printerSettings)
        {
            if (!base.CanPrint(filePath))
            {
                return(false);
            }

            PdfPrinterSettings pdfPrinterSettings = new PdfPrinterSettings(printerSettings);

            using (PdfViewer pdfViewer = new PdfViewer())
            {
                pdfViewer.LoadDocument(filePath);
                pdfViewer.Print(pdfPrinterSettings);
            }
            return(true);
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            // Create a Pdf Document Processor instance and load a PDF into it.
            PdfDocumentProcessor documentProcessor = new PdfDocumentProcessor();

            documentProcessor.LoadDocument(@"..\..\Demo.pdf");

            // Declare the PDF printer settings.
            PdfPrinterSettings pdfPrinterSettings = new PdfPrinterSettings();

            // Specify the PDF printer settings.
            pdfPrinterSettings.PageOrientation = PdfPrintPageOrientation.Portrait;
            pdfPrinterSettings.PageNumbers     = new int[] { 1, 3, 4, 5 };

            // Setting the PdfPrintScaleMode property to CustomScale requires
            // specifying the Scale property, as well.
            pdfPrinterSettings.ScaleMode = PdfPrintScaleMode.CustomScale;
            pdfPrinterSettings.Scale     = 90;

            // Print the document using the specified printer settings.
            documentProcessor.Print(pdfPrinterSettings);
        }
Beispiel #5
0
        public ShippingModel PrintRemesa(List <FacturaModel> ord, ShippingModel shipping, PdfPrinterSettings sett)
        {
            try
            {
                shipping.error.HasError = false;
                using (var pdfViewer = new DevExpress.XtraPdfViewer.PdfViewer())
                {
                    PageSettings sets = sett.Settings.DefaultPageSettings;
                    XtraReport   rem  = new RemesaTCC();
                    rem.DataSource            = ord;
                    rem.PrinterName           = "kioskobillprint";
                    rem.ShowPrintStatusDialog = false;
                    rem.PaperKind             = System.Drawing.Printing.PaperKind.Custom;
                    string path = @"C:\Kiosko\temp\invoice\" + shipping.guide.Code + ".pdf";
                    rem.CreateDocument(false);
                    rem.ExportToPdf(path);
                    rem.ExportToPdf(path);
                    pdfViewer.LoadDocument(path);
                    PaperSize paperSize = new PaperSize("Print", (int)(800 / 2.94), (int)(rem.PageHeight / 2.94));
                    paperSize.RawKind = (int)PaperKind.Custom;
                    sets.PaperSize    = paperSize;
                    pdfViewer.ShowPrintStatusDialog = false;
                    pdfViewer.Print(sett);
                    pdfViewer.CloseDocument();
                }
            }catch (SystemException E)
            {
                shipping.error.HasError = true;
                shipping.error.Message  = E.Message;

                return(shipping);
            }
            return(shipping);
        }
        private void GetReport(string FormsID)
        {
            string GetReportRL = string.Format(@"/api/Report/GetReport/");
            var    client      = new ClientConnect();
            var    param       = new Dictionary <string, string>();
            var    header      = new Dictionary <string, string>();

            param.Add("FormsID", FormsID);
            _Forms.UniqueDataStructure.AcceptChanges();
            DataSet TheData = new DataSet();

            TheData.Tables.Clear();
            TheData.Tables.Add(_Forms.UniqueDataStructure);
            string JSOResult;

            JSOResult = JsonConvert.SerializeObject(TheData, Formatting.Indented);
            try
            {
                //this.pdfViewer1.LoadDocument(@"..\..\Report.pdf"

                var response = Task.Run(() => client.PostWithBodyAndParameters(GetReportRL, param, JSOResult)).Result;
                _PrintedForm = JsonConvert.DeserializeObject <PrintedForm>(response);
                string txtPDF = _PrintedForm.PDFLocation;

                if (File.Exists(@_PrintedForm.PDFLocation))
                {
                    if (MoveToProdind)
                    {
                        //Process.Start("explorer.exe", _PrintedForm.PDFLocation);
                        PdfViewer i = new PdfViewer();
                        DevExpress.XtraEditors.XtraForm jj = new DevExpress.XtraEditors.XtraForm();
                        i.LoadDocument(@_PrintedForm.PDFLocation);
                        i.Dock     = DockStyle.Fill;
                        i.ZoomMode = PdfZoomMode.FitToWidth;
                        i.NavigationPanePageVisibility = PdfNavigationPanePageVisibility.None;
                        jj.Controls.Add(i);
                        jj.Width  = 600;
                        jj.Height = 800;
                        jj.Show();
                        jj.ShowIcon = false;
                        jj.Text     = "OCR - DOCUMENT PREVIEW";
                        i.CreateRibbon();
                        PdfPrinterSettings ps = new PdfPrinterSettings();
                        i.Print(ps);
                    }
                    else
                    {
                        PdfViewer i = new PdfViewer();
                        DevExpress.XtraEditors.XtraForm jj = new DevExpress.XtraEditors.XtraForm();
                        i.LoadDocument(@_PrintedForm.PDFLocation);
                        i.Dock     = DockStyle.Fill;
                        i.ZoomMode = PdfZoomMode.FitToWidth;
                        i.NavigationPanePageVisibility = PdfNavigationPanePageVisibility.None;
                        jj.Controls.Add(i);
                        jj.Width  = 600;
                        jj.Height = 800;
                        jj.Show();
                        jj.ShowIcon = false;
                        jj.Text     = "CHECKLIST EXAMPLE - CANNOT BE PRINTED";
                    }
                }
            }
            catch (Exception error)
            {
            }
        }