MemoryStream ile Resimlere PDF Sayfalarını Rasterlemek
MemoryStream kullanarak PDF sayfalarını dosya sistemine dokunmadan resimlere nasıl dönüştürürüm?
IronPDF, PDF belgelerini MemoryStream'den yükleme sunar. (Nasıl Yapılırlar|API Referansı)
PDF sayfalarını resim olarak dışa aktarmak için PdfDocument.ToBitmap() yöntemini kullanın. Bu yöntem, daha fazla işlem için kullanılabilecek bir IronSoftware.Drawing.AnyBitmap nesneleri dizisi döndürecektir.
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();
}Imports IronPdf
Imports System.IO
' Example rendering PDF documents to Images or Thumbnails
Using pdf = PdfDocument.FromFile("Example.pdf")
' Convert each page of the PDF document to a bitmap image
Dim pageImages As IronSoftware.Drawing.AnyBitmap() = pdf.ToBitmap()
For Each bitmap In pageImages
' Use MemoryStream to handle the image data in memory
Using memoryStream As 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.
End Using
' Dispose of the bitmap once processing is complete to free resources
bitmap.Dispose()
Next
End UsingStack Overflow makalesi, bit eşlemeyi bir MemoryStream'e kaydetme hakkında daha fazla ayrıntı için yardımcı olabilir.

Curtis Chau, Bilgisayar Bilimleri alanında Lisans Derecesine (Carleton Üniversitesi) sahip ve Node.js, TypeScript, JavaScript ve React konularında uzmanlaşmış ön uç geliştirmeyle ilgileniyor. Sezgisel ve estetik açıdan hoş kullanıcı arayüzleri oluşturma tutkunu, Curtis modern çerçevelerle çalışmayı ve iyi yapılandırılmış, görsel olarak çekici kılavuzlar oluşturmayı seviyor.