Docx to PDF renders fail seemingly at random

We use ‘asposewordscloud’ in node JS to convert docx files to pdf. It seems that certain files from certain clients do not convert to PDF at all and result in a 500 status code when we use convertDocument(convertRequest).

I’ve downloaded the problematic file and sent a request from my PC but it fails every time, when I “Save as” the file, it seems the work, as if it was a localization issue or something but from what I can tell, the word file is in English.

This is only part of the response body but hopefully this is enough:

"body":{"requestId":"3016d81d0d98fe933076ba1d56d3837c","error":{"message":"Object reference not set to an instance of an object."}

If not, this is the rest of the response excluding the above and a bearer token:

{"response":{"statusCode":500,"body":{"type":"Buffer","data":[123,13,10,32,32,34,69,114,114,111,114,34,58,32,123,13,10,32,32,32,32,34,77,101,115,115,97,103,101,34,58,32,34,79,98,106,101,99,116,32,114,101,102,101,114,101,110,99,101,32,110,111,116,32,115,101,116,32,116,111,32,97,110,32,105,110,115,116,97,110,99,101,32,111,102,32,97,110,32,111,98,106,101,99,116,46,34,13,10,32,32,125,44,13,10,32,32,34,82,101,113,117,101,115,116,73,100,34,58,32,34,51,48,49,54,100,56,49,100,48,100,57,56,102,101,57,51,51,48,55,54,98,97,49,100,53,54,100,51,56,51,55,99,34,13,10,125]},"headers":{"date":"Tue, 25 Jun 2024 00:32:29 GMT","content-type":"application/json; charset=utf-8","content-length":"147","connection":"close"},"request":{"uri":{"protocol":"https:","slashes":true,"auth":null,"host":"api.aspose.cloud","port":null,"hostname":"api.aspose.cloud","hash":null,"search":"?format=pdf","query":"format=pdf","pathname":"/v4.0/words/convert","path":"/v4.0/words/convert?format=pdf","href":"https://api.aspose.cloud/v4.0/words/convert?format=pdf"},"method":"PUT","headers":{"Content-Type":"application/octet-stream","x-aspose-client":"nodejs sdk","x-aspose-client-version":"24.6"

I can’t post the original document here since it contains sensitive info and this is a public forum, I hope that the request ID can let you track it somehow and pinpoint the issue.

The original title of this post is accurate because in our node JS server, this file would sometimes render and sometimes not but it 100% doesn’t render locally.

@quality_forward Please create your topic on the related cloud forum - Aspose.Words Cloud Product Family - Free Support Forum - aspose.cloud

Hello,

We have faced the same issue. Currently we found out that aspose can’t convert .docx saved in google sheets. Files which are saved with MS word → works. It started to happen since 20 of June.

Update:
I suppose this ticket is related with this case NullPointerException is raised when converting a Word document to PDf

@TeamBitSupport Could you please provide your document here for testing?

@vyacheslav.deryushev this is the file saved in MS Word
Teambit-LT-template.docx (20.1 KB)

And for example, this is the file from google docs
Untitled document (1).docx (6.7 KB)

For example, if you open Untitled document (1) file with MS Word and save it, it’s going to convert just fine.

I face the same symptoms, and it looks like indeed at around the 20th of June, google docs exports are no longer converting.

@TeamBitSupport
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WORDSNET-27139

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@quality_forward If possible, could you send your document to us? You can create a new private thread for it, or send it via personal messages on the forum.

I’ve made a private response here - https://forum.aspose.cloud/t/docx-to-pdf-renders-fail-seemingly-at-random/23879/8

@quality_forward Ok, I have no access to this forum. Our colleges from cloud team will help you shortly.

Hey, any new info regarding google docs not converting?

@quality_forward The problem has been fixed. The fix will be available in an upcoming release.

Thanks, what’s the ETA on the next release?

@quality_forward Since you are using the Aspose.Words Cloud, please ask about the release date on the appropriate forum. There is no ETA for Aspose.Words release, but I think it will be released next week.

Thanks, I didn’t know they released separately, I assumed they both have the same issue.

The error “Object reference not set to an instance of an object” usually indicates accessing an uninitialized object. To troubleshoot:

  1. Validate the File: Ensure the DOCX file isn’t corrupt. Try re-saving it in Word.
  2. Check Content: Look for special characters, non-standard fonts, or localized content causing issues.
  3. Update SDK: Use the latest Aspose.Words Cloud SDK for Node.js.
  4. SDK Setup: Verify correct initialization and API credentials.
  5. File Size: Large files might cause issues; adjust timeout settings if needed.
  6. Error Handling: Enhance error logging around the convertDocument call.

Example:

javascript

Copy code

const asposewordscloud = require('asposewordscloud');
const fs = require('fs');

const wordsApi = new asposewordscloud.WordsApi("Client Id", "Client Secret");

const convertDocument = async (filePath, outputPath) => {
  try {
    const fileBuffer = fs.readFileSync(filePath);
    const convertRequest = new asposewordscloud.ConvertDocumentRequest({ document: fileBuffer, format: 'pdf' });
    const result = await wordsApi.convertDocument(convertRequest);
    fs.writeFileSync(outputPath, result.body);
    console.log("Document converted successfully.");
  } catch (error) {
    console.error("Error during document conversion:", error.message);
  }
};

convertDocument("path/to/input.docx", "path/to/output.pdf");

Contact Aspose Support with the request ID for further help. While in Toronto, ensure all your Word documents meet compatibility requirements before conversion.

@quality_forward Aspose.Words Cloud is a different team, so I can’t provide you with information about their processes. Thank you for your understanding.

@jtaylor23 Thank you for providing steps to resolve the issues which is can be helpfull for others. However, issue mentioned in this post specifically related to the documents with the styles from Google Docs.

The issues you have found earlier (filed as WORDSNET-27139) have been fixed in this Aspose.Words for .NET 24.7 update also available on NuGet.