Hello,
Does anybody know how to convert PDF to PNG8 ? By défault in my code, the PDF document is converted to PNG24. Is there any option that can be added ? I join my code below.
Thanks in advance for your help.
David
public static void GeneratePngWithASPOSE(PDF pdfInfo)
{
var pdfDocument = new Document(pdfInfo.SourceFolder + pdfInfo.FileName + sourceExtension);
try
{
if (!Directory.Exists(pdfInfo.DestinationFolder))
{
Directory.CreateDirectory(pdfInfo.DestinationFolder);
}
}
catch
{
throw new Exception(String.Format(“Droits d’écriture insuffisant, création de ‘{0}’ impossible”, pdfInfo.DestinationFolder));
}
pdfInfo.NumberOfPages = pdfDocument.Pages.Count;
for (int pageCount = 1; pageCount <= pdfDocument.Pages.Count; pageCount++)
{
var folderAndFileToSavePng = pdfInfo.DestinationFolder + pdfInfo.FileName + "" + pageCount + _destinationExtension;
using (var imageStream = new FileStream(folderAndFileToSavePng, FileMode.Create))
{
var resolution = new Resolution(80);
var pngDevice = new PngDevice(resolution);
try
{
pngDevice.Process(pdfDocument.Pages[pageCount], imageStream);
}
catch
{
throw new Exception(String.Format(“Un problème est survenu la création de {0}”, folderAndFileToSavePng));
}
finally
{
imageStream.Close();
}
}
using (var myImage = System.Drawing.Image.FromFile(folderAndFileToSavePng))
{
if (myImage.Width < myImage.Height) // Portrait
{
myImage.RotateFlip(RotateFlipType.Rotate90FlipNone);
try
{
myImage.Save(folderAndFileToSavePng);
}
catch
{
throw new Exception(String.Format(“Un problème est survenu lors de la rotation de {0}”, folderAndFileToSavePng));
}
}
}
}
}