/// <summary>
        /// Export to PDF on Button click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Exportbutton_Click(object sender, EventArgs e)
        {
            var converter = new GridPDFConverter();
            var lowest    = 0;

            //Adding PageBreaks to a list.
            var rows = new List <int> {
                30, 63, 90, 130, 150
            };

            var pdfDocument = new PdfDocument();

            pdfDocument.Save("Sample.pdf");
            foreach (var rownumber in rows)
            {
                var pdf        = new PdfDocument();
                var maximumRow = rownumber;
                converter.ExportToPdf(pdf, gridControl1, GridRangeInfo.Rows(lowest, maximumRow));
                var stream = new MemoryStream();
                pdf.Save(stream);
                var loadedDocument = new PdfLoadedDocument("Sample.pdf");
                loadedDocument =
                    PdfDocumentBase.Merge(loadedDocument, new PdfLoadedDocument(stream)) as PdfLoadedDocument;
                loadedDocument.Save("Sample.pdf");
                loadedDocument.Close(true);
                stream.Dispose();
                lowest = maximumRow + 1;
            }
            var loadedDocument1 = new PdfLoadedDocument("Sample.pdf");

            loadedDocument1.Pages.RemoveAt(0);
            loadedDocument1.Save("Sample.pdf");
            Process.Start("Sample.pdf");
        }
Exemplo n.º 2
0
        //perform the toolstrip operation
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            if (ShowDialog() == DialogResult.OK)
            {
                GridPDFConverter pdfConvertor = new GridPDFConverter();

                if (checkBoxAdv1.CheckState == CheckState.Checked)
                {
                    pdfConvertor.ShowHeader = true;
                }
                if (checkBoxAdv2.CheckState == CheckState.Checked)
                {
                    pdfConvertor.ShowFooter = true;
                }

                pdfConvertor.Margins.Left   = (int)domainUpDown1.Value;
                pdfConvertor.Margins.Right  = (int)domainUpDown2.Value;
                pdfConvertor.Margins.Top    = (int)domainUpDown3.Value;
                pdfConvertor.Margins.Bottom = (int)domainUpDown4.Value;

                pdfConvertor.DrawPDFHeader += new GridPDFConverter.DrawPDFHeaderFooterEventHandler(pdfConvertor_DrawPDFHeader);

                pdfConvertor.DrawPDFFooter += new GridPDFConverter.DrawPDFHeaderFooterEventHandler(pdfConvertor_DrawPDFFooter);

                //pdfConvertor.Margins.All = 25;
                pdfConvertor.ExportToPdf("Sample.pdf", this.gridGroupingControl2.TableControl);
                //Launching the PDF file using the default Application.[Acrobat Reader]
                System.Diagnostics.Process.Start("Sample.pdf");
            }
        }
Exemplo n.º 3
0
        private void cmdPdf_Click(object sender, EventArgs e)
        {
            GridPDFConverter pdfConvertor = new GridPDFConverter();

            pdfConvertor.ShowHeader = true;
            pdfConvertor.ShowFooter = true;
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.AddExtension = true;
            saveFileDialog.Filter       = "Files(*.pdf)|*.pdf";
            saveFileDialog.FileName     = "Untitled";
            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                pdfConvertor.ExportToPdf(saveFileDialog.FileName, this.GGCVista.TableControl);
                System.Diagnostics.Process.Start(saveFileDialog.FileName);
            }
        }