syncfusion-dotnet-pdf-to-image

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Pdf To Image Converter Using Syncfusion .NET PDF Library

基于Syncfusion .NET PDF Library的PDF转图像转换器

Overview

概述

This PDF to image converter library allows converting PDF documents to images without opening the document in the PDF Viewer control. It allows you to selectively export pages as a stream by utilizing the ‘Convert’ method, facilitating the transformation of PDF files into images.
这个PDF转图像转换器库无需在PDF Viewer控件中打开文档,即可将PDF文档转换为图像。它允许你利用‘Convert’方法选择性地将页面导出为流,从而实现PDF文件到图像的转换。

Quick Start Examples

快速开始示例

Example 1: Generate Code

示例1:生成代码

User: "Show me the C# code to convert pdf to image." Result: C# code snippet displayed (no files created)
用户:“展示如何将PDF转换为图像的C#代码。” **结果:**显示C#代码片段(不创建文件)

One Modes

单一模式

Mode 1: Generate C# Code for the User's Project (default)

模式1:为用户项目生成C#代码(默认)

Use this mode when the user wants to view, write, review, refactor, or modify C# code related to pdf to image conversion processing.
Trigger keywords: "show me how", "how to", "how can I", "how do I", "provide code", "provide an example", "give an example", "demonstrate", "code snippet", "sample code", "example", "sample", "give me", "show me", "Program.cs", "example code", "generate code for", "codesnippet".
Workflow:
当用户想要查看、编写、审阅、重构或修改与PDF转图像处理相关的C#代码时,可使用此模式。
触发关键词:“show me how”, “how to”, “how can I”, “how do I”, “provide code”, “provide an example”, “give an example”, “demonstrate”, “code snippet”, “sample code”, “example”, “sample”, “give me”, “show me”, “Program.cs”, “example code”, “generate code for”, “codesnippet”。
工作流程:

Step 1 — Detect Application Type and Suggest Required NuGet Packages

步骤1 — 检测应用类型并建议所需的NuGet包

  • Inspect the workspace project files (
    .csproj
    ,
    web.config
    ,
    App.config
    ,
    Startup.cs
    ,
    Program.cs
    , etc.) and use the detection signals table in
    references/nuget-packages.md
    to determine the application type.
  • Based on the detected application type, identify the correct NuGet package(s) from references/nuget-packages.md and instruct the user to install them before generating any code.
  • 检查工作区项目文件(
    .csproj
    web.config
    App.config
    Startup.cs
    Program.cs
    等),并使用
    references/nuget-packages.md
    中的检测信号表确定应用类型。
  • 根据检测到的应用类型,从references/nuget-packages.md中识别正确的NuGet包,并指导用户在生成任何代码之前安装它们。

Step 2 — Generate Code from Reference Files Only

步骤2 — 仅从参考文件生成代码

