跳至頁尾內容
字處理工具

您能否將 PDF 新增到 Word 文件中(初學者指南)

本指南專注於如何在Microsoft Word文件中使用Microsoft Word的"插入物件"功能來插入PDF文件。 此方法保留了原始文件格式,同時允許直接在Word中存取。 我們將逐步講解這個過程,討論其優勢和限制,並探討針對特定使用案例的替代方法。

在文章結尾,我們將簡要介紹尋求程式解決方案的開發者的IronWordIronPDF程式庫。 這些工具為PDF和Word文件相關操作提供了進階功能。 讓我們了解如何將PDF作為嵌入物件新增到您的Word文件中。

2. 在Word中插入PDF作為物件

要在Word文件中將PDF作為物件新增,請遵循以下步驟:

  1. 打開您的Word文件。
  2. 將游標定位到您想要插入PDF的位置。
  3. 轉到功能區上的"插入"選項卡。
  4. 在"文字"組中,單擊"物件"。
  5. 在物件對話框中切換到"從文件建立"選項卡。
  6. 單擊"瀏覽"以找到您的PDF文件。
  7. 選擇PDF並單擊"打開"。
  8. 可以選擇勾選"連結至文件"或"顯示為圖示"。
  9. 單擊"確定"以將PDF插入到您的文件中。

讓我們詳細檢查每個步驟:

2.1 存取物件插入功能

物件插入功能位於插入選項卡中,其中包含許多新增內容到您的文件中的工具。 物件按鈕通常位於文字組中,與其他插入選項一起。

Can you add a PDF to a Word Document (Beginner Guide): Figure 1

2.2 從文件建立

物件對話框中的"從文件建立"選項卡允許您插入現有文件。 在這裡,您將選擇要插入的PDF文件。

Can you add a PDF to a Word Document (Beginner Guide): Figure 2

2.3 文件選擇

使用瀏覽按鈕瀏覽您的檔案系統並選擇所需的PDF。 Word支持多種文件型別,但本指南重點介紹PDF文件。

Can you add a PDF to a Word Document (Beginner Guide): Figure 3

2.4 插入選項

兩個複選框提供了對PDF插入方式的額外控制:

  • 連結至文件: 建立一個指向原始PDF的連結,而不是將其嵌入文件中。 這使得Word文件大小較小,但要求連結的PDF保留在其原始位置。
  • 顯示為圖示: 將PDF文件顯示為圖示而不是其首頁。 這對於保持文件佈局乾淨是有用的。

單擊確定後,將PDF插入到Word文件中作為嵌入物件。

Can you add a PDF to a Word Document (Beginner Guide): Figure 4

還有一種方法是使用Adobe Acrobat將PDF轉換為Word,再將其插入到Word文件中。 通過這種方式,使用者將能夠直接查看內容。

使用IronPDF和IronWord進行進階PDF和Word文件處理

雖然IronPDF和IronWord並不直接支持插入PDF到Word文件,但它們提供強大的PDF和Word文件處理功能,這在涉及兩者格式的工作流程中可以非常有價值。

IronPDF .NET PDF Library

Can you add a PDF to a Word Document (Beginner Guide): Figure 5 - IronPDF: The C# PDF library

IronPDF是一個為.NET開發者設計的PDF程式庫。 它允許使用者直接從C#、F#或VB.NET程式碼中建立、編輯和操作PDF。 該程式庫支持從HTML、URL字串和原始HTML文件渲染PDF。 它還包括密碼保護、數位簽名、註釋和文字提取。 IronPDF相容於各種.NET環境(包括.NET Core、Framework和Standard),並支持Windows、Linux、macOS以及像Docker這樣的容器化環境。

它還包括PDF/A合規支持,使其適合於存檔和法律使用場景。 進階功能包括HTML/CSS整合、自定義頁面設置,以及將多媒體元素如圖像和JavaScript嵌入到PDF中的選項。

using IronPdf;

const string htmlWithJavaScript = @"
<h2>New HTML Content</h2>
<script>
    document.write('<p>This text is generated by JavaScript</p>');
    window.ironpdf.notifyRender();
</script>";

var renderer = new ChromePdfRenderer();
renderer.RenderingOptions.EnableJavaScript = true;
// Adjusted the JavaScript wait time
renderer.RenderingOptions.WaitFor.RenderDelay = 150; 

// Renders the HTML as a PDF including the JavaScript-generated content
var pdfWithJavaScript = renderer.RenderHtmlAsPdf(htmlWithJavaScript);

// Saves the generated PDF on disk
pdfWithJavaScript.SaveAs("javascript-in-html-v2.pdf");
using IronPdf;

const string htmlWithJavaScript = @"
<h2>New HTML Content</h2>
<script>
    document.write('<p>This text is generated by JavaScript</p>');
    window.ironpdf.notifyRender();
</script>";

