HTML to PDF Conversion is failing

Hi, I am getting the following error in the Log and PDF not getting created:

[04/14/2025 15:56:57 > f3d712: INFO] System.AggregateException: One or more errors occurred. (Object reference not set to an instance of an object.)
[04/14/2025 15:56:57 > f3d712: INFO] —> System.NullReferenceException: Object reference not set to an instance of an object.
[04/14/2025 15:56:57 > f3d712: INFO] at Aspose.HTML.Cloud.Sdk.Services.ConversionService.<>c__DisplayClass12_0.<b__0>d.MoveNext()
[04/14/2025 15:56:57 > f3d712: INFO] — End of stack trace from previous location —
[04/14/2025 15:56:57 > f3d712: INFO] at Aspose.HTML.Cloud.Sdk.Services.ConversionService.ExecuteConversionAsync(ConverterBuilder builder, IObserver1 observer) [04/14/2025 15:56:58 > f3d712: INFO] at Aspose.HTML.Cloud.Sdk.Services.ConversionService.ConvertAsync(ConverterBuilder builder, IObserver1 observer)
[04/14/2025 15:56:58 > f3d712: INFO] at Aspose.HTML.Cloud.Sdk.ConvertApi.ConvertAsync(ConverterBuilder builder, IObserver1 observer) [04/14/2025 15:56:58 > f3d712: INFO] at Aspose.HTML.Cloud.Sdk.ConvertApi.ConvertAsync(String inputFilePath, IList1 resources, String outputFilePath, ConversionOptions options, IObserver1 observer) [04/14/2025 15:56:58 > f3d712: INFO] --- End of inner exception stack trace --- [04/14/2025 15:56:58 > f3d712: INFO] at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) [04/14/2025 15:56:59 > f3d712: INFO] at System.Threading.Tasks.Task1.GetResultCore(Boolean waitCompletionNotification)
[04/14/2025 15:56:59 > f3d712: INFO] at System.Threading.Tasks.Task1.get_Result() [04/14/2025 15:56:59 > f3d712: INFO] at ConvertHtmlToPdf.Program.ConvertHtmlToPf(Project project) in C:\Development\Clients\RBSomerville\ConvertHtmlToPdf\Program.cs:line 177 [04/14/2025 15:56:59 > f3d712: INFO] at ConvertHtmlToPdf.Program.GeneratePDFs(List1 projects) in C:\Development\Clients\RBSomerville\ConvertHtmlToPdf\Program.cs:line 131

@devrajbanerjee

It seems that you are encountering a System.NullReferenceException during the HTML to PDF conversion process using Aspose’s API. This error typically indicates that your code is trying to access an object that has not been initialized.

Here are some steps you can take to troubleshoot and potentially resolve this issue:

  1. Check Input Files: Ensure that the input HTML files you are using for conversion are valid and accessible. If the files were previously successful, confirm that they have not been modified or corrupted.

  2. Review API Changes: Since you mentioned that this issue started occurring recently without any changes on your side, it might be related to updates or changes in the Aspose API. Check the Aspose documentation or forums for any announcements regarding changes that could affect the conversion process.

  3. Error Handling: Implement error handling in your code to catch exceptions and log more detailed information about the state of your application when the error occurs. This can help you identify which part of the code is causing the issue.

  4. Use Alternative Methods: If the ConvertAsync method is failing, consider using other available methods for conversion, such as synchronous conversion or different API endpoints, if applicable. For example, you can try converting HTML from a URL or using different conversion options.

  5. Contact Support: If the problem persists, consider reaching out to Aspose support with the details of your issue, including the stack trace and any relevant code snippets. They may be able to provide insights or confirm if there is a known issue with the API.

  6. Check for Known Issues: There have been reports of similar issues in the past, and Aspose has logged tickets for certain problems. It might be worth checking if your issue aligns with any known bugs that are being addressed.

If you need further assistance, please provide additional details about your implementation, and I would be happy to help!

