Share via


DocumentBase.ExportAsFixedFormat Method

Saves the document in PDF or XPS format.

Namespace:  Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word.v4.0.Utilities (in Microsoft.Office.Tools.Word.v4.0.Utilities.dll)

Syntax

'Declaration
Public Sub ExportAsFixedFormat ( _
    outputFileName As String, _
    exportFormat As WdExportFormat, _
    openAfterExport As Boolean, _
    optimizeFor As WdExportOptimizeFor, _
    range As WdExportRange, _
    from As Integer, _
    to As Integer, _
    item As WdExportItem, _
    includeDocProps As Boolean, _
    keepIRM As Boolean, _
    createBookmarks As WdExportCreateBookmarks, _
    docStructureTags As Boolean, _
    bitmapMissingFonts As Boolean, _
    useISO19005_1 As Boolean, _
    ByRef fixedFormatExtClassPtr As Object _
)
public void ExportAsFixedFormat(
    string outputFileName,
    WdExportFormat exportFormat,
    bool openAfterExport,
    WdExportOptimizeFor optimizeFor,
    WdExportRange range,
    int from,
    int to,
    WdExportItem item,
    bool includeDocProps,
    bool keepIRM,
    WdExportCreateBookmarks createBookmarks,
    bool docStructureTags,
    bool bitmapMissingFonts,
    bool useISO19005_1,
    ref Object fixedFormatExtClassPtr
)

Parameters

  • outputFileName
    Type: System.String
    The path and file name of the new PDF or XPS file.
  • openAfterExport
    Type: System.Boolean
    true to open the new file automatically; otherwise, false.
  • includeDocProps
    Type: System.Boolean
    true to include document properties in the new file; otherwise, false.
  • keepIRM
    Type: System.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.
  • docStructureTags
    Type: System.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
    Type: System.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
    Type: System.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
    Type: System.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.

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.

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 Sub SaveAsPDF()
    Me.ExportAsFixedFormat("MyPDFDocument", _
        Word.WdExportFormat.wdExportFormatPDF)
End Sub
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);
}

.NET Framework Security

See Also

Reference

DocumentBase Class

Microsoft.Office.Tools.Word Namespace