How to adjust zoom ratio in Excel to PDF conversion?
This article explains how to adjust the zoom ratio in Excel to PDF conversion using XlsIO.
What is Zoom Ratio?
Zoom value gets or sets the percentage (between 10 and 400) by which Microsoft Excel will scale the worksheet for printing. This property applies only to worksheets.
To know more about other page settings in XlsIO, please refer to the documentation.
Code snippet to adjust the zoom ratio in Excel to PDF conversion
// Set zoom value worksheet.PageSetup.Zoom = 50;
Note: To adjust the zoom ratio for a PDF document, first, the zoom value is set to the worksheet and then converted into PDF.
The following C#/VB complete code snippet shows how to adjust the zoom ratio in Excel to PDF conversion using XlsIO.
C#
using Syncfusion.XlsIO; using System.IO; using System.Reflection; using Syncfusion.ExcelToPdfConverter; using Syncfusion.Pdf; namespace Zoom_Ratio { class Program { static void Main(string[] args) { using (ExcelEngine excelEngine = new ExcelEngine()) { // Instantiate the excel application object IApplication application = excelEngine.Excel; // The workbook is opened IWorkbook workbook; // Open existing workbook with data entered Assembly assembly = typeof(Program).GetTypeInfo().Assembly; Stream fileStream = assembly.GetManifestResourceStream("Zoom_Ratio.Sample.xlsx"); workbook = application.Workbooks.Open(fileStream, ExcelOpenType.Automatic); // The first worksheet object in the worksheets collection is accessed IWorksheet worksheet = workbook.Worksheets[0]; // Set zoom value worksheet.PageSetup.Zoom = 50; // Create an ExcelToPDFConverter instance ExcelToPdfConverter converter = new ExcelToPdfConverter(worksheet); // Initialize PDF Document PdfDocument pdfDocument = new PdfDocument(); // Initialize converter settings ExcelToPdfConverterSettings settings = new ExcelToPdfConverterSettings(); // Convert Excel document into PDF document with the specified settings pdfDocument = converter.Convert(settings); // Save the PDF document Stream stream = File.Create("Output.pdf"); pdfDocument.Save(stream); } } } }
VB
Imports Syncfusion.XlsIO Imports System.IO Imports System.Reflection Imports Syncfusion.ExcelToPdfConverter Imports Syncfusion.Pdf Namespace Zoom_Ratio Class Program Private Shared Sub Main(ByVal args() As String) Using excelEngine As ExcelEngine = New ExcelEngine() 'Instantiate the excel application object Dim application As IApplication = excelEngine.Excel 'The workbook is opened Dim workbook As IWorkbook 'Open existing workbook with data entered Dim assembly As Assembly = GetType(Program).GetTypeInfo.Assembly Dim fileStream As Stream = assembly.GetManifestResourceStream("Zoom_Ratio.Sample.xlsx") workbook = application.Workbooks.Open(fileStream, ExcelOpenType.Automatic) 'The first worksheet object in the worksheets collection is accessed Dim worksheet As IWorksheet = workbook.Worksheets(0) 'Set zoom value worksheet.PageSetup.Zoom = 50 'Create an ExcelToPDFConverter instance Dim converter As ExcelToPdfConverter = New ExcelToPdfConverter(worksheet) 'Initialize PDF Document Dim pdfDocument As PdfDocument = New PdfDocument 'Initialize converter settings Dim settings As ExcelToPdfConverterSettings = New ExcelToPdfConverterSettings 'Convert Excel Document into PDF document with the specified settings pdfDocument = converter.Convert(settings) 'Save the PDF file Dim stream As Stream = File.Create("Output.pdf") pdfDocument.Save(stream) End Using End Sub End Class End Namespace
Take a moment to peruse the documentation where you can find basic Excel document processing options along with the features like import and export data, chart, formulas, conditional formatting, data validation, tables, pivot tables and protect the Excel documents, and most importantly, the PDF, CSV and Image conversions with code examples.
Conclusion
I hope you enjoyed learning about how to adjust zoom ratio in Excel to PDF conversion.
You can refer to our XIsIO’s feature tour page to learn about its other groundbreaking features. Explore our UG documentation and online demos to understand how to manipulate data in Excel documents.
If you are an existing user, you can access our latest components from the License and Downloads page. For new users, you can try our 30-day free trial to check out XlsIO and other Syncfusion® components.
If you have any queries or require clarification, please let us know in the comments below or contact us through our support forums, Support Tickets, or feedback portal. We are always happy to assist you!