One previously successfully converted file is no longer converting. We have not made any code changes done last two years. Is there any method change or SDK change?

Hi @devrajbanerjee please check now. It must be back to normal

Hi, we are still getting the error. Here is the log output again:

[04/15/2025 13:50:48 > f3d712: INFO] [13:50:48 INF] Starting Program.GeneratePDFs
[04/15/2025 13:50:48 > f3d712: INFO] [13:50:48 DBG] Program.GeneratePDFs: Processing 1 of 2
[04/15/2025 13:50:48 > f3d712: INFO] [13:50:48 INF] Starting Program.ConvertHtmlToPf
[04/15/2025 13:50:48 > f3d712: INFO] [13:50:48 DBG] Program.ConvertHtmlToPf: Processing the project test-1.cshtml
[04/15/2025 13:50:48 > f3d712: INFO] [13:50:48 INF] Starting Program.ReplaceToken
[04/15/2025 13:50:48 > f3d712: INFO] [13:50:48 INF] Program.ReplaceToken Done
[04/15/2025 13:50:48 > f3d712: INFO] [13:50:48 DBG] Program.ConvertHtmlToPf: Html file ‘C:\home\site\wwwroot\app_data\Jobs\Triggered\ConvertHtmlToPdf\Output\test-1.html’ is created successfully
[04/15/2025 13:50:50 > f3d712: INFO] [13:50:50 ERR] Error Occurred while generating PDF for project: test-1.cshtml
[04/15/2025 13:50:50 > f3d712: INFO] System.AggregateException: One or more errors occurred. (Object reference not set to an instance of an object.)
[04/15/2025 13:50:50 > f3d712: INFO] —> System.NullReferenceException: Object reference not set to an instance of an object.
[04/15/2025 13:50:50 > f3d712: INFO] at Aspose.HTML.Cloud.Sdk.Services.ConversionService.<>c__DisplayClass12_0.<b__0>d.MoveNext()
[04/15/2025 13:50:50 > f3d712: INFO] — End of stack trace from previous location —
[04/15/2025 13:50:50 > f3d712: INFO] at Aspose.HTML.Cloud.Sdk.Services.ConversionService.ExecuteConversionAsync(ConverterBuilder builder, IObserver1 observer) [04/15/2025 13:50:50 > f3d712: INFO] at Aspose.HTML.Cloud.Sdk.Services.ConversionService.ConvertAsync(ConverterBuilder builder, IObserver1 observer)
[04/15/2025 13:50:50 > f3d712: INFO] at Aspose.HTML.Cloud.Sdk.ConvertApi.ConvertAsync(ConverterBuilder builder, IObserver1 observer) [04/15/2025 13:50:50 > f3d712: INFO] at Aspose.HTML.Cloud.Sdk.ConvertApi.ConvertAsync(String inputFilePath, IList1 resources, String outputFilePath, ConversionOptions options, IObserver1 observer) [04/15/2025 13:50:50 > f3d712: INFO] --- End of inner exception stack trace --- [04/15/2025 13:50:50 > f3d712: INFO] at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) [04/15/2025 13:50:50 > f3d712: INFO] at System.Threading.Tasks.Task1.GetResultCore(Boolean waitCompletionNotification)
[04/15/2025 13:50:50 > f3d712: INFO] at System.Threading.Tasks.Task1.get_Result() [04/15/2025 13:50:50 > f3d712: INFO] at ConvertHtmlToPdf.Program.ConvertHtmlToPf(Project project) in C:\Development\Clients\RBSomerville\ConvertHtmlToPdf\Program.cs:line 177 [04/15/2025 13:50:50 > f3d712: INFO] at ConvertHtmlToPdf.Program.GeneratePDFs(List1 projects) in C:\Development\Clients\RBSomerville\ConvertHtmlToPdf\Program.cs:line 131

Regards,
Devraj
test-1.zip (25.3 KB)

@devrajbanerjee Hi, please check if it works for you now. We released a couple of updates