IronPDF 故障排除 使用MemoryStream栅格化到图像 使用 MemoryStream 将 PDF 栅格化为图像 Curtis Chau 已更新:2025年6月1日 下载 IronPDF NuGet 下载 DLL 下载 Windows 安装程序 免费试用 LLM副本 LLM副本 将页面复制为 Markdown 格式,用于 LLMs 在 ChatGPT 中打开 向 ChatGPT 咨询此页面 在双子座打开 向 Gemini 询问此页面 在 Grok 中打开 向 Grok 询问此页面 打开困惑 向 Perplexity 询问有关此页面的信息 分享 在 Facebook 上分享 分享到 X(Twitter) 在 LinkedIn 上分享 复制链接 电子邮件文章 This article was translated from English: Does it need improvement? Translated View the article in English 如何使用 MemoryStream 将 PDF 页面转换为图像,而无需触及文件系统? IronPDF 提供从 MemoryStream 加载 PDF 文档的功能。 (操作指南|API 参考) 使用 PdfDocument.ToBitmap() 方法将 PDF 页面导出为图像。 这将返回一个 IronSoftware.Drawing.AnyBitmap 对象数组,可用于进一步处理。 using IronPdf; using System.IO; // Example rendering PDF documents to Images or Thumbnails using var pdf = PdfDocument.FromFile("Example.pdf"); // Convert each page of the PDF document to a bitmap image IronSoftware.Drawing.AnyBitmap[] pageImages = pdf.ToBitmap(); foreach (var bitmap in pageImages) { // Use MemoryStream to handle the image data in memory using (MemoryStream memoryStream = new MemoryStream()) { // Export the image to MemoryStream as a PNG format bitmap.ExportStream(memoryStream, IronSoftware.Drawing.AnyBitmap.ImageFormat.Png); // MemoryStream can now be used for further processing without touching the file system // Example: Send it over a network, save to a database, etc. } // Dispose of the bitmap once processing is complete to free resources bitmap.Dispose(); } using IronPdf; using System.IO; // Example rendering PDF documents to Images or Thumbnails using var pdf = PdfDocument.FromFile("Example.pdf"); // Convert each page of the PDF document to a bitmap image IronSoftware.Drawing.AnyBitmap[] pageImages = pdf.ToBitmap(); foreach (var bitmap in pageImages) { // Use MemoryStream to handle the image data in memory using (MemoryStream memoryStream = new MemoryStream()) { // Export the image to MemoryStream as a PNG format bitmap.ExportStream(memoryStream, IronSoftware.Drawing.AnyBitmap.ImageFormat.Png); // MemoryStream can now be used for further processing without touching the file system // Example: Send it over a network, save to a database, etc. } // Dispose of the bitmap once processing is complete to free resources bitmap.Dispose(); } $vbLabelText $csharpLabel 以下是一个有用的 Stack Overflow 文章,以获取有关将位图保存到 MemoryStream 的更多信息。 Curtis Chau 立即与工程团队聊天 技术作家 Curtis Chau 拥有卡尔顿大学的计算机科学学士学位,专注于前端开发,精通 Node.js、TypeScript、JavaScript 和 React。他热衷于打造直观且美观的用户界面,喜欢使用现代框架并创建结构良好、视觉吸引力强的手册。除了开发之外,Curtis 对物联网 (IoT) 有浓厚的兴趣,探索将硬件和软件集成的新方法。在空闲时间,他喜欢玩游戏和构建 Discord 机器人,将他对技术的热爱与创造力相结合。 准备开始了吗? Nuget 下载 17,803,474 | 版本: 2026.3 刚刚发布 免费试用 免费 NuGet 下载 总下载量:17,803,474 查看许可证 还在滚动吗? 想快速获得证据? PM > Install-Package IronPdf 运行示例看着你的HTML代码变成PDF文件。 免费 NuGet 下载 总下载量:17,803,474 查看许可证