Do NOT invent, guess, or suggest any API, method, property, class, or namespace not explicitly present in the reference files.
  • Read the relevant
    references/*.md
    file(s) for the requested feature
  • Build C# code strictly from the APIs and snippets found in those files
  • Do not create or run any
    .csx
    script

请勿发明、猜测或建议任何未在参考文件中明确提及的API、方法、属性、类或命名空间。
  • 读取与所需功能相关的
    references/*.md
    文件
  • 严格根据这些文件中的API和代码片段构建C#代码
  • 请勿创建或运行任何
    .csx
    脚本

API Summary

API摘要

API / PropertyPurpose
new PdfToImageConverter(stream)
Loads a PDF document from a stream via constructor
new PdfToImageConverter(stream, password)
Loads an encrypted PDF document from a stream via constructor
imageConverter.Load(stream)
Loads a PDF document from a stream using the Load method
imageConverter.Load(stream, password)
Loads an encrypted PDF document from a stream using the Load method
imageConverter.Convert(pageIndex, keepTransparency, isSkipAnnotations)
Converts a single PDF page to an image stream
imageConverter.Convert(startPage, endPage, keepTransparency, isSkipAnnotations)
Converts a range of PDF pages to an array of image streams
imageConverter.Convert(pageIndex, SizeF, keepAspectRatio, keepTransparency, isSkipAnnotations)
Converts a PDF page to an image with a custom width and height
imageConverter.Convert(startPage, endPage, dpiX, dpiY, keepTransparency, isSkipAnnotations)
Converts a range of PDF pages to images at a custom DPI resolution (MVC / WinForms / WPF)
imageConverter.Convert(pageIndex, zoomFactor, tileXCount, tileYCount, tileX, tileY)
Converts a PDF page to an image using zoom factor and tile matrix coordinates (ASP.NET Core / Blazor)
imageConverter.PageCount
Gets the total number of pages in the loaded PDF document
imageConverter.ScaleFactor
Sets the scale factor to enhance output image quality (default:
1.5f
)
imageConverter.ReferencePath
Sets a custom folder path for PDFium binary extraction in restricted-access environments

API / 属性用途
new PdfToImageConverter(stream)
通过构造函数从流中加载PDF文档
new PdfToImageConverter(stream, password)
通过构造函数从流中加载加密的PDF文档
imageConverter.Load(stream)
使用Load方法从流中加载PDF文档
imageConverter.Load(stream, password)
使用Load方法从流中加载加密的PDF文档
imageConverter.Convert(pageIndex, keepTransparency, isSkipAnnotations)
将单页PDF转换为图像流
imageConverter.Convert(startPage, endPage, keepTransparency, isSkipAnnotations)
将指定范围的PDF页面转换为图像流数组
imageConverter.Convert(pageIndex, SizeF, keepAspectRatio, keepTransparency, isSkipAnnotations)
将PDF页面转换为自定义宽高的图像
imageConverter.Convert(startPage, endPage, dpiX, dpiY, keepTransparency, isSkipAnnotations)
将指定范围的PDF页面转换为自定义DPI分辨率的图像(MVC / WinForms / WPF)
imageConverter.Convert(pageIndex, zoomFactor, tileXCount, tileYCount, tileX, tileY)
使用缩放因子和瓦片矩阵坐标将PDF页面转换为图像(ASP.NET Core / Blazor)
imageConverter.PageCount
获取已加载PDF文档的总页数
imageConverter.ScaleFactor
设置缩放因子以提升输出图像质量(默认值:
1.5f
imageConverter.ReferencePath
在受限访问环境中为PDFium二进制文件提取设置自定义文件夹路径

Code References

代码参考

All templates and snippets are in the
references/
folder:
FileContents
nuget-packages.md
Lists the required NuGet packages for PDFToImageConverter per target platform, with application-type detection signals
load.md
Loads a PDF document (plain or encrypted) as stream into PdfToImageConverter using constructor or Load method
customizing-conversion.md
Converts PDF pages to images — single page, page range, custom size, custom DPI, and zoom/tile resolution
multithreading-pdf-to-image.md
Converts PDF pages to images using multithreading — via Task-based async and Parallel.For patterns

所有模板和代码片段都位于
references/
文件夹中:
文件内容
nuget-packages.md
列出了针对不同目标平台使用PDFToImageConverter所需的NuGet包,以及应用类型检测信号
load.md
使用构造函数或Load方法将PDF文档(普通或加密)作为流加载到PdfToImageConverter中
customizing-conversion.md
将PDF页面转换为图像——单页、页面范围、自定义尺寸、自定义DPI以及缩放/瓦片分辨率
multithreading-pdf-to-image.md
使用多线程将PDF页面转换为图像——基于Task的异步和Parallel.For模式

Rules

规则

  • Output files go in
    ./output/
    directory
  • Use license key from
    SyncfusionLicense.txt
    at workspace root
  • Don't use any API which is not in reference
  • 输出文件保存到
    ./output/
    目录
  • 使用工作区根目录下
    SyncfusionLicense.txt
    中的许可证密钥
  • 请勿使用参考文件中未提及的任何API

Prerequisites

前提条件

  • Install required runtime and library packages from NuGet before running recognition.
  • .NET SDK 8+ and
    dotnet-script
    :
    dotnet tool install -g dotnet-script
  • Syncfusion License:
    SyncfusionLicense.txt
    or env var
    SYNCFUSION_LICENSE_KEY
  • Free license: https://www.syncfusion.com/products/communitylicense
  • 在运行识别前,从NuGet安装所需的运行时和库包。
  • .NET SDK 8+和
    dotnet-script
    dotnet tool install -g dotnet-script
  • Syncfusion许可证:
    SyncfusionLicense.txt
    或环境变量
    SYNCFUSION_LICENSE_KEY
  • 免费许可证:https://www.syncfusion.com/products/communitylicense