Excel to PDF Converter Settings

24 Jul 202624 minutes to read

XlsIO allows you to convert an entire workbook or a single worksheet into PDF document with conversion settings of Excel to PDF converter.

Auto-detect Complex Script

This property enables complex-script validation for text in the Excel document so that scripts such as Arabic, Hebrew, and Thai are rendered correctly in the PDF. Its default value is false.

The following code snippet explains how to enable the AutoDetectComplexScript property while converting an Excel document to PDF.

using (ExcelEngine excelEngine = new ExcelEngine())
{
	IApplication application = excelEngine.Excel;
	application.DefaultVersion = ExcelVersion.Xlsx;
	IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"));

	//Initialize XlsIORendererSettings
	XlsIORendererSettings settings = new XlsIORendererSettings();

	//Enable AutoDetectComplexScript property
	settings.AutoDetectComplexScript = true;

	//Initialize XlsIORenderer
	XlsIORenderer renderer = new XlsIORenderer();

	//Convert the Excel document to PDF with renderer settings
	PdfDocument pdfDocument = renderer.ConvertToPDF(workbook, settings);

	#region Save
	//Saving the workbook
	pdfDocument.Save(Path.GetFullPath("Output/ComplexScriptToPDF.pdf"));
	#endregion
}
using (ExcelEngine excelEngine = new ExcelEngine())
{
  IApplication application = excelEngine.Excel;
  application.DefaultVersion = ExcelVersion.Excel2016;
  IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");

  //Initialize ExcelToPdfConverterSettings
  ExcelToPdfConverterSettings settings = new ExcelToPdfConverterSettings();

  //Enable AutoDetectComplexScript property
  settings.AutoDetectComplexScript = true;

  //Load the Excel document into ExcelToPdfConverter
  ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook);

  //Convert the Excel document to PDF with converter settings
  PdfDocument document = converter.Convert(settings);

  //Save the PDF document
  document.Save("Output.pdf");
}
Using excelEngine As ExcelEngine = New ExcelEngine()
  Dim application As IApplication = excelEngine.Excel
  application.DefaultVersion = ExcelVersion.Excel2016
  Dim workbook As IWorkbook = application.Workbooks.Open("Sample.xlsx")

  'Initialize ExcelToPdfConverterSettings
  Dim settings As ExcelToPdfConverterSettings = New ExcelToPdfConverterSettings()

  'Enable AutoDetectComplexScript property
  settings.AutoDetectComplexScript = True

  'Load the Excel document into ExcelToPdfConverter
  Dim converter As ExcelToPdfConverter = New ExcelToPdfConverter(workbook)

  'Convert the Excel document to PDF with converter settings
  Dim document As PdfDocument = converter.Convert(settings)

  'Save the PDF document
  document.Save("Output.pdf")
End Using

A complete working example to detect complex script in Excel to PDF conversion in C# is present on this GitHub page.

Custom Paper Size

This property sets the required paper size, in inches. The default value is SizeF.Empty (that is, Width = 0.0f, Height = 0.0f).

The following complete code snippet explains how to set CustomPaperSize while converting Excel document to PDF.

using (ExcelEngine excelEngine = new ExcelEngine())
{
	IApplication application = excelEngine.Excel;
	application.DefaultVersion = ExcelVersion.Xlsx;
	IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"));

	//Initialize XlsIORendererSettings
	XlsIORendererSettings settings = new XlsIORendererSettings();

	//Set CustomPaperSize
	settings.CustomPaperSize = new SizeF(10, 20);

	//Initialize XlsIORenderer
	XlsIORenderer renderer = new XlsIORenderer();

	//Convert the Excel document to PDF with renderer settings
	PdfDocument pdfDocument = renderer.ConvertToPDF(workbook, settings);

	#region Save
	//Saving the workbook
	pdfDocument.Save(Path.GetFullPath("Output/CustomPaperSize.pdf"));
	#endregion
}
using (ExcelEngine excelEngine = new ExcelEngine())
{
  IApplication application = excelEngine.Excel;
  application.DefaultVersion = ExcelVersion.Excel2016;
  IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");

  //Initialize ExcelToPdfConverterSettings
  ExcelToPdfConverterSettings settings = new ExcelToPdfConverterSettings();

  //Set CustomPaperSize
  settings.CustomPaperSize = new SizeF(10, 20);

  //Load the Excel document into ExcelToPdfConverter
  ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook);

  //Convert the Excel document to PDF with converter settings
  PdfDocument document = converter.Convert(settings);

  //Save the PDF document
  document.Save("Output.pdf");
}
Using excelEngine As ExcelEngine = New ExcelEngine()
  Dim application As IApplication = excelEngine.Excel
  application.DefaultVersion = ExcelVersion.Excel2016
  Dim workbook As IWorkbook = application.Workbooks.Open("Sample.xlsx")

  'Initialize ExcelToPdfConverterSettings
  Dim settings As ExcelToPdfConverterSettings = New ExcelToPdfConverterSettings()

  'Set CustomPaperSize
  settings.CustomPaperSize = New SizeF(10, 20)

  'Load the Excel document into ExcelToPdfConverter
  Dim converter As ExcelToPdfConverter = New ExcelToPdfConverter(workbook)

  'Convert the Excel document to PDF with converter settings
  Dim document As PdfDocument = converter.Convert(settings)

  'Save the PDF document
  document.Save("Output.pdf")
End Using

A complete working example to convert Excel to PDF with custom paper size in C# is present on this GitHub page.

Display Gridlines

This property sets the gridline display style in the output PDF document. Three display styles are available on the GridLinesDisplayStyle enumeration: Auto, Invisible, and Visible.

Auto

When the display style is set to Auto, gridlines are not rendered in the output PDF. The default value of DisplayGridLines is Auto.

using (ExcelEngine excelEngine = new ExcelEngine())
{
  IApplication application = excelEngine.Excel;
  IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");

  //Initialize XlsIORendererSettings
  XlsIORendererSettings settings = new XlsIORendererSettings();

  //Set the gridlines display style as Auto
  settings.DisplayGridLines = GridLinesDisplayStyle.Auto;

  //Initialize XlsIORenderer
  XlsIORenderer renderer = new XlsIORenderer();

  //Convert the Excel document to PDF with renderer settings
  PdfDocument document = renderer.ConvertToPDF(workbook, settings);

  //Save the PDF document
  document.Save("Output.pdf");
}
using (ExcelEngine excelEngine = new ExcelEngine())
{
  IApplication application = excelEngine.Excel;
  application.DefaultVersion = ExcelVersion.Excel2016;
  IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");

  //Initialize ExcelToPdfConverterSettings
  ExcelToPdfConverterSettings settings = new ExcelToPdfConverterSettings();

  //Set the gridlines display style as Auto
  settings.DisplayGridLines = GridLinesDisplayStyle.Auto;

  //Load the Excel document into ExcelToPdfConverter
  ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook);

  //Convert the Excel document to PDF with converter settings
  PdfDocument document = converter.Convert(settings);

  //Save the PDF document
  document.Save("Output.pdf");
}
Using excelEngine As ExcelEngine = New ExcelEngine()
  Dim application As IApplication = excelEngine.Excel
  application.DefaultVersion = ExcelVersion.Excel2016
  Dim workbook As IWorkbook = application.Workbooks.Open("Sample.xlsx")

  'Initialize ExcelToPdfConverterSettings
  Dim settings As ExcelToPdfConverterSettings = New ExcelToPdfConverterSettings()

  'Set the gridlines display style as Auto
  settings.DisplayGridLines = GridLinesDisplayStyle.Auto

  'Load the Excel document into ExcelToPdfConverter
  Dim converter As ExcelToPdfConverter = New ExcelToPdfConverter(workbook)

  'Convert the Excel document to PDF with converter settings
  Dim document As PdfDocument = converter.Convert(settings)

  'Save the PDF document
  document.Save("Output.pdf")
End Using

Invisible

When the display style is set to Invisible, gridlines are not rendered in the output PDF.

using (ExcelEngine excelEngine = new ExcelEngine())
{
  IApplication application = excelEngine.Excel;
  IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");

  //Initialize XlsIORendererSettings
  XlsIORendererSettings settings = new XlsIORendererSettings();

  //Set the gridlines display style as Invisible
  settings.DisplayGridLines = GridLinesDisplayStyle.Invisible;

  //Initialize XlsIORenderer
  XlsIORenderer renderer = new XlsIORenderer();

  //Convert the Excel document to PDF with renderer settings
  PdfDocument document = renderer.ConvertToPDF(workbook, settings);

  //Save the PDF document
  document.Save("Output.pdf");
}
using (ExcelEngine excelEngine = new ExcelEngine())
{
  IApplication application = excelEngine.Excel;
  application.DefaultVersion = ExcelVersion.Excel2016;
  IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");

  //Initialize ExcelToPdfConverterSettings
  ExcelToPdfConverterSettings settings = new ExcelToPdfConverterSettings();

  //Set the gridlines display style as Invisible
  settings.DisplayGridLines = GridLinesDisplayStyle.Invisible;

  //Load the Excel document into ExcelToPdfConverter
  ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook);

  //Convert the Excel document to PDF with converter settings
  PdfDocument document = converter.Convert(settings);

  //Save the PDF document
  document.Save("Output.pdf");
}
Using excelEngine As ExcelEngine = New ExcelEngine()
  Dim application As IApplication = excelEngine.Excel
  application.DefaultVersion = ExcelVersion.Excel2016
  Dim workbook As IWorkbook = application.Workbooks.Open("Sample.xlsx")

  'Initialize ExcelToPdfConverterSettings
  Dim settings As ExcelToPdfConverterSettings = New ExcelToPdfConverterSettings()

  'Set the gridlines display style as Invisible
  settings.DisplayGridLines = GridLinesDisplayStyle.Invisible

  'Load the Excel document into ExcelToPdfConverter
  Dim converter As ExcelToPdfConverter = New ExcelToPdfConverter(workbook)

  'Convert the Excel document to PDF with converter settings
  Dim document As PdfDocument = converter.Convert(settings)

  'Save the PDF document
  document.Save("Output.pdf")
