Hi All,
I am very happy in using aspose.words. But i had a requirement like this:
1. I am having an html content that has say for example two images and an
between them
between them
2. When i am trying to convert this to .doc file i am able to get these images but not the
( horizontal line).
( horizontal line).
Code snippet:
//for getting the two images paths in that html and added to an array
while (true)
{
int idx1 = htmlContent.IndexOf("<img");
if (idx1 < 0)
break;
int idx2 = htmlContent.IndexOf(">", idx1);
string imstring = htmlContent.Substring(idx1, idx2 - idx1);
htmlContent = htmlContent.Substring(idx2 + 2);
idx2 = imstring.Replace("&", “&”).IndexOf("&EmailTemplate");
int start = imstring.IndexOf("?filename=") + 10;
int len = idx2 - start;
string strEncFilePath = imstring.Substring(start, len);
strEncFilePath = System.Web.HttpUtility.UrlDecode(strEncFilePath);
strEncFilePath = strEncFilePath.Replace("@", “^”);
strEncFilePath = Encryption.SecureDecrypt(strEncFilePath, Encryption.KeyTypes.URL, Encryption.EncodingTypes.Base64);
imnames.Add(strEncFilePath);
}
//go through each shape in the document and assign the actuall source to each image. (here i need
to skip if that is not an image. i will be thankful if u can suggest me to check wether it is image or not)
Aspose.Words.Document doc = new Aspose.Words.Document(strHTMLFilePath);
Aspose.Words.DocumentBuilder db = new DocumentBuilder(doc);
NodeCollection shapes = doc.GetChildNodes(NodeType.Shape, true, false);
int imageIndex = 1;
foreach (Aspose.Words.Drawing.Shape shape in shapes)
{
if (shape.Name == “”)
{
shape.ImageData.SourceFullName = (string)imnames[imageIndex - 1];
shape.ImageData.SetImage((string)imnames[imageIndex - 1]);
System.Threading.Thread.Sleep(Int32.Parse(strWordSleepTime));
shape.Height = 100;
shape.Width = 100;
}
imageIndex++;
}
doc.Save(strScratchpadDirectoryPath + strWordFileName, SaveFormat.Doc);
With this code i am getting the document but that
is not comming. (it is comming but as a missed image)
is not comming. (it is comming but as a missed image)
I will be very helpfull if someone help me here.
Thanks,
Yashwanth