Share via


DocumentBase.ExportAsFixedFormat 方法

使用 PDF 或 XPS 格式儲存文件。

命名空間:  Microsoft.Office.Tools.Word
組件:  Microsoft.Office.Tools.Word.v4.0.Utilities (在 Microsoft.Office.Tools.Word.v4.0.Utilities.dll 中)

語法

'宣告
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
)

參數

  • outputFileName
    型別:System.String
    新的 PDF 或 XPS 檔案的路徑和檔案名稱。
  • openAfterExport
    型別:System.Boolean
    true 表示要自動開啟新檔案,否則為 false。
  • includeDocProps
    型別:System.Boolean
    true 表示要在新檔案中包含文件摘要資訊,否則為 false。
  • keepIRM
    型別:System.Boolean
    true 表示要將資訊版權管理 (IRM) 權限複製到 XPS 文件 (如果來源文件有 IRM 保護的話),否則為 false。預設值為 true。
  • docStructureTags
    型別:System.Boolean
    true 表示要包含額外資料 (例如,內容之流程和邏輯組織的相關資訊) 以協助螢幕助讀員,否則為 false。預設值為 true。
  • bitmapMissingFonts
    型別:System.Boolean
    true 表示要包含文字的點陣圖;false 表示要參考文字字型。當字型授權不允許將字型嵌入 PDF 檔案時,請將這個參數設定為 true。如果您將這個參數設定為 false,且指定的字型無法使用,則檢閱者的電腦會以適當的字型來替代。預設值為 true。
  • useISO19005_1
    型別:System.Boolean
    true 表示限制 PDF 使用依循 ISO 19005-1 標準化的 PDF 子集,否則為 false。如果您將這個參數設定為 true,則產生的檔案會更確實地獨立 (Self-Contained),但由於格式的限制,可能變得較大或出現更多視覺疊影。預設值為 false。
  • fixedFormatExtClassPtr
    型別:System.Object%
    IMsoDocExporter 介面的實作之指標,能夠以不同的固定格式儲存文件。如需詳細資訊,請參閱<擴充 Office (2007) 固定格式匯出功能>。

備註

您可以在 Microsoft Office Word 中另存為 PDF 或 XPS 檔案,但必須先安裝提供這個功能的增益集 (Add-In)。 如需詳細資訊,請搜尋 Office Online 上的「啟用其他檔案格式的支援,例如 PDF 和 XPS」。

選擇性參數

如需選擇性參數的詳細資訊,請參閱Office 方案中的選擇性參數

範例

下列程式碼範例會以指定的名稱,將目前文件儲存為 PDF 格式。 由於沒有指定資料夾,因此預設會將這個 PDF 檔案儲存在使用者的 [我的文件] 資料夾。 若要使用這個範例,請在文件層級專案中的 ThisDocument 類別執行。

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 安全性

請參閱

參考

DocumentBase 類別

Microsoft.Office.Tools.Word 命名空間