Hi,
When I try to use Aspose to convert a pdf to a png, the file size is about 4-5x the size of the pdf, so I attempted to use the Aspose Imaging class to do a compression with PngOptions to make the file size smaller. However, the new image that is created has this text in the top left corner, “Evaluation Only. Created with Aspose.Imaging. Copyright, etc.”. I have an Aspose.Pdf license, so I assume this would be included in our package.
- Is there a more efficient way to use the compression when creating the png file initially?
- if not, how do i get this text to go away?
My code is below, mostly taken from the Aspose documentation.
using (var msSource = new MemoryStream(bytes))
using (var pdf = new Aspose.Pdf.Document(msSource))
{
var outputPath = filePath; // some file path
// Create JPEG device with specified attributes
// Width, Height, Resolution, Quality
// Quality [0-100], 100 is Maximum
// Create Resolution object
var resolution = new Resolution(300);
var pngDevice = new PngDevice(resolution);
for (var pageCount = 1; pageCount <= pdf.Pages.Count; pageCount++)
{
var fileName = $"image_{idType}_{id}_{pageCount}.png";
var filePath = Path.Combine(outputPath, fileName);
using (var fileStream = new FileStream(filePath, FileMode.Create))
{
pngDevice.Process(pdf.Pages[pageCount], fileStream);
}
var compressedName = $"image_{idType}_{id}_{pageCount}_compressed.png";
var compressionPath = Path.Combine(outputPath, compressedName);
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(filePath))
{
image.Save(compressionPath, new PngOptions { CompressionLevel = 9 });
}
}