在IronPDF中管理表格標題

This article was translated from English: Does it need improvement?
Translated
View the article in English

在處理 PDF 中跨越多頁的 HTML 表格時,請務必確保表格標題在每個新頁面的頂部重複出現。 IronPDF 的 CssMediaType.Print 選項可以實現這種行為。

// Set the CSS media type to 'Print' to ensure table headers repeat on every new page
Renderer.RenderingOptions.CssMediaType = IronPdf.Rendering.PdfCssMediaType.Print;
// Set the CSS media type to 'Print' to ensure table headers repeat on every new page
Renderer.RenderingOptions.CssMediaType = IronPdf.Rendering.PdfCssMediaType.Print;
$vbLabelText   $csharpLabel

相較之下,使用 CssMediaType.Screen 將導致 Chrome 只在表格的最開頭列印一次表格標題。

// Set the CSS media type to 'Screen' if you want the headers printed only once at the start of the table
Renderer.RenderingOptions.CssMediaType = IronPdf.Rendering.PdfCssMediaType.Screen;
// Set the CSS media type to 'Screen' if you want the headers printed only once at the start of the table
Renderer.RenderingOptions.CssMediaType = IronPdf.Rendering.PdfCssMediaType.Screen;
$vbLabelText   $csharpLabel

有關處理分頁符號和表格的更多範例和詳細程式碼片段,您可以參考處理分頁符號和表格的程式碼範例

Curtis Chau
技術作家

Curtis Chau 擁有卡爾頓大學計算機科學學士學位,專注於前端開發,擅長於 Node.js、TypeScript、JavaScript 和 React。Curtis 熱衷於創建直觀且美觀的用戶界面,喜歡使用現代框架並打造結構良好、視覺吸引人的手冊。

除了開發之外,Curtis 對物聯網 (IoT) 有著濃厚的興趣,探索將硬體和軟體結合的創新方式。在閒暇時間,他喜愛遊戲並構建 Discord 機器人,結合科技與創意的樂趣。

準備好開始了嗎?
Nuget 下載 17,803,474 | 版本: 2026.3 剛剛發布
Still Scrolling Icon

還在滾動嗎?

想快速取得證據? PM > Install-Package IronPdf
運行範例看著你的HTML程式碼變成PDF檔。