Image Error

Hello,


I am having an issue displaying an image when converting a word document to pdf. I have attached an example word document and the converted pdf. The image at the top is displaying a red X instead of the image from the word document. The method that converts this is as follows:

public static void FormatConvertDocs(string sCopiedFileName, bool p_bRemoveSeal, string sTempLocation, out string sPDFName)
{
string sDocType = System.IO.Path.GetExtension(sCopiedFileName);
sPDFName = System.IO.Path.GetFileNameWithoutExtension(sCopiedFileName);

//4. we need to check if the type is a document, if it is then we don’t need to convert it
if (sDocType.ToLower() != “.pdf”)
{
Aspose.Words.Document objDoc = new Aspose.Words.Document(sCopiedFileName);

if (p_bRemoveSeal)
{
//remove the seal - return as txt file?
objDoc.Save(sTempLocation + sPDFName + “.txt”);
File.Delete(sCopiedFileName);
}
else
{
int iNumberSections = objDoc.Sections.Count;

//is there a blank page? if so remove it
if (objDoc.Sections[iNumberSections - 1].Body.GetText() == “\f”)
{
//Ciara - Image Issue - 06/05/2016
Aspose.Words.NodeCollection shapes = objDoc.GetChildNodes(Aspose.Words.NodeType.Shape, true);

foreach (Aspose.Words.Drawing.Shape shape in shapes)
{
if (!shape.HasImage)
{
//empty last page here do something with it
objDoc.Sections[iNumberSections - 1].Remove();
}
}

//Ciara end
}

//check for hidden report text - EJO fault fixed by this
if (objDoc.Sections[0].Body.GetText().ToLower().Contains(“this file was created by oracle reports. view this document in page layout mode”))
{
int ipara = objDoc.Sections[0].Body.Paragraphs.Count;
if (objDoc.Sections[0].Body.Paragraphs[1].GetText().ToLower().Contains(“this file was created by oracle reports. view this document in page layout mode”))
{
objDoc.Sections[0].Body.Paragraphs[1].Remove();
}
else if (objDoc.Sections[0].Body.Paragraphs[0].GetText().ToLower().Contains(“this file was created by oracle reports. view this document in page layout mode”))
{
objDoc.Sections[0].Body.Paragraphs[0].Remove();
}
}

//do we have more than one page? then we need to tidy our headers and footers
if (iNumberSections > 1)
{
//are there headers and footers?
if (objDoc.Sections[0].HeadersFooters.Count > 0)
{
//get the main header
Aspose.Words.HeaderFooter x = objDoc.Sections[0].HeadersFooters[0];
Aspose.Words.HeaderFooter BottomFooter = objDoc.Sections[0].HeadersFooters[1];

//strip all the headers & footers from the document
int iNumberDocSections = objDoc.Sections.Count;
for (int i = iNumberDocSections - 1; i >= 0; i–)
{
int iNumberHeaderFooters = objDoc.Sections[i].HeadersFooters.Count;
for (int j = iNumberHeaderFooters - 1; j >= 0; j–)
{
objDoc.Sections[i].HeadersFooters[j].Remove();
}
}

//at this stage headers should be clear
objDoc.UpdateFields();
objDoc.AcceptAllRevisions();

//insert our header and footer
objDoc.Sections[0].HeadersFooters.Insert(0, x);
objDoc.Sections[0].HeadersFooters.Insert(1, BottomFooter);

//convert the document
objDoc.Save(sTempLocation + sPDFName + “.pdf”);
}
else
{
//no headers or footers
objDoc.Save(sTempLocation + sPDFName + “.pdf”);
}
}
else
{
//we’ve only one page no work to do here
objDoc.Save(sTempLocation + sPDFName + “.pdf”);
}

objDoc.Save(sTempLocation + sPDFName + “.pdf”);
File.Delete(sCopiedFileName);
}

//TODO - need to check here if we need to remove the seal
//TODO - need to check to see if the file has been deleted?
}
}
}


You should also note that this has started happening all of a sudden, there were no issues previously and no changes have ben made to the code or the template.

Any help with this is much appreciated.

Thanks
Ciara

Hi Ciara,


To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word document
  • Aspose.Words generated output document showing the undesired behavior
  • Please create a standalone console application (source code without compilation errors) that helps us reproduce your problem on our end and attach it here for testing.
  • Please also provide a little more information about the Aspose.Words’ version number for which there were no problems on your side previously.

As soon as you get these pieces of information ready, we’ll start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip them and Click ‘Reply’ button that will bring you to the ‘reply page’ and there at the bottom you can include any attachments with that post by clicking the ‘Add/Update’ button.

Best regards,

Hello,


The only other thing that the application does outside of the method above is that it picks up the word document of a location on the machine, it then runs through the method above to convert to pdf.

I have attached a sample word document and the out put pdf. I have attached the class file from my solution also.

Thank You
Ciara
Hi Ciara,

Thanks for your inquiry. After an initial test with Aspose.Words for .NET 16.4.0, I was unable to reproduce this issue on my side (please see attached 16.4.0.pdf). I would suggest you please upgrade to the latest version of Aspose.Words. You can download it from the following link. I hope, this helps.
http://www.aspose.com/downloads/words-family/net

Best regards,