Error while converting PDF to PNG images

Error:

I am trying to convert PDF's pages to PNG images but getting an exception at

"pngDevice.Process(pdfDocument.Pages(pageCount), imageStream)" line with message "Parameter is not Valid".

Background:

I am Converting DOCX and DOC file to PDF and then each page of PDF to PNG images.

Fails at:

While converting some DOCX file containing headers & footers, tables especially images (copied screenshot or inserted pictures) am getting an exception.

While debugging I found out it process the pages which does not have a picture and was converted to PDF from DOCX file. The code executes fine if the original file extension is DOC before converting to PDF and then converting to PNG images.

I do pass LoadOptions object with appropriate format while loading the document into Aspose.Words.Document (not sure if it matters) object and saving it with below code:

Aspose.Words.Document document = new Aspose.Words.Document(filePath, docLoadOptions);

document.Save(tempFolder + "filename.pdf", Aspose.Words.SaveFormat.Pdf);

Where am I going wrong, or is there any limitation of converting from DOCX to PDF causing this error.



Though it is a requirement to have it converted to PDF first then to PNG images it will be nice to know how to convert each page of DOC/DOCX to PNG. I have tried document.save() method but it only converts the first page to PNG.


See attachad pdf document.

Manmeet:

Error:<o:p></o:p>

I am trying to convert PDF’s pages to PNG images but getting an exception at<o:p></o:p>

“pngDevice.Process(pdfDocument.Pages(pageCount), imageStream)” line with message “Parameter is not Valid”.<o:p></o:p>

Background:<o:p></o:p>

I am Converting DOCX and DOC file to PDF and then each page of PDF to PNG images.<o:p></o:p>

Fails at:<o:p></o:p>

While converting some DOCX file containing headers & footers, tables especially images (copied screenshot or inserted pictures) am getting an exception.<o:p></o:p>

While debugging I found out it process the pages which does not have a picture and was converted to PDF from DOCX file. The code executes fine if the original file extension is DOC before converting to PDF and then converting to PNG images.<o:p></o:p>

I do pass LoadOptions object with appropriate format while loading the document into Aspose.Words.Document (not sure if it matters) object and saving it with below code:<o:p></o:p>

Aspose.Words.Document document = new Aspose.Words.Document(filePath, docLoadOptions);<o:p></o:p>

document.Save(tempFolder + “filename.pdf”, Aspose.Words.SaveFormat.Pdf);<o:p></o:p>

Where am I going wrong, or is there any limitation of converting from DOCX to PDF causing this error.

Hi Manmeet,


Thanks for using our products.


I
have tested the scenario using Aspose.Pdf for .NET 7.3.0 and I am getting Out of Memory error when trying to convert PDF pages into PNG format. For the
sake of correction, I have logged it in our issue tracking system as PDFNEWNET-34305. We
will investigate this issue in details and will keep you updated on the status
of a correction.


We
apologize for your inconvenience.


Manmeet:

Though it is a requirement to have it converted to PDF first then to PNG images it will be nice to know how to convert each page of DOC/DOCX to PNG. I have tried document.save() method but it only converts the first page to PNG.

Concerning to this issue, I am moving this thread to respective forum where my fellow workers taking care of Aspose.Words for .NET would be in better position to answer this query.

Hi Manmeet,

Thanks for your query.

Manmeet:
Though it is a requirement to have it converted to PDF first then to PNG images it will be nice to know how to convert each page of DOC/DOCX to PNG. I have tried document.save() method but it only converts the first page to PNG.

Please use the following code snippet to convert each page of a Word document into a PNG image and read following documentation of links for your kind reference.

http://www.aspose.com/docs/display/wordsnet/ImageSaveOptions+Members

http://www.aspose.com/docs/display/wordsnet/ImageSaveOptions+Class

http://www.aspose.com/docs/display/wordsnet/Document+Features+Supported+on+Image+Export


<span lang=“EN-GB” style=“font-family:“Courier New”;color:#2B91AF;mso-ansi-language:EN-GB;
mso-no-proof:yes”>Document<span lang=“EN-GB” style=“font-family:“Courier New”;
mso-ansi-language:EN-GB;mso-no-proof:yes”> doc = new
Document(MyDir + “in.doc”);<o:p></o:p>

ImageSaveOptions options = new ImageSaveOptions(SaveFormat.Png);

options.PageCount = 1;

for (int pageIndex = 0; pageIndex < doc.PageCount; pageIndex++)

{

string outputFileName = MyDir + string.Format("{0}_{1}.png", "AsposeOut", pageIndex + 1);

options.PageIndex = pageIndex;

doc.Save(outputFileName, options);

}

Please let us know if you have any more queries.

The issues you have found earlier (filed as PDFNEWNET-34305) have been fixed in Aspose.Pdf for .NET 7.6.0.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan