Hi Guys,
Could you please assist with next:
when I'm trying to convert .pdf data file (with an existing background in it) to .png file - I couldn't get the correct result of the such convertation.
Expected Result: The background Layer should be present at converted .png file
Actual Result: After converting has been perfromed I could get the .png file without background.
Did I miss something?
Test files and actual result is attached to post.
Used code you read bellow:
var pdf = new Pdf();
using (var xmlStream = File.OpenRead("SampleAsposePdf.xml"))
{
pdf.BindXML(xmlStream, null);
}
pdf.Save("empty.pdf");
using (var pdfDocument = new Document(pdf))
{
// create BackgroundArtifact object
var background = new BackgroundArtifact();
// specify the image for backgroundartifact object
background.BackgroundImage = File.OpenRead("background.png");
pdfDocument.Pages[1].Artifacts.Add(background);
pdfDocument.Save("background.pdf");
const int dpi = 150;
// Create Resolution object
var resolution = new Resolution(dpi);
// create PNG device with specified attributes
var pngDevice = new PngDevice(resolution);
using (var output = new FileStream("converted.png", FileMode.Create, FileAccess.Write))
{
// Convert a particular page and save the image to stream
pngDevice.Process(pdfDocument.Pages[1], output);
}
}
Thanks in advance!