End Using

Visible

When the display style is set to Visible, gridlines are rendered in the output PDF.

using (ExcelEngine excelEngine = new ExcelEngine())
{
	IApplication application = excelEngine.Excel;
	application.DefaultVersion = ExcelVersion.Xlsx;
	IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"));

	//Initialize XlsIORendererSettings
	XlsIORendererSettings settings = new XlsIORendererSettings();

	//Set the gridlines display style as Visible. Available options are Auto, Visible, Invisible
	settings.DisplayGridLines = GridLinesDisplayStyle.Visible;

	//Initialize XlsIORenderer
	XlsIORenderer renderer = new XlsIORenderer();

	//Convert the Excel document to PDF with renderer settings
	PdfDocument pdfDocument = renderer.ConvertToPDF(workbook, settings);

	#region Save
	//Saving the workbook
	pdfDocument.Save(Path.GetFullPath("Output/Gridlines.pdf"));
	#endregion
}
using (ExcelEngine excelEngine = new ExcelEngine())
{
  IApplication application = excelEngine.Excel;
  application.DefaultVersion = ExcelVersion.Excel2016;
  IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");

  //Initialize ExcelToPdfConverterSettings
  ExcelToPdfConverterSettings settings = new ExcelToPdfConverterSettings();

  //Set the gridlines display style as Visible
  settings.DisplayGridLines = GridLinesDisplayStyle.Visible;

  //Load the Excel document into ExcelToPdfConverter
  ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook);

  //Convert the Excel document to PDF with converter settings
  PdfDocument document = converter.Convert(settings);

  //Save the PDF document
  document.Save("Output.pdf");
}
Using excelEngine As ExcelEngine = New ExcelEngine()
  Dim application As IApplication = excelEngine.Excel
  application.DefaultVersion = ExcelVersion.Excel2016
  Dim workbook As IWorkbook = application.Workbooks.Open("Sample.xlsx")

  'Initialize ExcelToPdfConverterSettings
  Dim settings As ExcelToPdfConverterSettings = New ExcelToPdfConverterSettings()

  'Set the gridlines display style as Visible
  settings.DisplayGridLines = GridLinesDisplayStyle.Visible

  'Load the Excel document into ExcelToPdfConverter
  Dim converter As ExcelToPdfConverter = New ExcelToPdfConverter(workbook)

  'Convert the Excel document to PDF with converter settings
  Dim document As PdfDocument = converter.Convert(settings)

  'Save the PDF document
  document.Save("Output.pdf")
End Using

A complete working example to hide gridlines in Excel to PDF conversion in C# is present on this GitHub page.

Embed Fonts

When the Arial Unicode MS font is missing from the machine, Excel content is rendered incorrectly. Set EmbedFonts to true to embed the referenced fonts into the output PDF (default is false). Note that embedding fonts increases the output PDF size.

The following code snippet explains how to enable EmbedFonts property.

using (ExcelEngine excelEngine = new ExcelEngine())
{
	IApplication application = excelEngine.Excel;
	application.DefaultVersion = ExcelVersion.Xlsx;
	IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"));

	//Initialize XlsIORendererSettings
	XlsIORendererSettings settings = new XlsIORendererSettings();

	//Enable EmbedFonts
	settings.EmbedFonts = true;

	//Initialize XlsIORenderer
	XlsIORenderer renderer = new XlsIORenderer();

	//Convert the Excel document to PDF with renderer settings
	PdfDocument pdfDocument = renderer.ConvertToPDF(workbook, settings);

	#region Save
	//Saving the workbook
	pdfDocument.Save(Path.GetFullPath("Output/EmbedFonts.pdf"));
	#endregion
}
using (ExcelEngine excelEngine = new ExcelEngine())
{
  IApplication application = excelEngine.Excel;
  application.DefaultVersion = ExcelVersion.Excel2016;
  IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");

  //Initialize ExcelToPdfConverterSettings
  ExcelToPdfConverterSettings settings = new ExcelToPdfConverterSettings();

  //Enable EmbedFonts
  settings.EmbedFonts = true;

  //Load the Excel document into ExcelToPdfConverter
  ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook);

  //Convert the Excel document to PDF with converter settings
  PdfDocument document = converter.Convert(settings);

  //Save the PDF document
  document.Save("Output.pdf");
}
Using excelEngine As ExcelEngine = New ExcelEngine()
  Dim application As IApplication = excelEngine.Excel
  application.DefaultVersion = ExcelVersion.Excel2016
  Dim workbook As IWorkbook = application.Workbooks.Open("Sample.xlsx")

  'Initialize ExcelToPdfConverterSettings
  Dim settings As ExcelToPdfConverterSettings = New ExcelToPdfConverterSettings()

  'Enable EmbedFonts
  settings.EmbedFonts = True

  'Load the Excel document into ExcelToPdfConverter
  Dim converter As ExcelToPdfConverter = New ExcelToPdfConverter(workbook)

  'Convert the Excel document to PDF with converter settings
  Dim document As PdfDocument = converter.Convert(settings)

  'Save the PDF document
  document.Save("Output.pdf")
End Using

A complete working example to embed fonts in Excel to PDF conversion in C# is present on this GitHub page.

Export Bookmarks

The default value of the ExportBookmarks property is true, so workbook and worksheet bookmarks are exported to the PDF by default. Set it to false to skip the bookmarks during conversion.

The following code snippet explains how to disable ExportBookmarks property.

using (ExcelEngine excelEngine = new ExcelEngine())
{
	IApplication application = excelEngine.Excel;
	application.DefaultVersion = ExcelVersion.Xlsx;
	IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"));

	//Initialize XlsIORendererSettings
	XlsIORendererSettings settings = new XlsIORendererSettings();

	//Disable ExportBookmarks
	settings.ExportBookmarks = false;

	//Initialize XlsIORenderer
	XlsIORenderer renderer = new XlsIORenderer();

	//Convert the Excel document to PDF with renderer settings
	PdfDocument pdfDocument = renderer.ConvertToPDF(workbook, settings);

	#region Save
	//Saving the workbook
	pdfDocument.Save(Path.GetFullPath("Output/BookmarksInPDF.pdf"));
	#endregion
}
using (ExcelEngine excelEngine = new ExcelEngine())
{
  IApplication application = excelEngine.Excel;
  application.DefaultVersion = ExcelVersion.Excel2016;
  IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");

  //Initialize ExcelToPdfConverterSettings
  ExcelToPdfConverterSettings settings = new ExcelToPdfConverterSettings();

  //Disable ExportBookmarks
  settings.ExportBookmarks = false;

  //Load the Excel document into ExcelToPdfConverter
  ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook);

  //Convert the Excel document to PDF with converter settings
  PdfDocument document = converter.Convert(settings);

  //Save the PDF document
  document.Save("Output.pdf");
}
Using excelEngine As ExcelEngine = New ExcelEngine()
  Dim application As IApplication = excelEngine.Excel
  application.DefaultVersion = ExcelVersion.Excel2016
  Dim workbook As IWorkbook = application.Workbooks.Open("Sample.xlsx")

  'Initialize ExcelToPdfConverterSettings
  Dim settings As ExcelToPdfConverterSettings = New ExcelToPdfConverterSettings()

  'Disable ExportBookmarks
  settings.ExportBookmarks = False

  'Load the Excel document into ExcelToPdfConverter
  Dim converter As ExcelToPdfConverter = New ExcelToPdfConverter(workbook)

  'Convert the Excel document to PDF with converter settings
  Dim document As PdfDocument = converter.Convert(settings)

  'Save the PDF document
  document.Save("Output.pdf")
End Using

A complete working example to export bookmarks in Excel to PDF conversion in C# is present on this GitHub page.

Export Document Properties

Excel document properties will be exported to PDF document by default, in Excel to PDF conversion. This can be skipped by disabling the ExportDocumentProperties.

The following complete code snippet explains how to disable ExportDocumentProperties.

using (ExcelEngine excelEngine = new ExcelEngine())
{
	IApplication application = excelEngine.Excel;
	application.DefaultVersion = ExcelVersion.Xlsx;
	IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"));

	//Initialize XlsIORendererSettings
	XlsIORendererSettings settings = new XlsIORendererSettings();

	//Disable ExportDocumentProperties
	settings.ExportDocumentProperties = false;

	//Initialize XlsIORenderer
	XlsIORenderer renderer = new XlsIORenderer();

	//Convert the Excel document to PDF with renderer settings
	PdfDocument pdfDocument = renderer.ConvertToPDF(workbook, settings);

	#region Save
	//Saving the workbook
	pdfDocument.Save(Path.GetFullPath("Output/DocumentProperties.pdf"));
	#endregion
}
using (ExcelEngine excelEngine = new ExcelEngine())
{
  IApplication application = excelEngine.Excel;
  application.DefaultVersion = ExcelVersion.Excel2016;
  IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");

  //Initialize ExcelToPdfConverterSettings
  ExcelToPdfConverterSettings settings = new ExcelToPdfConverterSettings();

  //Disable ExportDocumentProperties
  settings.ExportDocumentProperties = false;

  //Load the Excel document into ExcelToPdfConverter
  ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook);

  //Convert the Excel document to PDF with converter settings
  PdfDocument document = converter.Convert(settings);

  //Save the PDF document
  document.Save("Output.pdf");
}
Using excelEngine As ExcelEngine = New ExcelEngine()
  Dim application As IApplication = excelEngine.Excel
  application.DefaultVersion = ExcelVersion.Excel2016
  Dim workbook As IWorkbook = application.Workbooks.Open("Sample.xlsx")

  'Initialize ExcelToPdfConverterSettings
  Dim settings As ExcelToPdfConverterSettings = New ExcelToPdfConverterSettings()

  'Disable ExportDocumentProperties
  settings.ExportDocumentProperties = False

  'Load the Excel document into ExcelToPdfConverter
  Dim converter As ExcelToPdfConverter = New ExcelToPdfConverter(workbook)

  'Convert the Excel document to PDF with converter settings
  Dim document As PdfDocument = converter.Convert(settings)

  'Save the PDF document
  document.Save("Output.pdf")
