Hi,
I am using HtmlConverter in my code and it is working fine when there is no image tag in the html that i am trying to convert to WordML, but when i have an image then the word doc shows the following pop ups
"We're sorry. We can't open Test.docx because we found a problem with its contents"
and the details contains
"Unspecified error
Location: Part: /word.header1.xml, Line 1, Column: 0"
followed by another popup
"Word found unreadable content in "Test.docx". Do you want to recover the contents of this document? If you trust the source of this document, click Yes"
The HTML is something like this, it is generated by a Rich text editor
This is test string <p> </p><p> </p><p> </p><img src="/api/ImageApi/GetImageById?id=47">
When creating the HtmlConverter object i am setting ImageProcessing attr to ImageProcessing.ManualProvisioning and
ProvisionImage += converter_ProvisionImage;
in converter_ProvisionImage() function I make a web service call and set the
e.Data to the byte array that the service call returns.
The code is something like this
static void converter_ProvisionImage(object sender, ProvisionImageEventArgs e)
Please help me out here as it is a critical functionality in my project.
I am using HtmlConverter in my code and it is working fine when there is no image tag in the html that i am trying to convert to WordML, but when i have an image then the word doc shows the following pop ups
"We're sorry. We can't open Test.docx because we found a problem with its contents"
and the details contains
"Unspecified error
Location: Part: /word.header1.xml, Line 1, Column: 0"
followed by another popup
"Word found unreadable content in "Test.docx". Do you want to recover the contents of this document? If you trust the source of this document, click Yes"
The HTML is something like this, it is generated by a Rich text editor
This is test string <p> </p><p> </p><p> </p><img src="/api/ImageApi/GetImageById?id=47">
When creating the HtmlConverter object i am setting ImageProcessing attr to ImageProcessing.ManualProvisioning and
ProvisionImage += converter_ProvisionImage;
in converter_ProvisionImage() function I make a web service call and set the
e.Data to the byte array that the service call returns.
The code is something like this
static void converter_ProvisionImage(object sender, ProvisionImageEventArgs e)
{
HttpWebRequest request = null;
if (e.ImageUrl.IsAbsoluteUri)
request = (HttpWebRequest)WebRequest.Create(e.ImageUrl.OriginalString);
else
request = (HttpWebRequest)WebRequest.Create(BaseURL + e.ImageUrl.OriginalString);
request.Method = "GET";
request.ContentLength = 0;
request.ContentType = "application/octet-stream";
request.UseDefaultCredentials = true;
using (var response = (HttpWebResponse)request.GetResponse())
{
var responseValue = string.Empty;
if (response.StatusCode != HttpStatusCode.OK)
{
string message = String.Format("POST failed. Received HTTP {0}", response.StatusCode);
throw new ApplicationException(message);
}
// grab the response
using (Stream reader = response.GetResponseStream())
{
byte[] b = null;
using (MemoryStream ms = new MemoryStream())
{
int count = 0;
do
{
byte[] buf = new byte[1024];
count = reader.Read(buf, 0, 1024);
ms.Write(buf, 0, count);
} while (reader.CanRead && count > 0);
b = ms.ToArray();
}
e.Data = b;
e.ImageExtension = ImagePartType.Png;
}
}
}
Am I missing something in this function ?Please help me out here as it is a critical functionality in my project.