![[PDF]](http://www.csharphelper.com/howto_load_word_pictures_to_pdf.png)
The example Make a Word document containing pictures in C# shows how to make a Word document containing pictures taken from selected files. This example is similar to the that one (see that post for details) except it saves the resulting document in a PDF file instead of in a Word document.
The code is the same as in the previous example except when it comes to saving the file. The previous example uses the word document object’s SaveAs method to save the document in Word (docx) format. Instead of using SaveAs, this example uses the document object’s ExportAsFixedFormat method to save the document as a PDF file. The following code shows the call to ExportAsFixedFormat.
// Save the document. word_doc.ExportAsFixedFormat(filename, WdExportFormat.wdExportFormatPDF, false, // OpenAfterExport WdExportOptimizeFor.wdExportOptimizeForOnScreen, WdExportRange.wdExportAllDocument, 0, // From 0, // To WdExportItem.wdExportDocumentContent, false, // IncludeDocProps false, // KeepIRM WdExportCreateBookmarks.wdExportCreateNoBookmarks, false, // DocStructureTags false, // BitmapMissingFonts false, // UseISO19005_1 ref missing); // FixedFormatExtClassPtr
The ExportAsFixedFormat method’s parameters are:
- OutputFileName – The name of the file to create.
- ExportFormat – PDF or XPS.
- OpenAfterExport – True to open the file after creating it.
- OptimizeFor – Optimize for screen or print.
- Range – The range to export. The default is the entire document.
- From – Starting page number (if Range is set to wdExportFromTo).
- To – Ending page number (if Range is set to wdExportFromTo).
- Item – Determines whether only text is exported or text with markup.
- IncludeDocProps – Determines whether document properties are included.
- KeepIRM – Determines whether to include IRM permissions.
- CreateBookmarks – Determines whether bookmarks are included.
- DocStructureTags – Determines whether to include extra data to help screen readers.
- BitmapMissingFonts – Determines whether to include a bitmap of the text.
- UseISO19005_1 – Determines whether to limit PDF usage to the ISO 19005-1 subset.
- FixedFormatExtClassPtr – A variant that gives a pointer to an add-in that provides an alternate implementation of code.
That’s all there is to it! Note that you could leave the call to SaveAs in the program to save the document as both a Word file and a PDF file.