End Using

A complete working example to export document properties in Excel to PDF conversion in C# is present on this GitHub page.

Export Quality Image

The default value of ExportQualityImage is false. Set it to true to render images at higher DPI in the output PDF (at the cost of larger file size).

The following complete code snippet explains how to enable ExportQualityImage property.

using (ExcelEngine excelEngine = new ExcelEngine())
{
	IApplication application = excelEngine.Excel;
	application.DefaultVersion = ExcelVersion.Xlsx;
	IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"));

	//Initialize XlsIORendererSettings
	XlsIORendererSettings settings = new XlsIORendererSettings();

	//Enable ExportQualityImage
	settings.ExportQualityImage = true;

	//Initialize XlsIORenderer
	XlsIORenderer renderer = new XlsIORenderer();

	//Convert the Excel document to PDF with renderer settings
	PdfDocument pdfDocument = renderer.ConvertToPDF(workbook, settings);

	#region Save
	//Saving the workbook
	pdfDocument.Save(Path.GetFullPath("Output/QualityImageInPDF.pdf"));
	#endregion
}
using (ExcelEngine excelEngine = new ExcelEngine())
{
  IApplication application = excelEngine.Excel;
  application.DefaultVersion = ExcelVersion.Excel2016;
  IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");

  //Initialize ExcelToPdfConverterSettings
  ExcelToPdfConverterSettings settings = new ExcelToPdfConverterSettings();

  //Enable ExportQualityImage
  settings.ExportQualityImage = true;

  //Load the Excel document into ExcelToPdfConverter
  ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook);

  //Convert the Excel document to PDF with converter settings
  PdfDocument document = converter.Convert(settings);

  //Save the PDF document
  document.Save("Output.pdf");
}
Using excelEngine As ExcelEngine = New ExcelEngine()
  Dim application As IApplication = excelEngine.Excel
  application.DefaultVersion = ExcelVersion.Excel2016
  Dim workbook As IWorkbook = application.Workbooks.Open("Sample.xlsx")

  'Initialize ExcelToPdfConverterSettings
  Dim settings As ExcelToPdfConverterSettings = New ExcelToPdfConverterSettings()

  'Enable ExportQualityImage
  settings.ExportQualityImage = True

  'Load the Excel document into ExcelToPdfConverter
  Dim converter As ExcelToPdfConverter = New ExcelToPdfConverter(workbook)

  'Convert the Excel document to PDF with converter settings
  Dim document As PdfDocument = converter.Convert(settings)

  'Save the PDF document
  document.Save("Output.pdf")
End Using

A complete working example to export quality image in Excel to PDF conversion in C# is present on this GitHub page.

The HeaderFooterOption class exposes two properties: ShowHeader and ShowFooter.

Show Header

The worksheet header is rendered in the PDF by default. Set the ShowHeader property to false to hide it.

using (ExcelEngine excelEngine = new ExcelEngine())
{
  IApplication application = excelEngine.Excel;
  IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");

  //Initialize XlsIORendererSettings
  XlsIORendererSettings settings = new XlsIORendererSettings();

  //Disable ShowHeader
  settings.HeaderFooterOption.ShowHeader = false;

  //Initialize XlsIORenderer
  XlsIORenderer renderer = new XlsIORenderer();

  //Convert the Excel document to PDF with renderer settings
  PdfDocument document = renderer.ConvertToPDF(workbook, settings);

  //Save the PDF document
  document.Save("Output.pdf");
}
using (ExcelEngine excelEngine = new ExcelEngine())
{
  IApplication application = excelEngine.Excel;
  application.DefaultVersion = ExcelVersion.Excel2016;
  IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");

  //Initialize ExcelToPdfConverterSettings
  ExcelToPdfConverterSettings settings = new ExcelToPdfConverterSettings();

  //Disable ShowHeader
  settings.HeaderFooterOption.ShowHeader = false;

  //Load the Excel document into ExcelToPdfConverter
  ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook);

  //Convert the Excel document to PDF with converter settings
  PdfDocument document = converter.Convert(settings);

  //Save the PDF document
  document.Save("Output.pdf");
}
Using excelEngine As ExcelEngine = New ExcelEngine()
  Dim application As IApplication = excelEngine.Excel
  application.DefaultVersion = ExcelVersion.Excel2016
  Dim workbook As IWorkbook = application.Workbooks.Open("Sample.xlsx")

  'Initialize ExcelToPdfConverterSettings
  Dim settings As ExcelToPdfConverterSettings = New ExcelToPdfConverterSettings()

  'Disable ShowHeader
  settings.HeaderFooterOption.ShowHeader = False

  'Load the Excel document into ExcelToPdfConverter
  Dim converter As ExcelToPdfConverter = New ExcelToPdfConverter(workbook)

  'Convert the Excel document to PDF with converter settings
  Dim document As PdfDocument = converter.Convert(settings)

  'Save the PDF document
  document.Save("Output.pdf")
End Using

The worksheet footer is rendered in the PDF by default. Set the ShowFooter property to false to hide it.

using (ExcelEngine excelEngine = new ExcelEngine())
{
	IApplication application = excelEngine.Excel;
	application.DefaultVersion = ExcelVersion.Xlsx;
	IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"));

	//Initialize XlsIORendererSettings
	XlsIORendererSettings settings = new XlsIORendererSettings();

	//Disable ShowHeader
	settings.HeaderFooterOption.ShowHeader = false;

	//Enable ShowFooter
	settings.HeaderFooterOption.ShowFooter = true;

	//Initialize XlsIORenderer
	XlsIORenderer renderer = new XlsIORenderer();

	//Convert the Excel document to PDF with renderer settings
	PdfDocument pdfDocument = renderer.ConvertToPDF(workbook, settings);

	#region Save
	//Saving the workbook
	pdfDocument.Save(Path.GetFullPath("Output/HeaderFooterInPDF.pdf"));
	#endregion
}
using (ExcelEngine excelEngine = new ExcelEngine())
{
  IApplication application = excelEngine.Excel;
  application.DefaultVersion = ExcelVersion.Excel2016;
  IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");

  //Initialize ExcelToPdfConverterSettings
  ExcelToPdfConverterSettings settings = new ExcelToPdfConverterSettings();

  //Disable ShowFooter
  settings.HeaderFooterOption.ShowFooter = false;

  //Load the Excel document into ExcelToPdfConverter
  ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook);

  //Convert the Excel document to PDF with converter settings
  PdfDocument document = converter.Convert(settings);

  //Save the PDF document
  document.Save("Output.pdf");
}
Using excelEngine As ExcelEngine = New ExcelEngine()
  Dim application As IApplication = excelEngine.Excel
  application.DefaultVersion = ExcelVersion.Excel2016
  Dim workbook As IWorkbook = application.Workbooks.Open("Sample.xlsx")

  'Initialize ExcelToPdfConverterSettings
  Dim settings As ExcelToPdfConverterSettings = New ExcelToPdfConverterSettings()

  'Disable ShowFooter
  settings.HeaderFooterOption.ShowFooter = False

  'Load the Excel document into ExcelToPdfConverter
  Dim converter As ExcelToPdfConverter = New ExcelToPdfConverter(workbook)

  'Convert the Excel document to PDF with converter settings
  Dim document As PdfDocument = converter.Convert(settings)

  'Save the PDF document
  document.Save("Output.pdf")
End Using

A complete working example to show or hide header and footer in Excel to PDF conversion in C# is present on this GitHub page.

Convert Blank Page

Blank pages in the Excel document are rendered in the PDF by default. Set IsConvertBlankPage to false to skip them.

The following code snippet explains this.

