Attempting to convert the attached file throws a Null Reference Exception from within an Aspose library included in the GroupDocs product.
We are using the most up to date version of convert available.
This appears to be related to the changes-tracking.
Is there an easy way to strip out the changes tracking or otherwise work around this issue?
Copy - Copy.docx (23.8 KB)
@JacobBodmer
To address the Null Reference Exception you are encountering while converting a DOCX file to PDF, it seems to be related to the changes tracking feature in the document. A straightforward solution is to disable the visibility of tracked changes during the conversion process.
You can achieve this by using the WordProcessingLoadOptions
class and setting the HideWordTrackedChanges
property to true
. Below is a C# code example demonstrating how to implement this:
using System;
using System.IO;
using GroupDocs.Conversion;
using GroupDocs.Conversion.Options.Convert;
using GroupDocs.Conversion.Options.Load;
namespace DocumentConversionExample
{
internal static class ConvertWordProcessingByHidingTrackedChanges
{
public static void Run()
{
string outputFolder = "YourOutputDirectoryPath"; // Specify your output directory
string outputFile = Path.Combine(outputFolder, "converted.pdf");
Func<LoadOptions> getLoadOptions = () => new WordProcessingLoadOptions
{
HideWordTrackedChanges = true // This hides tracked changes
};
using (Converter converter = new Converter("YourInputFilePath.docx", getLoadOptions)) // Specify your input file path
{
PdfConvertOptions options = new PdfConvertOptions();
converter.Convert(outputFile, options);
}
Console.WriteLine("WordProcessing document converted successfully. Check output in {0}", outputFolder);
}
}
}
Make sure to replace "YourOutputDirectoryPath"
and "YourInputFilePath.docx"
with the actual paths you are using. This code will convert the DOCX file to PDF while hiding any tracked changes, which should help you avoid the Null Reference Exception.
If you have any further questions or need additional assistance, feel free to ask!