Invalid parameter used - PDF to HTML Conversion

Hi Team,
We are getting “Invalid paramtere used” error when we try to convert PDF to HTML.
We need you assistance to determine how we can resolve this error.

Below is the stacktrace of the same .​Let us know id you need any additional information.

“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)","org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)","org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:171)","org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:194)","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)"]}”

Setup:
Aspose version : 24.6
Java version : Java8

​Thanks in advance !

@treutersaspose

The “Invalid parameter used” error during PDF to HTML conversion can occur due to various reasons, such as incorrect parameters being passed to the conversion method or issues with the PDF document itself. Here are some steps you can take to troubleshoot and potentially resolve this 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 its integrity.

  2. Update Aspose Library: You are using Aspose version 24.6. Consider updating to the latest version of the Aspose.PDF library, as newer versions may contain bug fixes and improvements that could resolve your issue.

  3. Review Conversion Code: Ensure that the code you are using for the conversion is correct. Here is a basic example of how to convert a PDF to HTML using Aspose.PDF in Java:

    import com.aspose.pdf.Document;
    import com.aspose.pdf.HtmlSaveOptions;
    
    public class PDFToHTMLExample {
        public static void main(String[] args) {
            // Load the PDF document
            Document pdfDocument = new Document("path/to/your/document.pdf");
    
            // Create HTML save options
            HtmlSaveOptions htmlSaveOptions = new HtmlSaveOptions();
            htmlSaveOptions.setSplitIntoPages(true); // Optional: Split into multiple pages
    
            // Save the document as HTML
            pdfDocument.save("path/to/output/document.html", htmlSaveOptions);
        }
    }
    
  4. Check Parameters: If you are using any specific options or parameters in your conversion, ensure they are valid. For example, if you are excluding certain font resources or setting specific layout options, double-check that these settings are appropriate for your document.

  5. Consult Documentation: Review the Aspose.PDF documentation for any specific requirements or limitations regarding PDF to HTML conversion. This can provide insights into what parameters are valid and how to use them correctly.

If the issue persists after trying these steps, consider providing additional details about the specific parameters you are using or any other relevant information about the PDF document. This can help in diagnosing the problem more effectively.

If you need further assistance, feel free to ask!

Hi Team,
The pdf used for conversion is valid one . We have used these additional save options.

private void configureSaveOptions(HtmlSaveOptions saveOptions, boolean externalDependencies)
{
saveOptions.partsEmbeddingMode = externalDependencies ? HtmlSaveOptions.PartsEmbeddingModes.EmbedCssOnly : HtmlSaveOptions.PartsEmbeddingModes.EmbedAllIntoHtml

    saveOptions.lettersPositioningMethod =
            LettersPositioningMethods.UseEmUnitsAndCompensationOfRoundingErrorsInCss

    saveOptions.rasterImagesSavingMode =
            externalDependencies ? HtmlSaveOptions.RasterImagesSavingModes.AsExternalPngFilesReferencedViaSvg : HtmlSaveOptions.RasterImagesSavingModes.AsEmbeddedPartsOfPngPageBackground

    saveOptions.fontSavingMode = HtmlSaveOptions.FontSavingModes.SaveInAllFormats
}

Am also attaching one of the pdf files which are failing with the error.
06209403-00000001-000016523-fs2651_SRSDPCF-PDF.pdf (271.7 KB)

06099853-00000035-000001833-Fund_Facts_EN-PDF.pdf (620.1 KB)

06218410-00000001-000005496-Voting_Instruction_Form-PDF.pdf (267.1 KB)

Could you please check if any of these configuration is impacting.

Thanks in advance

@treutersaspose

We have tested the scenario with the latest version of the API in our environment using below code snippet and could not replicate the issue that you have mentioned.

Document doc = new Document(dataDir + "06209403-00000001-000016523-fs2651_SRSDPCF-PDF.pdf");
HtmlSaveOptions saveOptions = new HtmlSaveOptions();
saveOptions.setFixedLayout(true);
saveOptions.setPartsEmbeddingMode(HtmlSaveOptions.PartsEmbeddingModes.EmbedAllIntoHtml);
saveOptions.setRasterImagesSavingMode(HtmlSaveOptions.RasterImagesSavingModes.AsExternalPngFilesReferencedViaSvg);
saveOptions.setFontSavingMode(HtmlSaveOptions.FontSavingModes.SaveInAllFormats);
saveOptions.setLettersPositioningMethod(LettersPositioningMethods.UseEmUnitsAndCompensationOfRoundingErrorsInCss);
// Save the output file
doc.save(dataDir + "06209403-00000001-000016523-fs2651_SRSDPCF-PDF.html", saveOptions);

Attached is the sample output for your kind reference.
06209403-00000001-000016523-fs2651_SRSDPCF-PDF.zip (299.1 KB)

Would you kindly try using the latest version and if issue still persists, please share some steps to reproduce the issue and complete environment details so that we can further proceed accordingly.

Hi Team,

We were using the below version of libraries :
‘com.aspose:aspose-words:24.6:jdk17’
‘com.aspose:aspose-cells:24.6’
‘com.aspose:aspose-pdf:24.6’

We tried upgrading to the latest version which is 25.2 but it throws this exception :
“The subscription included in this license allows free upgrades until 19 Sep 2024, but this version of the product was released on 01 Dec 2024. Please renew the subscription or use a previous version of the product.”

We have a subscription valid till sep 2025.

The latest compatible verison we could try, without this error message was 24.8 which still throws the “Invalid parameter” error.

Could you please let us know which version you had used and why we are getting this exception.

Thanks!