Invalid param used error on PDF to HTML conversion

Hi Team,

We are getting a "Invalid param used " error on converting a PDF to HTML. Below is the stack trace.

Could you please let us know the cause for this issue.It is failing in the first page when we tried to split and execute page by page.

“error”: {
“Error”: “com.aspose.pdf.internal.ms.System.lh”,
“Cause”: “{"errorMessage":"Invalid parameter used.","errorType":"com.aspose.pdf.internal.ms.System.lh","stackTrace":["com.aspose.pdf.internal.l66p.l0k.lj(Unknown Source)","com.aspose.pdf.internal.l66p.l0k.lj(Unknown Source)","com.aspose.pdf.internal.l66t.l2p.lj(Unknown Source)","com.aspose.pdf.internal.l66t.l2p.lf(Unknown Source)","com.aspose.pdf.internal.l66t.l2p.lI(Unknown Source)","com.aspose.pdf.internal.l66t.l2p.lt(Unknown Source)","com.aspose.pdf.internal.l66t.l2p.lf(Unknown Source)","com.aspose.pdf.internal.l66t.l2p.lI(Unknown Source)","com.aspose.pdf.internal.l66t.l2p.lI(Unknown Source)","com.aspose.pdf.internal.l25f.lj.visitPathEnd(Unknown Source)","com.aspose.pdf.internal.foundation.rendering.l2if.accept(Unknown Source)","com.aspose.pdf.internal.foundation.rendering.l0if.accept(Unknown Source)","com.aspose.pdf.internal.foundation.rendering.lv.accept(Unknown Source)","com.aspose.pdf.internal.foundation.rendering.l0if.accept(Unknown Source)","com.aspose.pdf.internal.foundation.rendering.lv.accept(Unknown Source)","com.aspose.pdf.internal.foundation.rendering.l0if.accept(Unknown Source)","com.aspose.pdf.internal.foundation.rendering.l1k.accept(Unknown Source)","com.aspose.pdf.internal.l25f.lj.lI(Unknown Source)","com.aspose.pdf.internal.l25f.lj.lI(Unknown Source)","com.aspose.pdf.internal.l1n.lf.lI(Unknown Source)","com.aspose.pdf.internal.l1n.lf.lI(Unknown Source)","com.aspose.pdf.internal.l1h.lj.lI(Unknown Source)","com.aspose.pdf.internal.l1h.lj.lI(Unknown Source)","com.aspose.pdf.internal.l18l.ld.lI(Unknown Source)","com.aspose.pdf.internal.l18l.lv.lI(Unknown Source)","com.aspose.pdf.internal.l18l.lb.lI(Unknown Source)","com.aspose.pdf.internal.l17f.lj.lI(Unknown Source)","com.aspose.pdf.internal.l1j.lh.lI(Unknown Source)","com.aspose.pdf.l3t.lI(Unknown Source)","com.aspose.pdf.l3t.lI(Unknown Source)","com.aspose.pdf.ADocument.ld(Unknown Source)","com.aspose.pdf.ADocument.lt(Unknown Source)","com.aspose.pdf.ADocument.lI(Unknown Source)","com.aspose.pdf.Document.lI(Unknown Source)","com.aspose.pdf.ADocument.save(Unknown Source)","com.aspose.pdf.Document.save(Unknown Source)","org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:321)","com.tr.cns.documenttohtml.service.ConvertPDFToHtmlImpl.performSave(ConvertPDFToHtmlImpl.groovy:186)","org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:321)","com.tr.cns.documenttohtml.service.ConvertPDFToHtmlImpl.saveHtmlFile(ConvertPDFToHtmlImpl.groovy:170)","org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:321)","com.tr.cns.documenttohtml.service.ConvertPDFToHtmlImpl.convertToHtml(ConvertPDFToHtmlImpl.groovy:99)","org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:321)","com.tr.cns.documenttohtml.service.ConversionService.convertDocument(ConversionService.groovy:99)","org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:321)","com.tr.cns.documenttohtml.service.ConversionService.convertDocumentWithInputInS3(ConversionService.groovy:124)","org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:321)","com.tr.cns.documenttohtml.service.ConversionService.processRequest(ConversionService.groovy:61)","org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:321)","com.tr.cns.documenttohtml.DocumentToHTMLLambda.doHandleRequest(DocumentToHTMLLambda.groovy:48)","org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:321)","com.tr.cns.documenttohtml.DocumentToHTMLLambda.processMessage(DocumentToHTMLLambda.groovy:77)","com.tr.cns.documenttohtml.DocumentToHTMLLambda$processMessage.callCurrent(Unknown Source)","com.tr.cars.awsclients.sfn.StepFunctionBaseLambdaHandler.handleRequest(StepFunctionBaseLambdaHandler.groovy:27)","java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)","java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)","java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)","java.base/java.lang.reflect.Method.invoke(Unknown Source)"]}”

The pdf we are trying to process is here:

We are using AWS Java.al2 linux env​
Aspose version : 24.6

@treutersaspose

The “Invalid param used” error you are encountering during the PDF to HTML conversion can be caused by several factors, particularly related to the parameters or options being used in the conversion process. Here are some steps you can take to troubleshoot and potentially resolve the issue:

  1. Check PDF Document Integrity: Ensure that the PDF document you are trying to convert is not corrupted. You can try opening it in a PDF viewer to verify that it displays correctly.

  2. Update Aspose Library: You are using Aspose version 24.6, which may have bugs that have been fixed in later versions. Consider updating to the latest version of the Aspose.PDF library to benefit from improvements and bug fixes.

  3. Review Conversion Options: When converting PDF to HTML, specific options can affect the outcome. For instance, if you are using HtmlSaveOptions, ensure that the parameters you are setting are valid. Here’s an example of how to set up the conversion options correctly:

    Document pdfDocument = new Document("path/to/your/document.pdf");
    HtmlSaveOptions htmlOptions = new HtmlSaveOptions();
    htmlOptions.setSplitIntoPages(true); // If you want to split the output into multiple pages
    pdfDocument.save("output.html", htmlOptions);
    
  4. Test with Different Options: If you are using specific options like FixedLayout, try disabling them to see if the error persists. For example:

    htmlOptions.setFixedLayout(false);
    
  5. Isolate the Problem: Since the error occurs on the first page, try converting only that page to see if the issue is specific to the content on that page. You can specify the page to convert using:

    htmlOptions.setExplicitListOfSavedPages(new int[] { 1 }); // Convert only the first page
    
  6. Check for Unsupported Features: Some PDF features may not be supported during conversion. If your PDF contains complex elements (like certain types of images or fonts), consider simplifying the document or removing those elements.

If the problem persists after trying these steps, you may want to reach out to Aspose support with the specific PDF file and the code you are using for further assistance.

Sources:
[1]: PDFToHTML.cs
[2]: PDFToHTMLAvoidSavingImagesInSVGFormat.java