cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Regular Visitor

OneDrive conversion to PDF fails with error WordFileTypeBlocked

Our flow is using the OneDrive for Business connector to convert a combined DOCX file to PDF document but lately we noticed its throwing a 400 error as below:

 

{
  "status": 400,
  "message": "Error from Office Service. Url= HttpCode= OK ResponseHeaders=ResponseCode: Failure\r\n
ErrorCode: WordFileTypeBlocked
\r\nIsExpectedFailure: True\r\nErrorCategory: BadRequest\r\nServiceID: ca393fad-0cd5-4c58-afa8-39a9eea80e16\r\nOutputFormat: PDF\r\nServiceRegion: CanadaCentral\r\nConversionTime: 1281.2599\r\nSourceFileDownloadTimeInMs: 250.0066\r\nDate: Mon, 13 Aug 2018 16:28:42 GMT\r\nServer: Microsoft-IIS/8.5\r\nX-Powered-By: ASP.NET\r\n", "source": "api.connectorp.svc.ms" }

We are able to open the Word file in Word Online as well as Word Client editor. 

 

This was working fine before...

Any ideas?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

So I ended up not using the HTML injection into Word. I had the XSLT to transform my xml data into HTML before. I changed it to generate OOXML Markup for the native MS Word Table structure and injected the table as a Part into my master Word file. that worked with no problem!

View solution in original post

6 REPLIES 6
Highlighted
Advocate I
Advocate I

Is this error always popping up or does it sometimes happen and sometimes not? I also wonder if the Docx file itself changed recently? The name for instance or how it was created?

It started failing when we incorporated HTML content into our word file. 

 

 XslTransform myXslTransform;
                            myXslTransform = new XslTransform();
                            myXslTransform.Load(new XmlTextReader(new StringReader(Properties.Resources.Table)));
                            XmlDocument doc = new XmlDocument();
                            var xmlStr = container.GetRootDirectoryReference().GetDirectoryReference(name).GetFileReference((file as CloudFile).Name).DownloadText();
                            string byteOrderMarkUtf8 = Encoding.UTF8.GetString(Encoding.UTF8.GetPreamble());
                            if (xmlStr.StartsWith(byteOrderMarkUtf8, StringComparison.Ordinal))
                            {
                                xmlStr = xmlStr.Remove(0, byteOrderMarkUtf8.Length);
                            }
                            doc.LoadXml(xmlStr);
                            var tw = new StringWriter();
                            myXslTransform.Transform(doc.CreateNavigator(), new XsltArgumentList() { }, tw);


                            var chunk = mainPart.AddAlternativeFormatImportPart(AlternativeFormatImportPartType.Html, altChunkId);

                            chunk.FeedData(new MemoryStream(Encoding.ASCII.GetBytes(tw.ToString())));

This code produces a HTML table using XLST transformation with an xml file and the output looks like 

<table cellpadding="10" width="500" align="center" style="border: solid 1pt;border-spacing: 0;" xmlns:x="http://schemas.microsoft.com/office/2008/07/excelservices/rest">
  <thead style="background-color:#eee;">
    <tr border="0">
      <td style="border-bottom: solid 1pt" width="70%" align="center">Payment Date or Milestone</td>
      <td style="border-bottom: solid 1pt;border-left: solid 1pt" align="center">Amount</td>
    </tr>
  </thead>
  <tbody>
    <tr border="0">
      <td style="border-bottom: solid 0.5pt" width="70%">August 31, 2018</td>
      <td style="border-bottom: solid 0.5pt;border-left: solid 1pt" align="right">$24,032.40</td>
    </tr>
    <tr border="0">
      <td style="border-bottom: solid 0.5pt" width="70%">October 31, 2018</td>
      <td style="border-bottom: solid 0.5pt;border-left: solid 1pt" align="right">$10,299.60</td>
    </tr>
  </tbody>
</table>

Document can be opened in Word Online or Word Client app without any warnings or errors but OneDrive PDF conversion fails. 

Highlighted
Regular Visitor

I was able to confirm that the conversation fails if there’s HTML content in ms word file
Highlighted

I recently used the conversion action as well. As far as I remember if you use a .docx and passed it on to the conversion action (OneDrive) with target .pdf, it will expect binary information. Maybe this is why it fails? It's just a guess at this point.

 

Can you include the HTML content some other way into the document? Or is this not possible. When I do a convert, I always use a compose action, fill it with HTML and dynamically add in the data (from SharePoint or MS Forms) and then create a .html file. This file is then used as input in the OneDrive for Business convert action. This always works for me. Maybe you can try this approach? I don't know if this is possible in your business scenario, but if so you can easily generate pdfs from HTML without further issue. The already included HTML isn't going to be the problem anymore in that case.

Highlighted

So I ended up not using the HTML injection into Word. I had the XSLT to transform my xml data into HTML before. I changed it to generate OOXML Markup for the native MS Word Table structure and injected the table as a Part into my master Word file. that worked with no problem!

View solution in original post

Highlighted

Thanks for the update and I'm glad everything worked out.

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Top Solution Authors
Top Kudoed Authors
Users online (7,265)