using (ExcelEngine excelEngine = new ExcelEngine())
{
	IApplication application = excelEngine.Excel;
	application.DefaultVersion = ExcelVersion.Xlsx;
	IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"));

	//Initialize XlsIORendererSettings
	XlsIORendererSettings settings = new XlsIORendererSettings();

	//Disable IsConvertBlankPage
	settings.IsConvertBlankPage = false;

	//Initialize XlsIORenderer
	XlsIORenderer renderer = new XlsIORenderer();

	//Convert the Excel document to PDF with renderer settings
	PdfDocument pdfDocument = renderer.ConvertToPDF(workbook, settings);

	#region Save
	//Saving the workbook
	pdfDocument.Save(Path.GetFullPath("Output/BlankPageToPDF.pdf"));
	#endregion
}
using (ExcelEngine excelEngine = new ExcelEngine())
{
  IApplication application = excelEngine.Excel;
  application.DefaultVersion = ExcelVersion.Excel2016;
  IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");

  //Initialize ExcelToPdfConverterSettings
  ExcelToPdfConverterSettings settings = new ExcelToPdfConverterSettings();

  //Disable IsConvertBlankPage
  settings.IsConvertBlankPage = false;

  //Load the Excel document into ExcelToPdfConverter
  ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook);

  //Convert the Excel document to PDF with converter settings
  PdfDocument document = converter.Convert(settings);

  //Save the PDF document
  document.Save("Output.pdf");
}
Using excelEngine As ExcelEngine = New ExcelEngine()
  Dim application As IApplication = excelEngine.Excel
  application.DefaultVersion = ExcelVersion.Excel2016
  Dim workbook As IWorkbook = application.Workbooks.Open("Sample.xlsx")

  'Initialize ExcelToPdfConverterSettings
  Dim settings As ExcelToPdfConverterSettings = New ExcelToPdfConverterSettings()

  'Disable IsConvertBlankPage
  settings.IsConvertBlankPage = False

  'Load the Excel document into ExcelToPdfConverter
  Dim converter As ExcelToPdfConverter = New ExcelToPdfConverter(workbook)

  'Convert the Excel document to PDF with converter settings
  Dim document As PdfDocument = converter.Convert(settings)

  'Save the PDF document
  document.Save("Output.pdf")
End Using

A complete working example to convert blank page to PDF in C# is present on this GitHub page.

Convert Blank Sheet

Blank worksheets are rendered in the PDF by default. Set IsConvertBlankSheet to false to skip them.

The following code snippet explains this.

using (ExcelEngine excelEngine = new ExcelEngine())
{
	IApplication application = excelEngine.Excel;
	application.DefaultVersion = ExcelVersion.Xlsx;
	IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"));

	//Initialize XlsIORendererSettings
	XlsIORendererSettings settings = new XlsIORendererSettings();

	//Disable IsConvertBlankSheet
	settings.IsConvertBlankSheet = false;

	//Initialize XlsIORenderer
	XlsIORenderer renderer = new XlsIORenderer();

	//Convert the Excel document to PDF with renderer settings
	PdfDocument pdfDocument = renderer.ConvertToPDF(workbook, settings);

	#region Save
	//Saving the workbook
	pdfDocument.Save(Path.GetFullPath("Output/BlankSheetToPDF.pdf"));
	#endregion
}
using (ExcelEngine excelEngine = new ExcelEngine())
{
  IApplication application = excelEngine.Excel;
  application.DefaultVersion = ExcelVersion.Excel2016;
  IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");

  //Initialize ExcelToPdfConverterSettings
  ExcelToPdfConverterSettings settings = new ExcelToPdfConverterSettings();

  //Disable IsConvertBlankSheet
  settings.IsConvertBlankSheet = false;

  //Load the Excel document into ExcelToPdfConverter
  ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook);

  //Convert the Excel document to PDF with converter settings
  PdfDocument document = converter.Convert(settings);

  //Save the PDF document
  document.Save("Output.pdf");
}
Using excelEngine As ExcelEngine = New ExcelEngine()
  Dim application As IApplication = excelEngine.Excel
  application.DefaultVersion = ExcelVersion.Excel2016
  Dim workbook As IWorkbook = application.Workbooks.Open("Sample.xlsx")

  'Initialize ExcelToPdfConverterSettings
  Dim settings As ExcelToPdfConverterSettings = New ExcelToPdfConverterSettings()

  'Disable IsConvertBlankSheet
  settings.IsConvertBlankSheet = False

  'Load the Excel document into ExcelToPdfConverter
  Dim converter As ExcelToPdfConverter = New ExcelToPdfConverter(workbook)

  'Convert the Excel document to PDF with converter settings
  Dim document As PdfDocument = converter.Convert(settings)

  'Save the PDF document
  document.Save("Output.pdf")
End Using

A complete working example to convert blank sheet to PDF in C# is present on this GitHub page.

Layout Options

This property selects the page layout applied to the worksheet during Excel to PDF conversion. Six values are available on the LayoutOptions enumeration: Automatic, CustomScaling, FitAllColumnsOnOnePage, FitAllRowsOnOnePage, FitSheetOnOnePage, and NoScaling.

Value Effect on the output PDF
Automatic The converter picks the best fit. This is the default.
CustomScaling Uses the zoom value configured in the worksheet’s page setup.
FitAllColumnsOnOnePage All columns are rendered on a single PDF page.
FitAllRowsOnOnePage All rows are rendered on a single PDF page.
FitSheetOnOnePage Each worksheet is rendered on a single PDF page.
NoScaling Worksheets are printed at their actual size.

Automatic

Selecting Automatic under LayoutOptions lets the converter choose the best fit for the worksheet. Its default value is Automatic.

using (ExcelEngine excelEngine = new ExcelEngine())
{
	IApplication application = excelEngine.Excel;
	application.DefaultVersion = ExcelVersion.Xlsx;
	IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"));

	//Initialize XlsIORendererSettings
	XlsIORendererSettings settings = new XlsIORendererSettings();

	//Set layout option as Automatic
	settings.LayoutOptions = LayoutOptions.Automatic;

	//Initialize XlsIORenderer
	XlsIORenderer renderer = new XlsIORenderer();

	//Convert the Excel document to PDF with renderer settings
	PdfDocument pdfDocument = renderer.ConvertToPDF(workbook, settings);

	#region Save
	//Saving the workbook
	pdfDocument.Save(Path.GetFullPath("Output/Automatic.pdf"));
	#endregion
}
using (ExcelEngine excelEngine = new ExcelEngine())
{
  IApplication application = excelEngine.Excel;
  application.DefaultVersion = ExcelVersion.Excel2016;
  IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");

  //Initialize ExcelToPdfConverterSettings
  ExcelToPdfConverterSettings settings = new ExcelToPdfConverterSettings();

  //Set layout option as Automatic
  settings.LayoutOptions = LayoutOptions.Automatic;

  //Load the Excel document into ExcelToPdfConverter
  ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook);

  //Convert the Excel document to PDF with converter settings
  PdfDocument document = converter.Convert(settings);

  //Save the PDF document
  document.Save("Output.pdf");
}
Using excelEngine As ExcelEngine = New ExcelEngine()
  Dim application As IApplication = excelEngine.Excel
  application.DefaultVersion = ExcelVersion.Excel2016
  Dim workbook As IWorkbook = application.Workbooks.Open("Sample.xlsx")

  'Initialize ExcelToPdfConverterSettings
  Dim settings As ExcelToPdfConverterSettings = New ExcelToPdfConverterSettings()

  'Set layout option as Automatic
  settings.LayoutOptions = LayoutOptions.Automatic

  'Load the Excel document into ExcelToPdfConverter
  Dim converter As ExcelToPdfConverter = New ExcelToPdfConverter(workbook)

  'Convert the Excel document to PDF with converter settings
  Dim document As PdfDocument = converter.Convert(settings)

  'Save the PDF document
  document.Save("Output.pdf")
End Using

A complete working example to convert Excel to PDF with automatic layout in C# is present on this GitHub page.

Custom Scaling

Selecting CustomScaling under LayoutOptions uses the zoom value configured in the worksheet’s page setup.

using (ExcelEngine excelEngine = new ExcelEngine())
{
	IApplication application = excelEngine.Excel;
	application.DefaultVersion = ExcelVersion.Xlsx;
	IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"));

	//Initialize XlsIORendererSettings
	XlsIORendererSettings settings = new XlsIORendererSettings();

	//Set layout option as CustomScaling
	settings.LayoutOptions = LayoutOptions.CustomScaling;

	//Initialize XlsIORenderer
	XlsIORenderer renderer = new XlsIORenderer();

	//Convert the Excel document to PDF with renderer settings
	PdfDocument pdfDocument = renderer.ConvertToPDF(workbook, settings);

	#region Save
	//Saving the workbook
	pdfDocument.Save(Path.GetFullPath("Output/CustomScaling.pdf"));
	#endregion
}
using (ExcelEngine excelEngine = new ExcelEngine())
{
  IApplication application = excelEngine.Excel;
  application.DefaultVersion = ExcelVersion.Excel2016;
  IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");

  //Initialize ExcelToPdfConverterSettings
  ExcelToPdfConverterSettings settings = new ExcelToPdfConverterSettings();

  //Set layout option as CustomScaling
  settings.LayoutOptions = LayoutOptions.CustomScaling;

  //Load the Excel document into ExcelToPdfConverter
  ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook);

  //Convert the Excel document to PDF with converter settings
  PdfDocument document = converter.Convert(settings);

  //Save the PDF document
  document.Save("Output.pdf");
}
Using excelEngine As ExcelEngine = New ExcelEngine()
  Dim application As IApplication = excelEngine.Excel
  application.DefaultVersion = ExcelVersion.Excel2016
  Dim workbook As IWorkbook = application.Workbooks.Open("Sample.xlsx")

  'Initialize ExcelToPdfConverterSettings
  Dim settings As ExcelToPdfConverterSettings = New ExcelToPdfConverterSettings()

  'Set layout option as CustomScaling
  settings.LayoutOptions = LayoutOptions.CustomScaling

  'Load the Excel document into ExcelToPdfConverter
  Dim converter As ExcelToPdfConverter = New ExcelToPdfConverter(workbook)

  'Convert the Excel document to PDF with converter settings
  Dim document As PdfDocument = converter.Convert(settings)

  'Save the PDF document
  document.Save("Output.pdf")
End Using

A complete working example to convert Excel to PDF with custom scaling in C# is present on this GitHub page.

Fit All Columns On One Page

