BoldSignA modern eSignature application with affordable pricing. Sign up today for unlimited document usage!
//Create the previewdialog for print the document.
PrintPreviewDialog printdialog = new PrintPreviewDialog();
//Create the pdfviewer for load the document.
PdfViewerControl pdfviewer = new PdfViewerControl();
// PdfDocumentViewer
MemoryStream pdfstream = new MemoryStream();
ExcelToPdfConverter converter = new ExcelToPdfConverter(spreadsheetControl.Workbook);
//Intialize the PdfDocument
PdfDocument pdfDoc = new PdfDocument();
//Intialize the ExcelToPdfConverter Settings
ExcelToPdfConverterSettings settings = new ExcelToPdfConverterSettings();
settings.LayoutOptions = LayoutOptions.FitSheetOnOnePage;
//Assign the PdfDocument to the templateDocument property of ExcelToPdfConverterSettings
settings.TemplateDocument = pdfDoc;
settings.DisplayGridLines = GridLinesDisplayStyle.Invisible;
//Convert Excel Document into PDF document
pdfDoc = converter.Convert(settings);
//Setting the Orientation
pdfDoc.PageSettings.Orientation = PdfPageOrientation.Landscape;
//Save the PDF file
pdfDoc.Save(pdfstream);
//Load the document to pdfviewer
pdfviewer.Load(pdfstream);
printdialog.Document = pdfviewer.PrintDocument;
printdialog.ShowDialog();
|
//Create the previewdialog for print the document.
PrintPreviewDialog printdialog = new PrintPreviewDialog();
//Create the pdfviewer for load the document.
PdfViewerControl pdfviewer = new PdfViewerControl();
// PdfDocumentViewer
MemoryStream pdfstream = new MemoryStream();
//Set Orientation in Worksheet also,
spreadsheetControl.Workbook.ActiveSheet.PageSetup.Orientation = ExcelPageOrientation.Landscape;
ExcelToPdfConverter converter = new ExcelToPdfConverter(spreadsheetControl.Workbook);
//Intialize the PdfDocument
PdfDocument pdfDoc = new PdfDocument();
//Intialize the ExcelToPdfConverter Settings
ExcelToPdfConverterSettings settings = new ExcelToPdfConverterSettings();
settings.LayoutOptions = LayoutOptions.FitSheetOnOnePage;
//Assign the PdfDocument to the templateDocument property of ExcelToPdfConverterSettings
settings.TemplateDocument = pdfDoc;
settings.DisplayGridLines = GridLinesDisplayStyle.Invisible;
//Convert Excel Document into PDF document
pdfDoc = converter.Convert(settings);
//Setting the Orientation
pdfDoc.PageSettings.Orientation = PdfPageOrientation.Landscape;
//Save the PDF file
pdfDoc.Save(pdfstream);
//Load the document to pdfviewer
pdfviewer.Load(pdfstream);
printdialog.Document = pdfviewer.PrintDocument;
printdialog.ShowDialog();
|
pdfDoc.PageSettings.Margins.Top = 0;
pdfDoc.PageSettings.Margins.Bottom = 0;
|