I want to iterate through every image type (diagrams, custom shapes, images) line by line in word document(.docx) and upload the image type to cloud and pass the image url to src tag of converted html file.
I used two loop to iterate through images and custom shape.
Loop 1 :
Document newDoc = new Document(sourceDocumentFileName);
List<string> imgUris = new List<string>();
foreach (DrawingML s in newDoc.GetChildNodes(NodeType.DrawingML, true))
{
if (s.HasImage)
{
// upload the image to cloud server and retrieve new url
string imgUrl = UploadImageToServer(s);
imgUris.Add(imgUrl);
string imgName = Path.GetFileName(imgUrl);
s.AlternativeText = imgName;
}
}
Loop 2 :
foreach (Shape st in newDoc.GetChildNodes(NodeType.Shape, true))
{
if (st.HasImage)
{
// upload the image to cloud and retrieve new url
string imgURL = string.Empty;
string imageFileName = Server.MapPath("~/Documents/" + Guid.NewGuid().ToString("N") + st.Name + "." + st.ImageData.ImageType);
st.ImageData.Save(imageFileName);
CloudBlockBlob blockBlobSOPDocImage = Azure.UploadToBlob(Path.GetFileName(imageFileName), imageFileName, strBlobContainer);
if (System.IO.File.Exists(imageFileName))
{
System.IO.File.Delete(imageFileName);
}
string imgUrl = blockBlobSOPDocImage.Uri.ToString();
imgUris.Add(imgUrl);
string imgName = Path.GetFileName(imgUrl);
st.AlternativeText = imgName;
}
}
My query is that, is there any way to loop through entire document and find the image type line by line and upload image to cloud respectively.
Q.1 : Can this be done using single loop ? and How ?
Q.2 : Is there any way to identify and save custom shape to cloud, as custom shapes has no image type extension, tried hard coding the image extension but of no use,
I bought the license but unable to meet the requirement via Aspose.Words,
I am afraid, If Aspose can solve this issue !
Attached a sample document.
My query is that, is there any way to loop through entire document and find the image type line by line and upload image to cloud respectively.Q.1 : Can this be done using single loop ? and How ?Q.2 : Is there any way to identify and save custom shape to cloud, as custom shapes has no image type extension, tried hard coding the image extension but of no use,I bought the license but unable to meet the requirement via Aspose.Words,I am afraid, If Aspose can solve this issue !Attached a sample document.