Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
142459 | Feb 5,2019 10:53 AM UTC | Feb 12,2019 11:30 AM UTC | UWP | 5 |
![]() |
Tags: SfSpreadsheet |
xmlns:pdfviewer="using:Syncfusion.Windows.PdfViewer"
<pdfviewer:SfPdfViewerControl x:Name="pdfviewer"/> |
//Create a new PDF document.
PdfDocument pdfDocument = new PdfDocument();
StorageFile storageFile = null;
foreach (var sheet in this.spreadsheet.Workbook.Worksheets)
{
//Create the page
PdfPage pdfPage = pdfDocument.Pages.Add();
//Create the parent grid
PdfGrid parentPdfGrid = new PdfGrid();
//Add the rows
for (int i = 0; i < this.spreadsheet.ActiveSheet.UsedRange.Row; i++)
{
PdfGridRow row1 = parentPdfGrid.Rows.Add();
row1.Height = 50;
parentPdfGrid.Columns.Add(this.spreadsheet.ActiveSheet.UsedRange.Column);
for (int j = 0; j < this.spreadsheet.ActiveSheet.UsedRange.Column; j++)
{
var style = this.spreadsheet.ActiveSheet.UsedRange[i, j];
PdfGridCell pdfGridCell = parentPdfGrid.Rows[i].Cells[j];
pdfGridCell.Value = style.Value;
}
}
//Draw the PdfGrid.
parentPdfGrid.Draw(pdfPage, PointF.Empty);
StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
storageFile = await local.CreateFileAsync("Sample.pdf", CreationCollisionOption.ReplaceExisting);
//Save the document.
await pdfDocument.SaveAsync(storageFile);
}
if (storageFile != null)
{
FileStream stream = File.OpenRead(storageFile.Path);
pdfViewer.Unload();
pdfViewer.LoadDocument(stream);
//Print the pdf file.
pdfViewer.Print();
pdfDocument.Dispose();
} |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.