When i generate a PDF the image is not the same as the pdf.
Words have somethimes extra large spacing.
new lines are sometimes ignored
the tables are cropped
@2SSTsupport Could you please attach your input document and the code that will allow us to reproduce the problem? We will check the issue and provide you more information.
@2SSTsupport Thank you for additional information. Please note, Aspose.Words is designed to work with MS Word documents. MS Word documents are flow documents and they have structure very similar to Aspose.Words Document Object Model. On the other hand PDF documents are fixed page format documents . While loading PDF document, Aspose.Words converts Fixed Page Document structure into the Flow Document Object Model. Unfortunately, such conversion does not guaranty 100% fidelity.
Though you can use the following code to convert PDF document to image without loading PDF document into Aspose.Words DOM:
Aspose.Words.Pdf2Word.FixedFormats.PdfFixedRenderer pdfRenderer = new Aspose.Words.Pdf2Word.FixedFormats.PdfFixedRenderer();
using (FileStream pdfStream = File.OpenRead(@"C:\Temp\in.pdf"))
{
Aspose.Words.Pdf2Word.FixedFormats.PdfFixedOptions opt = new Aspose.Words.Pdf2Word.FixedFormats.PdfFixedOptions();
opt.ImageFormat = Aspose.Words.Pdf2Word.FixedFormats.FixedImageFormat.Png;
IReadOnlyList<Stream> images = pdfRenderer.SavePdfAsImages(pdfStream, opt);
for (int frameIdx = 0; frameIdx < images.Count; frameIdx++)
{
using (Stream imgStream = images[frameIdx])
using (FileStream imgFile = File.Create(string.Format(@"C:\Temp\out_{0}.png", frameIdx)))
{
imgStream.CopyTo(imgFile);
}
}
}
In this case the output is more accurate.
Thanks you this fixed it. Can you delete the attachments due to privacy? I accendently forgot to anonymise them.
@2SSTsupport Attachments in the forum are visible only to topic starter and Aspose staff. So they cannot be leaked to third persons.