Selecting FitAllColumnsOnOnePage under LayoutOptions renders all columns in Excel worksheet into single PDF page. The following code snippet explains how to select the layout option as FitAllColumnsOnOnePage.

using (ExcelEngine excelEngine = new ExcelEngine())
{
	IApplication application = excelEngine.Excel;
	application.DefaultVersion = ExcelVersion.Xlsx;
	IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"));

	//Initialize XlsIORendererSettings
	XlsIORendererSettings settings = new XlsIORendererSettings();

	//Set layout option as FitAllColumnsOnOnePage
	settings.LayoutOptions = LayoutOptions.FitAllColumnsOnOnePage;

	//Initialize XlsIORenderer
	XlsIORenderer renderer = new XlsIORenderer();

	//Convert the Excel document to PDF with renderer settings
	PdfDocument pdfDocument = renderer.ConvertToPDF(workbook, settings);

	#region Save
	//Saving the workbook
	pdfDocument.Save(Path.GetFullPath("Output/FitAllColumnsOnOnePage.pdf"));
	#endregion
}
using (ExcelEngine excelEngine = new ExcelEngine())
{
  IApplication application = excelEngine.Excel;
  application.DefaultVersion = ExcelVersion.Excel2016;
  IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");

  //Initialize ExcelToPdfConverterSettings
  ExcelToPdfConverterSettings settings = new ExcelToPdfConverterSettings();

  //Set layout option as FitAllColumnsOnOnePage
  settings.LayoutOptions = LayoutOptions.FitAllColumnsOnOnePage;

  //Load the Excel document into ExcelToPdfConverter
  ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook);

  //Convert the Excel document to PDF with converter settings
  PdfDocument document = converter.Convert(settings);

  //Save the PDF document
  document.Save("Output.pdf");
}
Using excelEngine As ExcelEngine = New ExcelEngine()
  Dim application As IApplication = excelEngine.Excel
  application.DefaultVersion = ExcelVersion.Excel2016
  Dim workbook As IWorkbook = application.Workbooks.Open("Sample.xlsx")

  'Initialize ExcelToPdfConverterSettings
  Dim settings As ExcelToPdfConverterSettings = New ExcelToPdfConverterSettings()

  'Set layout option as FitAllColumnsOnOnePage
  settings.LayoutOptions = LayoutOptions.FitAllColumnsOnOnePage

  'Load the Excel document into ExcelToPdfConverter
  Dim converter As ExcelToPdfConverter = New ExcelToPdfConverter(workbook)

  'Convert the Excel document to PDF with converter settings
  Dim document As PdfDocument = converter.Convert(settings)

  'Save the PDF document
  document.Save("Output.pdf")
End Using

A complete working example to convert Excel to PDF with fit all columns on one page in C# is present on this GitHub page.

Fit All Rows On One Page

Selecting FitAllRowsOnOnePage under LayoutOptions renders all rows in Excel worksheet into single PDF page. The following code snippet explains how to select the layout option as FitAllRowsOnOnePage.

using (ExcelEngine excelEngine = new ExcelEngine())
{
	IApplication application = excelEngine.Excel;
	application.DefaultVersion = ExcelVersion.Xlsx;
	IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"));

	//Initialize XlsIORendererSettings
	XlsIORendererSettings settings = new XlsIORendererSettings();

	//Set layout option as FitAllRowsOnOnePage
	settings.LayoutOptions = LayoutOptions.FitAllRowsOnOnePage;

	//Initialize XlsIORenderer
	XlsIORenderer renderer = new XlsIORenderer();

	//Convert the Excel document to PDF with renderer settings
	PdfDocument pdfDocument = renderer.ConvertToPDF(workbook, settings);

	#region Save
	//Saving the workbook
	pdfDocument.Save(Path.GetFullPath("Output/FitAllRowsOnOnePage.pdf"));
	#endregion
}
using (ExcelEngine excelEngine = new ExcelEngine())
{
  IApplication application = excelEngine.Excel;
  application.DefaultVersion = ExcelVersion.Excel2016;
  IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");

  //Initialize ExcelToPdfConverterSettings
  ExcelToPdfConverterSettings settings = new ExcelToPdfConverterSettings();

  //Set layout option as FitAllRowsOnOnePage
  settings.LayoutOptions = LayoutOptions.FitAllRowsOnOnePage;

  //Load the Excel document into ExcelToPdfConverter
  ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook);

  //Convert the Excel document to PDF with converter settings
  PdfDocument document = converter.Convert(settings);

  //Save the PDF document
  document.Save("Output.pdf");
}
Using excelEngine As ExcelEngine = New ExcelEngine()
  Dim application As IApplication = excelEngine.Excel
  application.DefaultVersion = ExcelVersion.Excel2016
  Dim workbook As IWorkbook = application.Workbooks.Open("Sample.xlsx")

  'Initialize ExcelToPdfConverterSettings
  Dim settings As ExcelToPdfConverterSettings = New ExcelToPdfConverterSettings()

  'Set layout option as FitAllRowsOnOnePage
  settings.LayoutOptions = LayoutOptions.FitAllRowsOnOnePage

  'Load the Excel document into ExcelToPdfConverter
  Dim converter As ExcelToPdfConverter = New ExcelToPdfConverter(workbook)

  'Convert the Excel document to PDF with converter settings
  Dim document As PdfDocument = converter.Convert(settings)

  'Save the PDF document
  document.Save("Output.pdf")
End Using

A complete working example to convert Excel to PDF with fit all rows on one page in C# is present on this GitHub page.

Fit Sheet On One Page

Selecting FitSheetOnOnePage under LayoutOptions renders each worksheet on a single PDF page.

using (ExcelEngine excelEngine = new ExcelEngine())
{
	IApplication application = excelEngine.Excel;
	application.DefaultVersion = ExcelVersion.Xlsx;
	IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"));

	//Initialize XlsIORendererSettings
	XlsIORendererSettings settings = new XlsIORendererSettings();

	//Set layout option as FitSheetOnOnePage
	settings.LayoutOptions = LayoutOptions.FitSheetOnOnePage;

	//Initialize XlsIORenderer
	XlsIORenderer renderer = new XlsIORenderer();

	//Convert the Excel document to PDF with renderer settings
	PdfDocument pdfDocument = renderer.ConvertToPDF(workbook, settings);

	#region Save
	//Saving the workbook
	pdfDocument.Save(Path.GetFullPath("Output/FitSheetOnOnePage.pdf"));
	#endregion
}
using (ExcelEngine excelEngine = new ExcelEngine())
{
  IApplication application = excelEngine.Excel;
  application.DefaultVersion = ExcelVersion.Excel2016;
  IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");

  //Initialize ExcelToPdfConverterSettings
  ExcelToPdfConverterSettings settings = new ExcelToPdfConverterSettings();

  //Set layout option as FitSheetOnOnePage
  settings.LayoutOptions = LayoutOptions.FitSheetOnOnePage;

  //Load the Excel document into ExcelToPdfConverter
  ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook);

  //Convert the Excel document to PDF with converter settings
  PdfDocument document = converter.Convert(settings);

  //Save the PDF document
  document.Save("Output.pdf");
}
Using excelEngine As ExcelEngine = New ExcelEngine()
  Dim application As IApplication = excelEngine.Excel
  application.DefaultVersion = ExcelVersion.Excel2016
  Dim workbook As IWorkbook = application.Workbooks.Open("Sample.xlsx")

  'Initialize ExcelToPdfConverterSettings
  Dim settings As ExcelToPdfConverterSettings = New ExcelToPdfConverterSettings()

  'Set layout option as FitSheetOnOnePage
  settings.LayoutOptions = LayoutOptions.FitSheetOnOnePage

  'Load the Excel document into ExcelToPdfConverter
  Dim converter As ExcelToPdfConverter = New ExcelToPdfConverter(workbook)

  'Convert the Excel document to PDF with converter settings
  Dim document As PdfDocument = converter.Convert(settings)

  'Save the PDF document
  document.Save("Output.pdf")
End Using

A complete working example to convert Excel to PDF with fit sheet on one page in C# is present on this GitHub page.

No Scaling

Selecting NoScaling under LayoutOptions prints the worksheets at their actual size. The following code snippet explains how to select the layout option as NoScaling.

using (ExcelEngine excelEngine = new ExcelEngine())
{
	IApplication application = excelEngine.Excel;
	application.DefaultVersion = ExcelVersion.Xlsx;
	IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"));

	//Initialize XlsIORendererSettings
	XlsIORendererSettings settings = new XlsIORendererSettings();

	//Set layout option as NoScaling
	settings.LayoutOptions = LayoutOptions.NoScaling;

	//Initialize XlsIORenderer
	XlsIORenderer renderer = new XlsIORenderer();

	//Convert the Excel document to PDF with renderer settings
	PdfDocument pdfDocument = renderer.ConvertToPDF(workbook, settings);

	#region Save
	//Saving the workbook
	pdfDocument.Save(Path.GetFullPath("Output/NoScaling.pdf"));
	#endregion
}
using (ExcelEngine excelEngine = new ExcelEngine())
{
  IApplication application = excelEngine.Excel;
  application.DefaultVersion = ExcelVersion.Excel2016;
  IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");

  //Initialize ExcelToPdfConverterSettings
  ExcelToPdfConverterSettings settings = new ExcelToPdfConverterSettings();

  //Set layout option as NoScaling
  settings.LayoutOptions = LayoutOptions.NoScaling;

  //Load the Excel document into ExcelToPdfConverter
  ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook);

  //Convert the Excel document to PDF with converter settings
  PdfDocument document = converter.Convert(settings);

  //Save the PDF document
  document.Save("Output.pdf");
}
Using excelEngine As ExcelEngine = New ExcelEngine()
  Dim application As IApplication = excelEngine.Excel
  application.DefaultVersion = ExcelVersion.Excel2016
  Dim workbook As IWorkbook = application.Workbooks.Open("Sample.xlsx")

  'Initialize ExcelToPdfConverterSettings
  Dim settings As ExcelToPdfConverterSettings = New ExcelToPdfConverterSettings()

  'Set layout option as NoScaling
  settings.LayoutOptions = LayoutOptions.NoScaling

  'Load the Excel document into ExcelToPdfConverter
  Dim converter As ExcelToPdfConverter = New ExcelToPdfConverter(workbook)

  'Convert the Excel document to PDF with converter settings
  Dim document As PdfDocument = converter.Convert(settings)

  'Save the PDF document
  document.Save("Output.pdf")