var renderer = new ChromePdfRenderer();
renderer.RenderingOptions.EnableJavaScript = true;
// Adjusted the JavaScript wait time
renderer.RenderingOptions.WaitFor.RenderDelay = 150; 

// Renders the HTML as a PDF including the JavaScript-generated content
var pdfWithJavaScript = renderer.RenderHtmlAsPdf(htmlWithJavaScript);

// Saves the generated PDF on disk
pdfWithJavaScript.SaveAs("javascript-in-html-v2.pdf");
Imports IronPdf

Private Const htmlWithJavaScript As String = "
<h2>New HTML Content</h2>
<script>
    document.write('<p>This text is generated by JavaScript</p>');
    window.ironpdf.notifyRender();
</script>"

Private renderer = New ChromePdfRenderer()
renderer.RenderingOptions.EnableJavaScript = True
' Adjusted the JavaScript wait time
renderer.RenderingOptions.WaitFor.RenderDelay = 150

' Renders the HTML as a PDF including the JavaScript-generated content
Dim pdfWithJavaScript = renderer.RenderHtmlAsPdf(htmlWithJavaScript)

' Saves the generated PDF on disk
pdfWithJavaScript.SaveAs("javascript-in-html-v2.pdf")
$vbLabelText   $csharpLabel

IronWord .NET Word Library

Can you add a PDF to a Word Document (Beginner Guide): Figure 6

IronWord是Iron Software 套件中的另一個程式庫,專注於使用Microsoft Word文件(DOCX)。 它提供了一個簡單的API,用於以.NET語言程式化地建立、讀取和編輯Word文件。 與IronPDF類似,IronWord與其他程式庫無縫整合,提供一系列文件操作能力,如修改DOCX文件中的文字、表格和圖像。

該程式庫生成動態報告、合併文件或將DOCX文件轉換為其他格式。 它還支持文件格式設置、模板建立和資料綁定,使其對於需要自動化或自定義Word文件的應用程式而言,理想的使用場景。

using IronWord;
using IronWord.Models;

// Creates a text object to be inserted into a Word document
Text textRun = new Text("Sample text");

// Creates a paragraph object to hold the text
Paragraph paragraph = new Paragraph();
paragraph.AddChild(textRun);

// Initializes a new Word document with the paragraph
WordDocument doc = new WordDocument(paragraph);

// Saves the Word document to disk
doc.SaveAs("Sample Doc.docx");
using IronWord;
using IronWord.Models;

// Creates a text object to be inserted into a Word document
Text textRun = new Text("Sample text");

// Creates a paragraph object to hold the text
Paragraph paragraph = new Paragraph();
paragraph.AddChild(textRun);

// Initializes a new Word document with the paragraph
WordDocument doc = new WordDocument(paragraph);

// Saves the Word document to disk
doc.SaveAs("Sample Doc.docx");
Imports IronWord
Imports IronWord.Models

' Creates a text object to be inserted into a Word document
Private textRun As New Text("Sample text")

' Creates a paragraph object to hold the text
Private paragraph As New Paragraph()
paragraph.AddChild(textRun)

' Initializes a new Word document with the paragraph
Dim doc As New WordDocument(paragraph)

' Saves the Word document to disk
doc.SaveAs("Sample Doc.docx")
$vbLabelText   $csharpLabel

結論

Can you add a PDF to a Word Document (Beginner Guide): Figure 7

將PDF作為嵌入物件新增到Word文件中,可以在保留原始文件格式的同時,將PDF插入到您的Word DOC中。 此方法幫助您將整個PDF新增到Word格式,而無需使用Word轉換器。 插入的PDF內容仍保持其源文件格式,這意味著它不會被轉換為Word文件中的可編輯文字。

對於需要更多進階文件處理能力的使用者,IronPDF和IronWord提供了強大的解決方案。 這些程式庫允許開發者以程式方式操控PDF內容和Word格式文件,並提供超過僅僅將PDF插入Word文件的靈活性。

IronPDF和IronWord都提供免費試用,讓使用者在投入使用前探索其功能。 這些強大的工具的授權價格起始於$999,為需要進階文件處理能力的企業和開發者提供了一個具有成本效益的解決方案。

Curtis Chau
技術作家

Curtis Chau擁有Carleton大學的電腦科學學士學位,專精於前端開發,擁有Node.js、TypeScript、JavaScript和React的專業知識。Curtis熱衷於建立直觀且美觀的使用者介面,喜愛使用現代框架並建立結構良好、視覺吸引力的手冊。

除了開發,Curtis對物聯網(IoT)有濃厚的興趣,探索創新的方法來整合硬體和軟體。在空閒時間,他喜歡玩遊戲和建立Discord機器人,結合他對技術的熱愛與創造力。

Iron 支援團隊

我們線上24小時,每週5天。
聊天
電子郵件
給我打電話