Microsoft Office Documents to PDF
ImageGear .NET provides the ability to convert any Microsoft Office Open XML and Microsoft Office 97-2003 document currently supported by the product or any page of a Microsoft Office Open XML or Microsoft Office 97-2003 document and save the converted content to a PDF file. This can be done by using one of the following API calls:
ImageGear .NET Office to PDF converter provides the conversion of all currently supported text elements, raster images, and graphic shapes for Microsoft Office Open XML and Microsoft Office 97-2003 formats described in Using ImageGear.Formats.Office Namespace.
Note the following conversions that take place when converting to PDF:
- Gradients with Transparency: Microsoft Office Open XML gradients with transparency are converted as non-transparent PDF gradients.
- Text with Gradients: Microsoft Office Open XML text with gradient fill and stroke is converted to solid PDF text with the color of the first gradient stop.
- Patterns: Microsoft Office Open XML text with patterns is converted to solid black PDF text.
Word (DOCX/DOC) to PDF
This sample shows how to input a Word document in the DOCX/DOC format and output all pages as a PDF document.
After some initializations, load the necessary ImGear filters to create an instance of Microsoft Word format for input and an instance of PDF format for output using code that looks like:
Next, the PDF library requires its own initialization:
Then, simply read in all pages of the Word document using the ImGearFileFormats.LoadDocument() method:
Finally, write out the document as PDF using the ImGearFileFormats.SaveDocument() method with the saving format set to ImGearSavingFormats.PDF and no special options:
Excel (XLSX/XLS) to PDF
This sample can be easily adjusted to accept Excel Spreadsheet XLSX/XLS documents as input.
To accept XLSX/XLS files as input, create an instance of Microsoft Excel format after initializing ImageGear .NET:
and modify the sample's open file dialog to accept the *.xlsx/*.xls extensions:
PowerPoint (PPTX/PPT) to PDF
This sample can be easily adjusted to accept PowerPoint PPTX/PPT files as input.
To accept PPTX files as input, create an instance of Microsoft PowerPoint format after initializing ImageGear .NET:
and modify the sample's open file dialog to accept the *.pptx extension: