Free Support Forum -

Convert Microsoft Word to PDF in C# using Aspose.Words REST API has missing images and highlighting issue


I am using the code snippet, to convert pdf to doc however the image and highlighting is missing

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 = "Rendering.docx";
 String storage = null;
 String folder = null;

 Com.Aspose.Words.Model.SaveOptionsData body = new Com.Aspose.Words.Model.SaveOptionsData();
 body.SaveFormat = "pdf";
 body.FileName = "output.pdf";

     // Upload file to aspose cloud storage
     storageApi.PutCreate(fileName, null, null, System.IO.File.ReadAllBytes(Common.GetDataDir() + fileName));

     // 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"))
         Console.WriteLine("doc:" + apiResponse.SaveResult.DestDocument.Href);
 catch (Exception ex)
     System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace);



Thank you for contacting Aspose Support.

The example you shared is converting Docx to PDF not PDF to Docx. I tested PostDocumentSaveAs API and it successfully converts the Docx file (containing Image and Highlighted text) to PDF. I have attached the Input and Output files for your consideration.

Source Files: Source (55.9 KB)
Output Files: Output (127.6 KB)

If you want to convert PDF document to Docx, please try ConvertPdfToOtherFormat or ConvertPdfToOtherFormatWithoutStorage example.

1 Like