Click or drag to resize

ExcelToPdfCPageStyleCPageScale Class

Allows to set scale produced document. Default option: FitByWidth.
Inheritance Hierarchy
SystemObject
  SautinSoftExcelToPdfCPageStyleCPageScale

Namespace: SautinSoft
Assembly: SautinSoft.ExcelToPdf (in SautinSoft.ExcelToPdf.dll) Version: 2023.11.22
Syntax
public class CPageScale

The ExcelToPdfCPageStyleCPageScale type exposes the following members.

Methods
 NameDescription
Public methodAuto Convert without any scaling.
Public methodEqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
Public methodFitByHeight Fit each Excel sheet to a one PDF page depending of the page height. Thus, either to decrease the scale or leave as is if sheet could be fitted by page height.
Public methodFitByWidth Fit each Excel sheet to a one PDF page depending of the page width. Thus, either to decrease the scale or leave as is if sheet could be fitted by page width. This is the default option.
Public methodGetHashCodeServes as the default hash function.
(Inherited from Object)
Public methodGetTypeGets the Type of the current instance.
(Inherited from Object)
Public methodPercent Allows to specify page scale in percentages: from 1...10000.
Public methodScaleByHeight Make the scale the same as PDF page height. Thus, either to decrease or to increase scale.
Public methodScaleByPageBreak Convert with page break in excel document.
Public methodScaleByWidth Make the scale the same as PDF page width. Thus, either to decrease or to increase scale.
Public methodScaleToOnePage Make the scale close as possible to page size to fit the sheet into a single page. Simultaneously takes care of page width and height.
Public methodToStringReturns a string that represents the current object.
(Inherited from Object)
Top
Example
Fit each sheet to a single PDF page fixed size in C#
using System;
using System.IO;
using SautinSoft;

namespace Sample
{
    class Sample
    {
        static void Main(string[] args)
        {
            // Fit each sheet to a single page fixed size.
            ExcelToPdf x = new ExcelToPdf();

            // Fit each sheet to single PDF page, A4 format.
            x.PageStyle.PageSize.A4();
            x.PageStyle.PageScale.Auto();

            // Set PDF as output format.
            x.OutputFormat = SautinSoft.ExcelToPdf.eOutputFormat.Pdf;

            string excelFile = Path.GetFullPath(@"..\..\..\test.xlsx");
            string pdfFile = Path.ChangeExtension(excelFile, ".pdf"); ;

            try
            {
                x.ConvertFile(excelFile, pdfFile);
                System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(pdfFile) { UseShellExecute = true });
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.ReadLine();
            }
        }
    }
}
Fit each sheet to single a PDF page fixed size in VB.Net
Imports System
Imports System.IO
Imports SautinSoft

Module Sample

    Sub Main()

        ' Fit each sheet to a single page fixed size.
        Dim x As New ExcelToPdf()

        'Fit each sheet to single PDF page, A4 format.
        x.PageStyle.PageSize.A4()
        x.PageStyle.PageScale.Auto()

        ' Set PDF as output format.
        x.OutputFormat = SautinSoft.ExcelToPdf.eOutputFormat.Pdf

        Dim excelFile As String = Path.GetFullPath("..\..\..\test.xlsx")
        Dim pdfFile As String = Path.ChangeExtension(excelFile, ".pdf")

        Try
            x.ConvertFile(excelFile, pdfFile)
            System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(pdfFile) With {.UseShellExecute = True})
        Catch ex As Exception
            Console.WriteLine(ex.Message)
            Console.ReadLine()
        End Try
    End Sub
End Module
See Also