When a pdfDocument (Aspose.Pdf.Document object) has it “Save” method called; then the pdf is converted to an image, the image does not have text in the same cases.
Here are two formats of demo code
- Github link to complete solution
https://github.com/zoldello/Aspose.Pdf.Document.SaveIssueDemo/tree/master - Code itself
//////////////
/Add license/
// var licence = new Aspose.Pdf.License();
//licence.SetLicense(Add YOUR LICENCE HERE);
var imageWidth = 77;
var imageHeight = 109;
var resolution = new Aspose.Pdf.Devices.Resolution(300);
var imageDevice = new Aspose.Pdf.Devices.PngDevice(imageWidth, imageHeight, resolution);
var path = Path.GetDirectoryName(Application.ExecutablePath).Replace(“bin\Debug”, string.Empty);
var testFile = path + @“TestImages\Superheros.pdf”;
var imageLocation = path + “GeneratedImages\Superheros.png”;
var dummypath = path + “DummyFolder\Superheroes.pdf”;
var pdfDocument = new Aspose.Pdf.Document(testFile);
imageDevice.RenderingOptions.SystemFontsNativeRendering = true;
/Having this line results in “GeneratedImages\Superheros.png”; being empty. Not having it makes the said png have the text from the source-pdf
/
pdfDocument.Save(dummypath);
if (imageDevice != null) {
using (var imageStream = new FileStream(imageLocation, FileMode.OpenOrCreate))
{
imageDevice.Process(pdfDocument.Pages[1], imageStream);
imageStream.Close();
}
}
}
/////////////////
I attached sample files with the error