Text color changing after converting word to pdf

Hi Support Team,

I initially posted the following on https://forum.aspose.com and I was asked to post on https://forum.aspose.cloud by one of your support team member

We are a licensed user, we are using Aspose.Words REST API to convert Word to PDF. We ran into an issue while converting word document to pdf. Word document has many hyperlinks with blue text, after converting to pdf some link text is blue and for some it is black. The text color before and after conversion are not same. Can you fix this please as this is very critical for us.

Please find the attached file for investigation Hyperlink text color.zip (21.1 KB) The text Table 1. on page 2 in word is blue but after converting to pdf it is black.

We are using the following code

Stream result = null;
// ExStart:1
WordsApi wordsApi = new WordsApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH);
StorageApi storageApi = new StorageApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH);

    // Set input file name
    String fileName = string.Format("{0}{1}", Guid.NewGuid().ToString().Replace("-", ""), inputFileFormat);
    String storage = null;
    String folder = null;

    Com.Aspose.Words.Model.SaveOptionsData body = new Com.Aspose.Words.Model.SaveOptionsData();
    body.SaveFormat = outputFileFormat;
    body.FileName = string.Format("{0}.{1}", Guid.NewGuid().ToString().Replace("-", ""), body.SaveFormat);
    if(includeBookmarks)
        body.HeadingsOutlineLevels = 9;

    // Upload file to aspose cloud storage
    storageApi.PutCreate(fileName, null, null, inputStream.ToArray());

    // Invoke Aspose.Words Cloud SDK API to convert words document to required format
    SaveResponse apiResponse = wordsApi.PostDocumentSaveAs(fileName, storage, folder, body);

    if (apiResponse != null && apiResponse.Status.Equals("OK"))
    {
        Com.Aspose.Storage.Model.ResponseMessage storageRes = storageApi.GetDownload(body.FileName, null, null);
        result = new MemoryStream(storageRes.ResponseStream);
    }
    return result;

Regards
Rajendra

@prarajh

Thank you for contacting Aspose Support.

We are unable to reproduce the error on our end. Both links are appearing blue in the output PDF file Hyperlink text color.pdf (39.4 KB)

For further testing, I created another Word file with a number of headings and converted to PDF using POST /words/{name}/saveAs API but all links are appearing blue. Document with Headings.zip (61.4 KB)

This is a private thread, no one has access to this topic other than you and Aspose Staff, we would appreciate if you could share the exact file that is causing this error.

Please also ensure you are using our updated .NET SDK GitHub - aspose-words-cloud/aspose-words-cloud-dotnet: .NET library for communicating with the Aspose.Words Cloud API

Hi mateensajjad,

It was clearly mentioned in my previous query that the issue is in page 2. The text Table 1. on page 2 in word is blue but after converting to pdf it is black. Please verify.

@prarajh

We are sorry for the inconvenience caused.

We are able to reproduce the issue. The issue has been logged in our system with ID WORDSCLOUD-366 for a fix by our Development team. We’ll update you here as soon as we have a feedback of our Development team.

Hi Support Team,

Any updates on this issue from your development team.

Regards
Rajendra

@prarajh

This is not a bug. Table 1 text is the content of the Ref field. However, you can get your expected result by setting UpdateFields attribute value to false as shown in the following example:

public void TestPostDocumentSaveAs() {
        var localName = "Hyperlink text color.docx"; 
        var remoteName = "Hyperlink text color.docx";
        var fullName = Path.Combine(this.dataFolder, remoteName);
        var destFileName = Path.Combine(BaseTestOutPath, Path.GetFileNameWithoutExtension(remoteName) + ".pdf");
        var saveOptionsData = new SaveOptionsData { SaveFormat = "pdf", FileName = destFileName, UpdateFields = false };

        this.StorageApi.PutCreate(fullName, null, null, File.ReadAllBytes(BaseTestContext.GetDataDir(BaseTestContext.CommonFolder) + localName));

        var request = new PostDocumentSaveAsRequest(remoteName, saveOptionsData, this.dataFolder);
        var actual = this.WordsApi.PostDocumentSaveAs(request);

        Assert.AreEqual(200, actual.Code);
}

The example generated this output file: Hyperlink text color.pdf (39.4 KB)

The example code is calling APIs of this SDK GitHub - aspose-words-cloud/aspose-words-cloud-dotnet: .NET library for communicating with the Aspose.Words Cloud API

Hi Support,

Thanks for your suggestion.
Your suggestion resolved the issue.

Regards
Rajendra

@prarajh

It’s good to know that the suggestion has resolved your issue. Please keep using Aspose Cloud APIs.