End Using

A complete working example to convert Excel to PDF with no scaling in C# is present on this GitHub page.

PDF Conformance Level

Excel to PDF converter settings allow you to set the PDF conformance level. XlsIO currently supports the following conformances:

  • PDF/A-1b — for long-term archiving.
  • PDF/X-1a — for print production workflows.

NOTE

NOTE: For more information about PDF conformance, see Working with PDF Conformance. The Pdf_X1A2001 value is not supported on .NET Standard (use the .NET Framework ExcelToPdfConverter or the cross-platform XlsIORenderer with the *.NET NuGet package instead).

The following code illustrates how to set the PdfConformanceLevel while converting an Excel workbook to PDF.

using (ExcelEngine excelEngine = new ExcelEngine())
{
	IApplication application = excelEngine.Excel;
	application.DefaultVersion = ExcelVersion.Xlsx;
	IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"));

	//Initialize XlsIO renderer.
	XlsIORenderer renderer = new XlsIORenderer();

	//Initialize XlsIO renderer settings
	XlsIORendererSettings settings = new XlsIORendererSettings();

	// Set the conformance for PDF/A-1b conversion
	settings.PdfConformanceLevel = PdfConformanceLevel.Pdf_A1B;

	//Convert Excel document into PDF document 
	PdfDocument pdfDocument = renderer.ConvertToPDF(workbook, settings);

	#region Save
	//Saving the workbook
	pdfDocument.Save(Path.GetFullPath("Output/PDFConformance.pdf"));
	#endregion
}
using (ExcelEngine excelEngine = new ExcelEngine())
{
  IApplication application = excelEngine.Excel;
  application.DefaultVersion = ExcelVersion.Excel2013;
  IWorkbook workbook = application.Workbooks.Open("Sample.xlsx", ExcelOpenType.Automatic);

  //Open the Excel document to Convert
  ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook);

  //Initialize Excel to PDF converter settings
  ExcelToPdfConverterSettings settings = new ExcelToPdfConverterSettings();

  // Set the conformance for PDF/A-1b conversion
  settings.PdfConformanceLevel = PdfConformanceLevel.Pdf_A1B;

  //Convert Excel document into PDF document
  PdfDocument pdfDocument = converter.Convert(settings);

  //Save the PDF file
  pdfDocument.Save("ExcelToPDF.pdf");
}
Using excelEngine As ExcelEngine = New ExcelEngine()
  Dim application As IApplication = excelEngine.Excel
  application.DefaultVersion = ExcelVersion.Excel2013
  Dim workbook As IWorkbook = application.Workbooks.Open("Sample.xlsx", ExcelOpenType.Automatic)

  'Open the Excel document to convert
  Dim converter As ExcelToPdfConverter = New ExcelToPdfConverter(workbook)

  'Initialize Excel to PDF converter settings
  Dim settings As ExcelToPdfConverterSettings = New ExcelToPdfConverterSettings()

  'Set the conformance for PDF/A-1b conversion
  settings.PdfConformanceLevel = PdfConformanceLevel.Pdf_A1B

  'Convert Excel document into PDF document
  Dim pdfDocument As PdfDocument = converter.Convert(settings)

  'Save the PDF file
  pdfDocument.Save("ExcelToPDF.pdf")
End Using

A complete working example to convert Excel to PDF with PDF conformance in C# is present on this GitHub page.

Template Document

TemplateDocument property helps to render multiple files into single PDF document.

Convert multiple Excel files into a single PDF document

The following complete code snippet explains how to convert two Excel documents into a single PDF document using TemplateDocument property.

using (ExcelEngine excelEngine = new ExcelEngine())
{
	IApplication application = excelEngine.Excel;
	application.DefaultVersion = ExcelVersion.Xlsx;
	IWorkbook workbook1 = application.Workbooks.Open(Path.GetFullPath(@"Data/Template1.xlsx"));

	IWorkbook workbook2 = application.Workbooks.Open(Path.GetFullPath(@"Data/Template2.xlsx"));

	//Initialize XlsIORenderer
	XlsIORenderer renderer = new XlsIORenderer();

	//Convert the first Excel document to PDF
	PdfDocument document = renderer.ConvertToPDF(workbook1);

	//Initialize XlsIORendererSettings
	XlsIORendererSettings settings = new XlsIORendererSettings();

	//Set the document as TemplateDocument
	settings.TemplateDocument = document;

	//Convert the second Excel document to PDF with renderer settings
	PdfDocument newDocument = renderer.ConvertToPDF(workbook2, settings);

	#region Save
	//Saving the workbook
	newDocument.Save(Path.GetFullPath("Output/MultipleExcelToPDF.pdf"));
	#endregion
}
using (ExcelEngine excelEngine = new ExcelEngine())
{
  IApplication application = excelEngine.Excel;
  application.DefaultVersion = ExcelVersion.Excel2016;
  IWorkbook workbook1 = application.Workbooks.Open("Sample1.xlsx");
  IWorkbook workbook2 = application.Workbooks.Open("Sample2.xlsx");

  //Load the Excel documents into ExcelToPdfConverter
  ExcelToPdfConverter converter1 = new ExcelToPdfConverter(workbook1);
  ExcelToPdfConverter converter2 = new ExcelToPdfConverter(workbook2);

  //Convert the first Excel document to PDF
  PdfDocument document = converter1.Convert();

  //Initialize ExcelToPdfConverterSettings
  ExcelToPdfConverterSettings settings = new ExcelToPdfConverterSettings();

  //Set the document as TemplateDocument
  settings.TemplateDocument = document;

  //Create a new PDF document and convert the second Excel document with settings
  PdfDocument newDocument = new PdfDocument();
  newDocument = converter2.Convert(settings);

  //Save the new PDF Document
  newDocument.Save("Output.pdf");
}
Using excelEngine As ExcelEngine = New ExcelEngine()
  Dim application As IApplication = excelEngine.Excel
  application.DefaultVersion = ExcelVersion.Excel2016
  Dim workbook1 As IWorkbook = application.Workbooks.Open("Sample1.xlsx")
  Dim workbook2 As IWorkbook = application.Workbooks.Open("Sample2.xlsx")

  'Load the Excel documents into ExcelToPdfConverter
  Dim converter1 As ExcelToPdfConverter = New ExcelToPdfConverter(workbook1)
  Dim converter2 As ExcelToPdfConverter = New ExcelToPdfConverter(workbook2)

  'Convert the first Excel document to PDF
  Dim document As PdfDocument = converter1.Convert

  'Initialize ExcelToPdfConverterSettings
  Dim settings As ExcelToPdfConverterSettings = New ExcelToPdfConverterSettings()

  'Set the document as TemplateDocument
  settings.TemplateDocument = document

  'Create a new PDF document and convert the second Excel document with settings
  Dim newDocument As PdfDocument = New PdfDocument
  newDocument = converter2.Convert(settings)

  'Save the PDF document
  newDocument.Save("Output.pdf")
End Using

A complete working example to convert multiple workbooks to PDF in C# is present on this GitHub page.

Convert selected worksheets into a single PDF document

By using the TemplateDocument property, multiple worksheets or selected worksheets can be converted into single PDF document. The following code snippet explains how to convert selected sheets into a single PDF document.

