syncfusion-dotnet-pdf-to-image
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePdf 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, etc.) and use the detection signals table inProgram.csto determine the application type.references/nuget-packages.md -
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 file(s) for the requested feature
references/*.md - Build C# code strictly from the APIs and snippets found in those files
- Do not create or run any script
.csx
请勿发明、猜测或建议任何未在参考文件中明确提及的API、方法、属性、类或命名空间。
- 读取与所需功能相关的文件
references/*.md - 严格根据这些文件中的API和代码片段构建C#代码
- 请勿创建或运行任何脚本
.csx
API Summary
API摘要
| API / Property | Purpose |
|---|---|
| Loads a PDF document from a stream via constructor |
| Loads an encrypted PDF document from a stream via constructor |
| Loads a PDF document from a stream using the Load method |
| Loads an encrypted PDF document from a stream using the Load method |
| Converts a single PDF page to an image stream |
| Converts a range of PDF pages to an array of image streams |
| Converts a PDF page to an image with a custom width and height |
| Converts a range of PDF pages to images at a custom DPI resolution (MVC / WinForms / WPF) |
| Converts a PDF page to an image using zoom factor and tile matrix coordinates (ASP.NET Core / Blazor) |
| Gets the total number of pages in the loaded PDF document |
| Sets the scale factor to enhance output image quality (default: |
| Sets a custom folder path for PDFium binary extraction in restricted-access environments |
| API / 属性 | 用途 |
|---|---|
| 通过构造函数从流中加载PDF文档 |
| 通过构造函数从流中加载加密的PDF文档 |
| 使用Load方法从流中加载PDF文档 |
| 使用Load方法从流中加载加密的PDF文档 |
| 将单页PDF转换为图像流 |
| 将指定范围的PDF页面转换为图像流数组 |
| 将PDF页面转换为自定义宽高的图像 |
| 将指定范围的PDF页面转换为自定义DPI分辨率的图像(MVC / WinForms / WPF) |
| 使用缩放因子和瓦片矩阵坐标将PDF页面转换为图像(ASP.NET Core / Blazor) |
| 获取已加载PDF文档的总页数 |
| 设置缩放因子以提升输出图像质量(默认值: |
| 在受限访问环境中为PDFium二进制文件提取设置自定义文件夹路径 |
Code References
代码参考
All templates and snippets are in the folder:
references/| File | Contents |
|---|---|
| Lists the required NuGet packages for PDFToImageConverter per target platform, with application-type detection signals |
| Loads a PDF document (plain or encrypted) as stream into PdfToImageConverter using constructor or Load method |
| Converts PDF pages to images — single page, page range, custom size, custom DPI, and zoom/tile resolution |
| Converts PDF pages to images using multithreading — via Task-based async and Parallel.For patterns |
所有模板和代码片段都位于文件夹中:
references/| 文件 | 内容 |
|---|---|
| 列出了针对不同目标平台使用PDFToImageConverter所需的NuGet包,以及应用类型检测信号 |
| 使用构造函数或Load方法将PDF文档(普通或加密)作为流加载到PdfToImageConverter中 |
| 将PDF页面转换为图像——单页、页面范围、自定义尺寸、自定义DPI以及缩放/瓦片分辨率 |
| 使用多线程将PDF页面转换为图像——基于Task的异步和Parallel.For模式 |
Rules
规则
- Output files go in directory
./output/ - Use license key from at workspace root
SyncfusionLicense.txt - 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-scriptdotnet tool install -g dotnet-script - Syncfusion License: or env var
SyncfusionLicense.txtSYNCFUSION_LICENSE_KEY - Free license: https://www.syncfusion.com/products/communitylicense
- 在运行识别前,从NuGet安装所需的运行时和库包。
- .NET SDK 8+和:
dotnet-scriptdotnet tool install -g dotnet-script - Syncfusion许可证:或环境变量
SyncfusionLicense.txtSYNCFUSION_LICENSE_KEY - 免费许可证:https://www.syncfusion.com/products/communitylicense