I am using the code in ConvertAllPagesToPNG.cs to convert a pdf doc (attached MatExample.pdf) but it removes the image (attached image1_out.png). Is it a bug or am I missing something?
This is the code I have used which is found in ConvertAllPagesToPNG.cs downloaded from https://github.com/aspose-pdf/Aspose.PDF-for-.NET/tree/master/Examples
public class ConvertAllPagesToPNG
{
public static void Run()
{
// ExStart:ConvertAllPagesToPNG
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdf_Images();
// Open document
Document pdfDocument = new Document(dataDir + "MatExample.pdf");
for (int pageCount = 1; pageCount <= pdfDocument.Pages.Count; pageCount++)
{
using (FileStream imageStream = new FileStream(dataDir + "image" + pageCount + "_out" + ".png", FileMode.Create))
{
// Create PNG device with specified attributes
// Width, Height, Resolution, Quality
// Quality [0-100], 100 is Maximum
// Create Resolution object
Resolution resolution = new Resolution(300);
PngDevice pngDevice = new PngDevice(resolution);
// Convert a particular page and save the image to stream
pngDevice.Process(pdfDocument.Pages[pageCount], imageStream);
// Close stream
imageStream.Close();
}
}
// ExEnd:ConvertAllPagesToPNG
System.Console.WriteLine("PDF pages are converted to PNG successfully!");
}
}
MatExample.pdf (69.8 KB)
image1_out.png (125.4 KB)