using (ExcelEngine excelEngine = new ExcelEngine())
{
	IApplication application = excelEngine.Excel;
	application.DefaultVersion = ExcelVersion.Xlsx;

	//Open an Excel document
	IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"));

	//Get the first worksheet
	IWorksheet worksheet1 = workbook.Worksheets[0];

	//Initialize XlsIORenderer
	XlsIORenderer renderer = new XlsIORenderer();

	//Initailize PdfDocument and convert first worksheet to PDF
	PdfDocument document = renderer.ConvertToPDF(worksheet1);

	//Initailize ExcelToPdfConverterSettings
	XlsIORendererSettings settings = new XlsIORendererSettings();

	//Set the PdfDocument to TemplateDocument in ExcelToPdfConverterSettings
	settings.TemplateDocument = document;

	//Get the third worksheet
	IWorksheet worksheet3 = workbook.Worksheets[2];

	//Initailize new PdfDocument and convert third worksheet to PDF with settings
	PdfDocument newDocument = renderer.ConvertToPDF(worksheet3, settings);

	#region Save
	//Saving the workbook
	newDocument.Save(Path.GetFullPath("Output/SelectedSheetsToPDF.pdf"));
	#endregion
}
using (ExcelEngine excelEngine = new ExcelEngine())
{
  IApplication application = excelEngine.Excel;
  application.DefaultVersion = ExcelVersion.Excel2013;

  //Open an Excel document
  IWorkbook workbook = application.Workbooks.Open("Sample.xlsx", ExcelOpenType.Automatic);

  //Get the first worksheet
  IWorksheet worksheet1 = workbook.Worksheets[0];

  //Load the first worksheet into ExcelToPdfConverter
  ExcelToPdfConverter converter1 = new ExcelToPdfConverter(worksheet1);

  //Convert the first worksheet; the result becomes the TemplateDocument for the next conversion.
  PdfDocument document = converter1.Convert();

  //Initailize ExcelToPdfConverterSettings
  ExcelToPdfConverterSettings settings = new ExcelToPdfConverterSettings();

  //Set the PdfDocument to TemplateDocument in ExcelToPdfConverterSettings
  settings.TemplateDocument = document;

  //Get the third worksheet
  IWorksheet worksheet3 = workbook.Worksheets[2];

  //Load the third worksheet into ExcelToPdfConverter
  ExcelToPdfConverter converter2 = new ExcelToPdfConverter(worksheet3);

  //Convert the worksheet with settings
  document = converter2.Convert(settings);

  //Save the PdfDocument
  document.Save("Output.pdf");
}
Using excelEngine As ExcelEngine = New ExcelEngine()
  Dim application As IApplication = excelEngine.Excel
  application.DefaultVersion = ExcelVersion.Excel2013

  'Open an Excel document
  Dim workbook As IWorkbook = application.Workbooks.Open("Sample.xlsx")

  'Get the first worksheet
  Dim worksheet1 As IWorksheet = workbook.Worksheets(0)

  'Load the first worksheet into ExcelToPdfConverter
  Dim converter1 As ExcelToPdfConverter = New ExcelToPdfConverter(worksheet1)

  'Convert the first worksheet; the result becomes the TemplateDocument for the next conversion.
  Dim document As PdfDocument = converter1.Convert()

  'Initailize ExcelToPdfConverterSettings
  Dim settings As ExcelToPdfConverterSettings = New ExcelToPdfConverterSettings()

  'Set the PdfDocument to TemplateDocument in ExcelToPdfConverterSettings
  settings.TemplateDocument = document

  'Get the third worksheet
  Dim worksheet3 As IWorksheet = workbook.Worksheets(2)

  'Load the third worksheet into ExcelToPdfConverter
  Dim converter2 As ExcelToPdfConverter = New ExcelToPdfConverter(worksheet3)

  'Convert the worksheet with settings
  document = converter2.Convert(settings)

  'Save the PdfDocument
  document.Save("Output.pdf")
End Using

A complete working example to convert selected worksheets to PDF in C# is present on this GitHub page.

Tagged PDF

An accessible tagged PDF includes structured tags for elements like text, tables, and images, enhancing accessibility and navigation. These tags ensure that users who rely on assistive technologies can effectively read and interact with the PDF content, meeting the accessibility requirements outlined by Section 508 and PDF/UA. By default, the output PDF is not tagged; set the AutoTag property to true to enable tagging.

The following complete code snippet explains how to preserve PDF document tags using AutoTag property while converting an Excel document to PDF.

using (ExcelEngine excelEngine = new ExcelEngine())
{
  IApplication application = excelEngine.Excel;
  application.DefaultVersion = ExcelVersion.Xlsx;
  IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"));

  //Initialize XlsIORendererSettings
  XlsIORendererSettings settings = new XlsIORendererSettings();
   
  //Set AutoTag to true to create a tagged PDF
  settings.AutoTag = true;

  //Initialize XlsIORenderer
  XlsIORenderer renderer = new XlsIORenderer();

  //Convert the Excel document to PDF with renderer settings
  PdfDocument pdfDocument = renderer.ConvertToPDF(workbook, settings);

  //Save the PDF document
  pdfDocument.Save("Output.pdf");
}
using (ExcelEngine excelEngine = new ExcelEngine())
{
  IApplication application = excelEngine.Excel;
  application.DefaultVersion = ExcelVersion.Xlsx;
  FileStream inputStream = new FileStream("../../Data/InputTemplate.xlsx", FileMode.Open, FileAccess.Read);
  IWorkbook workbook = application.Workbooks.Open(inputStream);

  //Initialize ExcelToPdfConverterSettings
  ExcelToPdfConverterSettings settings = new ExcelToPdfConverterSettings();

  //Set AutoTag to true to create a tagged PDF
  settings.AutoTag = true;

  //Initialize ExcelToPdfConverter
  ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook);

  //Convert the Excel document to PDF with converter settings
  PdfDocument pdfDocument = converter.Convert(settings);

  //Save the PDF document
  pdfDocument.Save("Output.pdf");    
}
Using excelEngine As ExcelEngine = New ExcelEngine()
  Dim application As IApplication = excelEngine.Excel
  application.DefaultVersion = ExcelVersion.Xlsx
  Dim inputStream As FileStream = New FileStream("../../Data/InputTemplate.xlsx", FileMode.Open, FileAccess.Read)
  Dim workbook As IWorkbook = application.Workbooks.Open(inputStream)

  'Initialize ExcelToPdfConverterSettings
  Dim settings As ExcelToPdfConverterSettings = New ExcelToPdfConverterSettings()

  'Set AutoTag to true to create a tagged PDF
  settings.AutoTag = True

  'Initialize ExcelToPdfConverter
  Dim converter As ExcelToPdfConverter = New ExcelToPdfConverter(workbook)

  'Convert the Excel document to PDF with converter settings
  Dim pdfDocument As PdfDocument = converter.Convert(settings)

  'Save the PDF document
  pdfDocument.Save("Output.pdf")
End Using

Throw When Excel File Is Empty

The default value of ThrowWhenExcelFileIsEmpty is false; with the default value, an empty workbook is converted to a PDF without any exception. When set to true, the converter throws an ExcelToPdfConverterException if the workbook has no worksheets. Catch this exception at the call site to handle the empty-workbook case.

The following code snippet explains this.

using (ExcelEngine excelEngine = new ExcelEngine())
{
	IApplication application = excelEngine.Excel;
	IWorkbook workbook = application.Workbooks.Create(1);

	//Initialize XlsIORendererSettings
	XlsIORendererSettings settings = new XlsIORendererSettings();

	//Enabling ThrowWhenExcelFileIsEmpty throws exception
	settings.ThrowWhenExcelFileIsEmpty = true;

	//Initialize XlsIORenderer
	XlsIORenderer renderer = new XlsIORenderer();

	//Convert the Excel document to PDF with renderer settings
	PdfDocument pdfDocument = renderer.ConvertToPDF(workbook, settings);

	#region Save
	//Saving the workbook
	pdfDocument.Save(Path.GetFullPath("Output/EmptyExcelToPDF.pdf"));
	#endregion
}
using (ExcelEngine excelEngine = new ExcelEngine())
{
  IApplication application = excelEngine.Excel;
  application.DefaultVersion = ExcelVersion.Excel2016;
  IWorkbook workbook = application.Workbooks.Create(1);

  //Initialize ExcelToPdfConverterSettings
  ExcelToPdfConverterSettings settings = new ExcelToPdfConverterSettings();

  //Enabling ThrowWhenExcelFileIsEmpty throws exception
  settings.ThrowWhenExcelFileIsEmpty = true;

  //Load the Excel document into ExcelToPdfConverter
  ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook);

  //Convert the Excel document to PDF with converter settings
  PdfDocument document = converter.Convert(settings);

  //Save the PDF document
  document.Save("Output.pdf");
}
Using excelEngine As ExcelEngine = New ExcelEngine()
  Dim application As IApplication = excelEngine.Excel
  application.DefaultVersion = ExcelVersion.Excel2016
  Dim workbook As IWorkbook = application.Workbooks.Create(1)

  'Initialize ExcelToPdfConverterSettings
  Dim settings As ExcelToPdfConverterSettings = New ExcelToPdfConverterSettings()

  'Enabling ThrowWhenExcelFileIsEmpty throws exception
  settings.ThrowWhenExcelFileIsEmpty = True

  'Load the Excel document into ExcelToPdfConverter
  Dim converter As ExcelToPdfConverter = New ExcelToPdfConverter(workbook)

  'Convert the Excel document to PDF with converter settings
  Dim document As PdfDocument = converter.Convert(settings)

  'Save the PDF document
  document.Save("Output.pdf")
End Using

A complete working example to through exception when file is empty in Excel to PDF in C# is present on this GitHub page.

Capture Warnings in Excel-to-PDF Conversion

XlsIO intentionally skips unsupported elements and substitutes unsupported fonts. The unsupported elements and substituted fonts are surfaced as warnings, so you can choose whether to continue or stop the conversion.

It is recommended to implement the IWarning interface in a supporting class. The interface exposes the following members:

Member Type Description
Type WarningType The element that failed to convert.
Description string A human-readable description of the failed element.
Cancel bool Set to true to stop the conversion when the warning is raised; false (default) to continue.

NOTE

Currently, warnings are captured only for elements that are supported during Excel document creation but not during Excel to PDF conversion. Features that are unsupported during Excel document creation itself are not captured by XlsIO.

The following code snippet shows how to capture warnings during Excel-to-PDF conversion.

using System.IO;
using Syncfusion.XlsIO;
using Syncfusion.XlsIORenderer;
using Syncfusion.Pdf;

