I download the last version of Aspose.Words for evaluation. I used the Temporary license for testing. I have the issue with the document which has the image on it, the image is in png format.
Here is the code to embed the image:
private Aspose.Words.Document FillInImage(DataRow[] drMergeField,Aspose.Words.Document master)
{
string strValue;
Aspose.Words.DocumentBuilder db = new Aspose.Words.DocumentBuilder(master);
for (int i=0; i<drMergeField.Length; i++)
{
strValue = drMergeField[i]["FieldValue"].ToString();
if (strValue != "" && strValue != null && strValue.Length != 0)
{
//System.Drawing.Bitmap img = new Bitmap(strValue);
Image img = Image.FromFile(strValue);
//img = resizeImage(img, new Size(700, 580));
MemoryStream memStream = new MemoryStream();
img.Save(memStream, System.Drawing.Imaging.ImageFormat.Bmp);
db.MoveToBookmark(drMergeField[i]["FieldName"].ToString());
db.InsertImage(memStream);
memStream.Close();
master.Range.Bookmarks.Remove(drMergeField[i]["FieldName"].ToString());
}
}
return master;
}
And then in the Main, I save the master as PDF as follow:
//save to PDF
master.Save(p_SavePath, Aspose.Words.SaveFormat.Pdf);
master.Save(p_SavePath + ".doc", Aspose.Words.SaveFormat.Doc);
The issue is that the PDF did not have the image on it, but the doc save after that is correct with image.
I attached the original doc file, the image and also 2 results (pdf and doc).
And I also have another issue, I have big doc with some word bookmarks on it. In the code I will replace those bookmarks with space. Like above, the pdf is the original doc convert to pdf, the command after that convert to doc is correct with those bookmarks are cleared and replace with space. Here is the part of code which replace the bookmarks with space:
if (master.Range.Bookmarks[bookmarkName] != null)
{
master.Range.Bookmarks[bookmarkName].Text = mergeText;
master.Range.Bookmarks.Remove(bookmarkName);
}
Thanks.
Tom.