function RenderPageBandedToStream(Stream: TStream; Width,
Height: Integer; const StreamOptions: TPdfBandedImageStreamOptions;
Rotation: TRotation = ro0; Options: TRenderOptions = [];
Color: TColor = clWhite): TPdfBandedImageReport;
| Stream | TStream。归调用方所有的可写输出,定位于图像开始处 |
| StreamOptions.Format | pbifPng 表示压缩的 8 位 RGB PNG,pbifTiff 表示未压缩的小端经典 TIFF 条带 |
| StreamOptions.BandHeight | 正的条带与 TIFF 条带高度;默认为 256 行 |
| StreamOptions.CompressionLevel | 0 到 9 的 PNG zlib 压缩级别;默认为 6,TIFF 会忽略它 |
| StreamOptions.MaxOutputBytes | 硬性编码字节上限;零表示无限制 |
| Rotation | TRotation。应用于页面的显示旋转 |
| Options | TRenderOptions。渲染标志 |
| Color | TColor。渲染前应用于每个条带的背景填充 |
| Result | TPdfBandedImageReport。条带计数、已编码行数、峰值条带字节数、输出字节数、完成标志和所选格式 |
该方法将流包装进所请求的内置编码器 TPdfPngBandedImageEncoder 或 TPdfTiffBandedImageEncoder,并驱动 RenderPageBandedToEncoder 的共享分带管线。返回的报告携带所选的 Format 而不是 pbifCustom
PNG 编码器将每条扫描线直接压缩为顺序的 IDAT 块,而 TIFF 编码器为每个渲染条带写入一个 RGB 条带并在像素数据之后追加其图像文件目录。两个编码器都只向前写入且从不查找调用方流
页面像素存储峰值为一个 Width x BandHeight 的 BGRA 位图,而不是 Width x Height。报告公开测得的 PeakBandBytes,以便导出方审计内存策略;OutputBytes 反映实际写入流的内容
在覆盖个别限制之前,请先使用 TPdfBandedImageStreamOptions.Default(pbifPng) 或 Default(pbifTiff);默认值为 BandHeight = 256、CompressionLevel = 6 和 MaxOutputBytes = 0
nil 流、非正的 BandHeight 或负的 MaxOutputBytes 会抛出 EPdfError;pbifCustom 会被拒绝,因为必须使用内置的 PNG 或 TIFF 格式
当编码后的图像将超过 MaxOutputBytes 时,写入会抛出 EPdfError,消息为 Encoded image exceeds the output byte budget
对于任何其他容器格式或外部编解码器,请将 RenderPageBandedToEncoder 与自定义的 TPdfBandedImageEncoder 子类结合使用
StreamOptions := TPdfBandedImageStreamOptions.Default(pbifTiff);
StreamOptions.BandHeight := 256;
StreamOptions.MaxOutputBytes := Int64(512) * 1024 * 1024;
Report := Pdf.RenderPageBandedToStream(OutputStream, 4960, 7016,
StreamOptions);
if not Report.Completed then
RaiseBandedExportIncomplete;