Пример #1
0
        /// <summary>
        /// Exports the DataGrid to PDF
        /// </summary>
        /// <param name="obj">object type parameter</param>
        private void ExportToPdf(object obj)
        {
            DataGridPdfExportingController pdfExport = new DataGridPdfExportingController();

            pdfExport.HeaderAndFooterExporting += this.PdfExport_HeaderAndFooterExporting;
            MemoryStream stream = new MemoryStream();
            var          doc    = pdfExport.ExportToPdf(this.dataGrid, new DataGridPdfExportOption()
            {
                FitAllColumnsInOnePage = true
            });

            if (doc == null)
            {
                return;
            }

            doc.Save(stream);
            doc.Close(true);

            if (Device.RuntimePlatform == Device.UWP)
            {
                Xamarin.Forms.DependencyService.Get <ISaveWindowsPhone>().Save("DataGrid.pdf", "application/pdf", stream);
            }
            else
            {
                Xamarin.Forms.DependencyService.Get <ISave>().Save("DataGrid.pdf", "application/pdf", stream);
            }
        }
Пример #2
0
 private void ExportToPdf(object sender, EventArgs e)
 {
     DataGridPdfExportingController pdfExport = new DataGridPdfExportingController();
     MemoryStream stream = new MemoryStream();
     pdfExport.HeaderAndFooterExporting += pdfExport_HeaderAndFooterExporting;
     var doc = pdfExport.ExportToPdf(this.SfGrid);
     doc.Save(stream);
     doc.Close(true);
     Save("DataGrid.pdf", "application/pdf", stream);
 }
Пример #3
0
        private void ExportToPdf(object sender, EventArgs e)
        {
            DataGridPdfExportingController pdfExport = new DataGridPdfExportingController();
            MemoryStream stream = new MemoryStream();

            pdfExport.HeaderAndFooterExporting += pdfExport_HeaderAndFooterExporting;
            var doc = pdfExport.ExportToPdf(this.SfGrid);

            doc.Save(stream);
            doc.Close(true);
            Save("DataGrid.pdf", "application/pdf", stream);
        }
        private void ExportToPdf()
        {
            isExporting = true;
            DataGridPdfExportingController pdfExport = new DataGridPdfExportingController();
            pdfExport.HeaderAndFooterExporting += pdfExport_HeaderAndFooterExporting;
            MemoryStream stream = new MemoryStream();
            var doc = pdfExport.ExportToPdf(this.dataGrid, new DataGridPdfExportOption() { FitAllColumnsInOnePage = true});
            doc.Save(stream);
            doc.Close(true);

            if (Device.OS == TargetPlatform.WinPhone || Device.OS == TargetPlatform.Windows)
                Xamarin.Forms.DependencyService.Get<ISaveWindowsPhone>().Save("DataGrid.pdf", "application/pdf", stream);
            else
                Xamarin.Forms.DependencyService.Get<ISave>().Save("DataGrid.pdf", "application/pdf", stream);
        }
        private async void sendButton_Clicked(object sender, EventArgs e)
        {
            bool confirmed = await Application.Current.MainPage.DisplayAlert("Query", "Confirm toexport the current form into a PDF. ", "Confirm", "Cancel");

            if (confirmed)
            {
                DataGridPdfExportingController pdfExport = new DataGridPdfExportingController();
                MemoryStream stream = new MemoryStream();
                var          doc    = pdfExport.ExportToPdf(this.reportsDataGrid, new DataGridPdfExportOption()
                {
                    FitAllColumnsInOnePage = true
                });
                doc.Save(stream);
                doc.Close(true);
                if (Device.OS == TargetPlatform.WinPhone || Device.OS == TargetPlatform.Windows)
                {
                    Xamarin.Forms.DependencyService.Get <ISaveWindowsPhone>().Save("DataGrid.pdf", "application/pdf", stream);
                }
                else
                {
                    Xamarin.Forms.DependencyService.Get <ISave>().Save("DataGrid.pdf", "application/pdf", stream);
                }


                //I have NO IDEA why the code the offered to print to PDF didnt work but I found a replacement deep in the forums.
                //DataGridPdfExportingController pdfExport = new DataGridPdfExportingController();
                //MemoryStream stream = new MemoryStream();
                //var pdfDoc = new PdfDocument();
                //PdfPage page = pdfDoc.Pages.Add();
                //var exportToPdfGrid = pdfExport.ExportToPdfGrid(this.reportsDataGrid, this.reportsDataGrid.View, new DataGridPdfExportOption()
                //{
                //    FitAllColumnsInOnePage = true,

                //}, pdfDoc);
                //exportToPdfGrid.Draw(page, new PointF(10, 10));
                //pdfDoc.Save(stream);
                //pdfDoc.Close(true);
                //if (Device.OS == TargetPlatform.WinPhone || Device.OS == TargetPlatform.Windows)
                //    await Xamarin.Forms.DependencyService.Get<ISaveWindows>().Save("DataGrid.pdf", "application/pdf", stream);
                //else
                //    Xamarin.Forms.DependencyService.Get<ISave>().Save("DataGrid.pdf", "application/pdf", stream);
            }
        }
Пример #6
0
        private void ExportToPDF_Clicked(object sender, EventArgs e)
        {
            isExporting = true;
            DataGridPdfExportingController pdfExport = new DataGridPdfExportingController();

            pdfExport.HeaderAndFooterExporting += pdfExport_HeaderAndFooterExporting;
            MemoryStream stream = new MemoryStream();
            var          doc    = pdfExport.ExportToPdf(this.dataGrid, new DataGridPdfExportOption()
            {
                FitAllColumnsInOnePage = true
            });

            doc.Save(stream);
            doc.Close(true);

            if (Device.OS == TargetPlatform.WinPhone || Device.OS == TargetPlatform.Windows)
            {
                Xamarin.Forms.DependencyService.Get <ISaveWindowsPhone>().Save("DataGrid.pdf", "application/pdf", stream);
            }
            else
            {
                Xamarin.Forms.DependencyService.Get <ISave>().Save("DataGrid.pdf", "application/pdf", stream);
            }
        }