3.267.0 起,回傳的 TPdfReflowDocument 另提供 WriteHtml(Writer: TPdfReportWriter; MaxDepth: Integer = 64),可直接在輸出/項目上限、文件節點/文字上限與可設定的深度限制下序列化
既有的 ToHtml 字串方法行為不變;中間的 HTML 組裝必須遵守所選限制時,請改用 有界的報告寫入
function BuildReflowDocument(
const Options: TPdfReflowOptions;
const CancellationToken: IPdfCancellationToken = nil): TPdfReflowDocument;
BuildReflowDocument 透過 GetStructuredText 讀取每個選取的頁面,優先採用 Tagged PDF 語意,缺少結構時則退回實體版面推斷
傳回的 TPdfReflowDocument.Nodes 陣列是帶有 ParentIndex 與 Depth 的穩定前序樹,避免遞迴所有權,同時保留頁面、標題、段落、清單、圖形、圖說、表格、列與儲存格的關係
每個 TPdfReflowNode 攜帶其頁面、文字、語言、語意來源、邊界、標題層級、表格座標 RowIndex 與 ColumnIndex 及其跨列跨欄資訊、IsHeader 狀態,以及適用時的信賴度
TPdfReflowOptions 選取頁面範圍與輸出閘門;DetectTables 透過巢狀的 TableOptions 額度記錄啟用表格偵測,產生的 TPdfReflowDocument 會在節點樹之外一併公開偵測到的 TableCount
偵測到的表格文字會取代與其重疊的段落區塊,使重排結果不會重複表格內容
TPdfReflowDocument.ToHtml 輸出語意的 h1 到 h6、p、ul、li、figure、figcaption、table、th 與 td 元素
文字與屬性值一律會跳脫,跨列與跨欄資訊會保留,選用的回應式 CSS 不需要指令碼或外部資源
FullDocument、IncludeCss、IncludePageSections、IncludeGeometry 與 PreserveLineBreaks 控制序列化,不必重新解析 PDF
FirstPage 與 LastPage 以 1 為起始,零代表文件邊界MaxCharacters、MaxNodes 與巢狀表格額度會在產生無上限輸出之前以 fail-closed 方式擋下var
Options: TPdfReflowOptions;
Document: TPdfReflowDocument;
begin
Options := TPdfReflowOptions.Default;
Options.IncludeGeometry := True;
Document := Pdf1.BuildReflowDocument(Options);
Memo1.Text := Document.ToHtml;
end;