Share via


DocumentBase.ExportAsFixedFormat Method

Definition

Saves the document in PDF or XPS format.

public void ExportAsFixedFormat (string outputFileName, Microsoft.Office.Interop.Word.WdExportFormat exportFormat, bool openAfterExport, Microsoft.Office.Interop.Word.WdExportOptimizeFor optimizeFor, Microsoft.Office.Interop.Word.WdExportRange range, int from, int to, Microsoft.Office.Interop.Word.WdExportItem item, bool includeDocProps, bool keepIRM, Microsoft.Office.Interop.Word.WdExportCreateBookmarks createBookmarks, bool docStructureTags, bool bitmapMissingFonts, bool useISO19005_1, ref object fixedFormatExtClassPtr);
member this.ExportAsFixedFormat : string * Microsoft.Office.Interop.Word.WdExportFormat * bool * Microsoft.Office.Interop.Word.WdExportOptimizeFor * Microsoft.Office.Interop.Word.WdExportRange * int * int * Microsoft.Office.Interop.Word.WdExportItem * bool * bool * Microsoft.Office.Interop.Word.WdExportCreateBookmarks * bool * bool * bool * obj -> unit
Public Sub ExportAsFixedFormat (outputFileName As String, exportFormat As WdExportFormat, Optional openAfterExport As Boolean, Optional optimizeFor As WdExportOptimizeFor, Optional range As WdExportRange, Optional from As Integer, Optional to As Integer, Optional item As WdExportItem, Optional includeDocProps As Boolean, Optional keepIRM As Boolean, Optional createBookmarks As WdExportCreateBookmarks, Optional docStructureTags As Boolean, Optional bitmapMissingFonts As Boolean, Optional useISO19005_1 As Boolean, Optional ByRef fixedFormatExtClassPtr As Object)

Parameters

outputFileName
String

The path and file name of the new PDF or XPS file.

exportFormat
WdExportFormat

One of the WdExportFormat values that specifies whether to save the document in PDF or XPS format.

openAfterExport
Boolean

true to open the new file automatically; otherwise, false.

optimizeFor
WdExportOptimizeFor

One of the WdExportOptimizeFor values that specifies whether to optimize for screen or print.

range
WdExportRange

One of the WdExportRange values that specifies whether the export range is the entire document, the current page, a range of text, or the current selection. The default is to export the entire document.

from
Int32

Specifies the starting page number, if the Range parameter is set to wdExportFromTo.

to
Int32

Specifies the ending page number, if the Range parameter is set to wdExportFromTo.

item
WdExportItem

One of the WdExportItem values that specifies whether the export process includes text only or includes text with markup.

includeDocProps
Boolean

true to include document properties in the new file; otherwise, false.

keepIRM
Boolean

true to copy Information Rights Management (IRM) permissions to an XPS document if the source document has IRM protections; otherwise, false. The default is true.

createBookmarks
WdExportCreateBookmarks

One of the WdExportCreateBookmarks values that specifies whether to export bookmarks and the type of bookmarks to export.

docStructureTags
Boolean

true to include extra data to help screen readers, such as information about the flow and logical organization of the content; otherwise, false. The default is true.

bitmapMissingFonts
Boolean

true to include a bitmap of the text; false to reference the text font. Set this parameter to true when font licenses do not permit a font to be embedded in the PDF file. If you set this to false, the viewer's computer substitutes an appropriate font if the specified one is not available. The default is true.

useISO19005_1
Boolean

true to limit PDF usage to the PDF subset standardized as ISO 19005-1; otherwise, false. If you set this parameter to true, the resulting files are more reliably self-contained but may be larger or show more visual artifacts due to the restrictions of the format. The default is false.

fixedFormatExtClassPtr
Object

A pointer to an implementation of the IMsoDocExporter interface that enables the document to be saved in a different fixed format. For more information, see Extending the Office (2007) Fixed-Format Export Feature.

Examples

The following code example saves the current document in PDF format with the specified name. Because no folder is specified, the PDF file is saved in the user's My Documents folder by default. To use this example, run it from the ThisDocument class in a document-level project.

private void SaveAsPDF()
{            
    this.ExportAsFixedFormat(
        @"myPDFDocument",
        Word.WdExportFormat.wdExportFormatPDF,
        false,
        Word.WdExportOptimizeFor.wdExportOptimizeForOnScreen,
        Word.WdExportRange.wdExportAllDocument,
        0,
        0,
        Word.WdExportItem.wdExportDocumentWithMarkup,
        true,
        true,
        Word.WdExportCreateBookmarks.wdExportCreateWordBookmarks,
        true,
        true,
        false,
        ref missing);
}
Private Sub SaveAsPDF()
    Me.ExportAsFixedFormat("MyPDFDocument", _
        Word.WdExportFormat.wdExportFormatPDF)
End Sub

Remarks

You can save as a PDF or XPS file from Microsoft Office Word only after you install an add-in that provides this feature. For more information, search for "Enable support for other file formats, such as PDF and XPS" on Office Online.

Optional Parameters

For information on optional parameters, see Optional Parameters in Office Solutions.

Applies to