namespace Warnings
{
    class Program
    {
        static void Main(string[] args)
        {
            using (ExcelEngine excelEngine = new ExcelEngine())
            {
                IApplication application = excelEngine.Excel;
                application.DefaultVersion = ExcelVersion.Xlsx;
                //Open the Excel document to convert.
                IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"));

                //Initialize warning class to capture warnings during the conversion.
                Warning warning = new Warning();

                //Initialize XlsIO renderer.
                XlsIORenderer renderer = new XlsIORenderer();

                //Initialize XlsIO renderer settings.
                XlsIORendererSettings settings = new XlsIORendererSettings();

                //Set the warning class that is implemented.
                settings.Warning = warning;

                //Convert Excel document into PDF document.
                PdfDocument pdfDocument = renderer.ConvertToPDF(workbook, settings);

                //If conversion process canceled null returned.
                if (pdfDocument != null)
                {
                    #region Save
                    //Saving the workbook
                    pdfDocument.Save(Path.GetFullPath("Output/ExceltoPDF.pdf"));
                    #endregion
                }
            }
        }
    }
    public class Warning : IWarning
    {
        public void ShowWarning(WarningInfo warning)
        {
            //Cancel the converion process if the warning type is FillPattern.
            if (warning.Type == WarningType.FillPattern)
                Cancel = true;

            //To view or log the warning, you can make use of warning.Description.
        }
        public bool Cancel { get; set; }
    }
}
using Syncfusion.ExcelToPdfConverter;
using Syncfusion.Pdf;
using Syncfusion.XlsIO;

namespace CaptureWarnings
{
  class Program
  {
    static void Main(string[] args)
    {
      using (ExcelEngine excelEngine = new ExcelEngine())
      {
        IApplication application = excelEngine.Excel;
        application.DefaultVersion = ExcelVersion.Excel2013;
        IWorkbook workbook = application.Workbooks.Open("Sample.xlsx", ExcelOpenType.Automatic);

        //Open the Excel document to convert.
        ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook);

        //Initialize warning class to capture warnings during the conversion.
        Warning warning = new Warning();

        //Initialize Excel-to-PDF converter settings.
        ExcelToPdfConverterSettings settings = new ExcelToPdfConverterSettings();

        //Set the warning class that is implemented.
        settings.Warning = warning;

        //Convert Excel document into PDF document.
        PdfDocument pdfDocument = converter.Convert(settings);

        //If conversion process canceled null returned.
        if (pdfDocument != null)
        {
          //Save the PDF file.
          pdfDocument.Save("ExcelToPDF.pdf");
        }
      }
    }
  }

  /// <summary>
  /// A supporting class that implements IWarning.
  /// </summary>
  public class Warning : IWarning
  {
    public void ShowWarning(WarningInfo warning)
    {
      //Cancel the converion process if the warning type is conditional formatting.
      if (warning.Type == WarningType.ConditionalFormatting)
        Cancel = true;

      //To view or log the warning, you can make use of warning.Description.
    }
    public bool Cancel { get; set; }
  }
}
Imports Syncfusion.ExcelToPdfConverter
Imports Syncfusion.Pdf
Imports Syncfusion.XlsIO

Namespace CaptureWarnings
  Class Program
    Private Shared Sub Main(ByVal args As String())
      Using excelEngine As ExcelEngine = New ExcelEngine()

        Dim application As IApplication = excelEngine.Excel
        application.DefaultVersion = ExcelVersion.Excel2013
        Dim workbook As IWorkbook = application.Workbooks.Open("Sample.xlsx", ExcelOpenType.Automatic)

        'Open the Excel document to convert.
        Dim converter As ExcelToPdfConverter = New ExcelToPdfConverter(workbook)

        'Initialize warning class to capture warnings during the conversion.
        Dim warning As Warning = New Warning()

        'Initialize Excel-to-PDF converter settings.
        Dim settings As ExcelToPdfConverterSettings = New ExcelToPdfConverterSettings()

        'Set the warning class that is implemented.
        settings.Warning = warning

        'Convert Excel document into PDF document.
        Dim pdfDocument As PdfDocument = converter.Convert(settings)

        'If conversion process canceled null returned.
        If pdfDocument IsNot Nothing Then
          'Save the PDF file.
          pdfDocument.Save("ExcelToPDF.pdf")
        End If
      End Using
    End Sub
  End Class

  ''' <summary>
  ''' A supporting class that implements IWarning.
  ''' </summary>
  Public Class Warning
    Inherits IWarning

    Public Sub ShowWarning(ByVal warning As WarningInfo)
      'Cancel the converion process if the warning type is conditional formatting.
      If warning.Type = WarningType.ConditionalFormatting Then Cancel = True

      'To view or log the warning, you can make use of warning.Description.
    End Sub

    Public Property Cancel As Boolean
  End Class
End Namespace

A complete working example to skip warning in Excel to PDF in C# is present on this GitHub page.

Show File Name

This property allows you to display the file name along with its extension in the header and/or footer when converting an Excel document to PDF. Its default value is false.

The following code snippet explains how to enable the ShowFileNameWithExtension property during Excel to PDF conversion.

using (ExcelEngine excelEngine = new ExcelEngine())
{
  IApplication application = excelEngine.Excel;
  application.DefaultVersion = ExcelVersion.Xlsx;
  IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"));

  //Initialize XlsIORendererSettings
  XlsIORendererSettings settings = new XlsIORendererSettings();

  //Enable ShowFileNameWithExtension property
  settings.ShowFileNameWithExtension = true;

  //Initialize XlsIORenderer
  XlsIORenderer renderer = new XlsIORenderer();

  //Convert the Excel document to PDF with renderer settings
  PdfDocument pdfDocument = renderer.ConvertToPDF(workbook, settings);

  #region Save
  //Save the PDF document
  pdfDocument.Save(Path.GetFullPath(@"Output/Output.pdf"));
  #endregion
}
using (ExcelEngine excelEngine = new ExcelEngine())
{
  IApplication application = excelEngine.Excel;
  application.DefaultVersion = ExcelVersion.Xlsx;
  IWorkbook workbook = application.Workbooks.Open("InputTemplate.xlsx");

  //Initialize ExcelToPdfConverterSettings
  ExcelToPdfConverterSettings settings = new ExcelToPdfConverterSettings();

  //Enable ShowFileNameWithExtension property
  settings.ShowFileNameWithExtension = true;
  
  //Load the Excel document into ExcelToPdfConverter
  ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook);

  //Convert the Excel document to PDF with converter settings
  PdfDocument document = converter.Convert(settings);

  //Save the PDF document
  document.Save("Output.pdf");
}
Using excelEngine As ExcelEngine = New ExcelEngine()
  Dim application As IApplication = excelEngine.Excel
  application.DefaultVersion = ExcelVersion.Xlsx
  Dim workbook As IWorkbook = application.Workbooks.Open("InputTemplate.xlsx")

  'Initialize ExcelToPdfConverterSettings
  Dim settings As ExcelToPdfConverterSettings = New ExcelToPdfConverterSettings()

  'Enable ShowFileNameWithExtension property
  settings.ShowFileNameWithExtension = True

  'Load the Excel document into ExcelToPdfConverter
  Dim converter As ExcelToPdfConverter = New ExcelToPdfConverter(workbook)

  'Convert the Excel document to PDF with converter settings
  Dim document As PdfDocument = converter.Convert(settings)

  'Save the PDF document
  document.Save("Output.pdf")
End Using

A complete working example demonstrating how to enable the ShowFileNameWithExtension property during Excel to PDF conversion in C# is present on this GitHub page.

See also

Enable Form Fields

This property enables the form fields in the Excel worksheet to be rendered as interactive form fields in the PDF document. The default value is FALSE.

The following code snippet explains how to enable the EnableFormFields property while converting an Excel document to PDF.

using (ExcelEngine excelEngine = new ExcelEngine())
{
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Xlsx;
    IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"));

    //Initialize XlsIORendererSettings
    XlsIORendererSettings settings = new XlsIORendererSettings();

    //Enable Form Fields
    settings.EnableFormFields = true;

    //Initialize XlsIORenderer
    XlsIORenderer renderer = new XlsIORenderer();

    //Convert the Excel document to PDF with renderer settings
    PdfDocument pdfDocument = renderer.ConvertToPDF(workbook, settings);

    #region Save
    //Saving the workbook
    pdfDocument.Save(Path.GetFullPath("Output/BookmarksInPDF.pdf"));
    #endregion
}
using (ExcelEngine excelEngine = new ExcelEngine())
{
  IApplication application = excelEngine.Excel;
  application.DefaultVersion = ExcelVersion.Xlsx;
  IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");

  //Initialize ExcelToPdfConverterSettings
  ExcelToPdfConverterSettings settings = new ExcelToPdfConverterSettings();

  //Enable Form Fields
  settings.EnableFormFields = true;

  //Load the Excel document into ExcelToPdfConverter
  ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook);

  //Convert the Excel document to PDF with converter settings
  PdfDocument document = converter.Convert(settings);

  //Save the PDF document
  document.Save("Output.pdf");
}
Using excelEngine As ExcelEngine = New ExcelEngine()
  Dim application As IApplication = excelEngine.Excel
  application.DefaultVersion = ExcelVersion.Xlsx
  Dim workbook As IWorkbook = application.Workbooks.Open("Sample.xlsx")

  'Initialize ExcelToPdfConverterSettings
  Dim settings As ExcelToPdfConverterSettings = New ExcelToPdfConverterSettings()

  'Enable Form Fields
  settings.EnableFormFields = True

  'Load the Excel document into ExcelToPdfConverter
  Dim converter As ExcelToPdfConverter = New ExcelToPdfConverter(workbook)

  'Convert the Excel document to PDF with converter settings
  Dim document As PdfDocument = converter.Convert(settings)

  'Save the PDF document
  document.Save("Output.pdf")
End Using

A complete working sample to enable form fields in Excel to PDF conversion in C# is present on this GitHub page.