When converting PDF files to DOCX format using Aspose.PDF for Java, encountering the error “Invalid parameter used” can be frustrating. This error may arise due to various reasons, including issues with the PDF file structure or unsupported features within the PDF.
To improve the chances of successful conversion, consider the following steps:
Check PDF File Integrity: Ensure that the PDF files you are trying to convert are not corrupted. You can open them in a PDF viewer to verify their integrity.
Use Load Options: Utilize the PdfLoadOptions class to specify how the PDF should be loaded. This can help in managing specific parameters that might be causing the error. For example, you can set the page range or handle password-protected documents.
Here’s a simple code snippet demonstrating how to use PdfLoadOptions:
import com.aspose.pdf.Document;
import com.aspose.pdf.PdfLoadOptions;
public class PdfToDocxConverter {
public static void main(String[] args) {
// Load PDF with options
PdfLoadOptions loadOptions = new PdfLoadOptions();
loadOptions.setPassword("your_password"); // if the PDF is password protected
Document pdfDocument = new Document("input.pdf", loadOptions);
pdfDocument.save("output.docx");
}
}
Error Handling: Implement robust error handling in your code to catch exceptions and log detailed error messages. This can help you identify the specific cause of the issue.
Review Documentation: Check the official Aspose documentation for any specific requirements or limitations regarding the PDF files you are converting. This can provide insights into parameters that may need adjustment.
Test with Different Files: If possible, try converting different PDF files to see if the issue is isolated to specific documents. This can help determine if the problem is with the files themselves or the conversion process.
By following these steps, you can enhance the reliability of your PDF to DOCX conversions and potentially avoid the “Invalid parameter used” error.
For more detailed guidance on converting PDFs to DOCX format, you can refer to the official Aspose documentation here and here.
We tested using 24.9 API version and the below code snippet in a console application. We were not able to replicate any exceptions in our environment.
// List all PDF files in the "pdfss" folder
File folder = new File(dataDir + "pdfss");
File[] files = folder.listFiles((dir, name) -> name.toLowerCase().endsWith(".pdf"));
if (files != null) {
for (File file : files) {
// Load the PDF document
Document pdfDocument = new Document(file.getAbsolutePath());
// Set save options for converting to DOCX
DocSaveOptions saveOptions = new DocSaveOptions();
saveOptions.setFormat(DocSaveOptions.DocFormat.DocX);
saveOptions.setMode(DocSaveOptions.RecognitionMode.EnhancedFlow);
// Save the document as DOCX
String outputFileName = dataDir + "pdfss/" + file.getName().replace(".pdf", "") + "output.docx";
pdfDocument.save(outputFileName, saveOptions);
}
}
Can you please try using the latest version and let us know if you still notice any issues?
Can you please confirm the OS you are testing with?
I am using Linux.
Ubuntu 22.04 to be precise.
Also, I am testing on version 24.1, and 23.X.
When I try using 24.9 I get the following dependency issues.
[ERROR] dependency: com.aspose.ms.jdk.NetFramework:mscorlib:jar:23.11 (compile)
[ERROR] com.aspose.ms.jdk.NetFramework:mscorlib:jar:23.11 was not found in https://git.core.objective.com/api/v4/groups/237/-/packages/maven during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of gitlab-maven has elapsed or updates are forced
[ERROR] com.aspose.ms.jdk.NetFramework:mscorlib:jar:23.11 was not found in https://git.core.objective.com/api/v4/projects/1351/packages/maven during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of cs-releases has elapsed or updates are forced
[ERROR] com.aspose.ms.jdk.NetFramework:mscorlib:jar:23.11 was not found in https://repository.springsource.com/maven/bundles/release during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of com.springsource.repository.bundles.release has elapsed or updates are forced
[ERROR] com.aspose.ms.jdk.NetFramework:mscorlib:jar:23.11 was not found in https://repository.springsource.com/maven/bundles/external during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of com.springsource.repository.bundles.external has elapsed or updates are forced
[ERROR] com.aspose.ms.jdk.NetFramework:mscorlib:jar:23.11 was not found in https://repository.jboss.org/nexus/content/groups/public-jboss/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of jboss-public-repository-group has elapsed or updates are forced
[ERROR] com.aspose.ms.jdk.NetFramework:mscorlib:jar:23.11 was not found in https://repo1.maven.org/maven2/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of central has elapsed or updates are forced
[ERROR] com.aspose.ms.jdk.NetFramework:mscorlib:jar:23.11 was not found in https://maven.alfresco.com/nexus/content/groups/public/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of maven.alfresco.com has elapsed or updates are forced
[ERROR] com.aspose.ms.jdk.NetFramework:mscorlib:jar:23.11 was not found in https://packages.atlassian.com/mvn/maven-atlassian-external/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of atlassian-external-public has elapsed or updates are forced
[ERROR] com.aspose.ms.jdk.NetFramework:mscorlib:jar:23.11 was not found in https://maven.restlet.talend.com/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of maven-restlet has elapsed or updates are forced
[ERROR] com.aspose.ms.jdk.NetFramework:mscorlib:jar:23.11 was not found in https://packages.nuxeo.com/repository/maven-public/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of nuxeo.public has elapsed or updates are forced
[ERROR] com.aspose.ms.jdk.NetFramework:mscorlib:jar:23.11 was not found in https://releases.aspose.com/java/repo during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of AsposeJavaAPI has elapsed or updates are forced
[ERROR] com.aspose.ms.jdk.NetFramework:mscorlib:jar:23.11 was not found in file://${basedir}/misc/lib during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of aspose-repository has elapsed or updates are forced
[ERROR] dependency: com.aspose.ms.jdk.NetFramework:System:jar:23.11 (compile)
[ERROR] com.aspose.ms.jdk.NetFramework:System:jar:23.11 was not found in https://git.core.objective.com/api/v4/groups/237/-/packages/maven during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of gitlab-maven has elapsed or updates are forced
[ERROR] com.aspose.ms.jdk.NetFramework:System:jar:23.11 was not found in https://git.core.objective.com/api/v4/projects/1351/packages/maven during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of cs-releases has elapsed or updates are forced
[ERROR] com.aspose.ms.jdk.NetFramework:System:jar:23.11 was not found in https://repository.springsource.com/maven/bundles/release during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of com.springsource.repository.bundles.release has elapsed or updates are forced
[ERROR] com.aspose.ms.jdk.NetFramework:System:jar:23.11 was not found in https://repository.springsource.com/maven/bundles/external during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of com.springsource.repository.bundles.external has elapsed or updates are forced
[ERROR] com.aspose.ms.jdk.NetFramework:System:jar:23.11 was not found in https://repository.jboss.org/nexus/content/groups/public-jboss/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of jboss-public-repository-group has elapsed or updates are forced
[ERROR] com.aspose.ms.jdk.NetFramework:System:jar:23.11 was not found in https://repo1.maven.org/maven2/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of central has elapsed or updates are forced
[ERROR] com.aspose.ms.jdk.NetFramework:System:jar:23.11 was not found in https://maven.alfresco.com/nexus/content/groups/public/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of maven.alfresco.com has elapsed or updates are forced
[ERROR] com.aspose.ms.jdk.NetFramework:System:jar:23.11 was not found in https://packages.atlassian.com/mvn/maven-atlassian-external/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of atlassian-external-public has elapsed or updates are forced
[ERROR] com.aspose.ms.jdk.NetFramework:System:jar:23.11 was not found in https://maven.restlet.talend.com/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of maven-restlet has elapsed or updates are forced
[ERROR] com.aspose.ms.jdk.NetFramework:System:jar:23.11 was not found in https://packages.nuxeo.com/repository/maven-public/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of nuxeo.public has elapsed or updates are forced
[ERROR] com.aspose.ms.jdk.NetFramework:System:jar:23.11 was not found in https://releases.aspose.com/java/repo during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of AsposeJavaAPI has elapsed or updates are forced
[ERROR] com.aspose.ms.jdk.NetFramework:System:jar:23.11 was not found in file://${basedir}/misc/lib during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of aspose-repository has elapsed or updates are forced
[ERROR] dependency: com.aspose.ms.jdk.NetFramework:System.Xml:jar:23.11 (compile)
[ERROR] com.aspose.ms.jdk.NetFramework:System.Xml:jar:23.11 was not found in https://git.core.objective.com/api/v4/groups/237/-/packages/maven during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of gitlab-maven has elapsed or updates are forced
[ERROR] com.aspose.ms.jdk.NetFramework:System.Xml:jar:23.11 was not found in https://git.core.objective.com/api/v4/projects/1351/packages/maven during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of cs-releases has elapsed or updates are forced
[ERROR] com.aspose.ms.jdk.NetFramework:System.Xml:jar:23.11 was not found in https://repository.springsource.com/maven/bundles/release during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of com.springsource.repository.bundles.release has elapsed or updates are forced
[ERROR] com.aspose.ms.jdk.NetFramework:System.Xml:jar:23.11 was not found in https://repository.springsource.com/maven/bundles/external during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of com.springsource.repository.bundles.external has elapsed or updates are forced
[ERROR] com.aspose.ms.jdk.NetFramework:System.Xml:jar:23.11 was not found in https://repository.jboss.org/nexus/content/groups/public-jboss/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of jboss-public-repository-group has elapsed or updates are forced
[ERROR] com.aspose.ms.jdk.NetFramework:System.Xml:jar:23.11 was not found in https://repo1.maven.org/maven2/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of central has elapsed or updates are forced
[ERROR] com.aspose.ms.jdk.NetFramework:System.Xml:jar:23.11 was not found in https://maven.alfresco.com/nexus/content/groups/public/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of maven.alfresco.com has elapsed or updates are forced
[ERROR] com.aspose.ms.jdk.NetFramework:System.Xml:jar:23.11 was not found in https://packages.atlassian.com/mvn/maven-atlassian-external/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of atlassian-external-public has elapsed or updates are forced
[ERROR] com.aspose.ms.jdk.NetFramework:System.Xml:jar:23.11 was not found in https://maven.restlet.talend.com/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of maven-restlet has elapsed or updates are forced
[ERROR] com.aspose.ms.jdk.NetFramework:System.Xml:jar:23.11 was not found in https://packages.nuxeo.com/repository/maven-public/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of nuxeo.public has elapsed or updates are forced
[ERROR] com.aspose.ms.jdk.NetFramework:System.Xml:jar:23.11 was not found in https://releases.aspose.com/java/repo during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of AsposeJavaAPI has elapsed or updates are forced
[ERROR] com.aspose.ms.jdk.NetFramework:System.Xml:jar:23.11 was not found in file://${basedir}/misc/lib during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of aspose-repository has elapsed or updates are forced
[ERROR] dependency: com.aspose.ms.jdk.NetFramework:System.Net:jar:23.11 (compile)
[ERROR] com.aspose.ms.jdk.NetFramework:System.Net:jar:23.11 was not found in https://git.core.objective.com/api/v4/groups/237/-/packages/maven during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of gitlab-maven has elapsed or updates are forced
[ERROR] com.aspose.ms.jdk.NetFramework:System.Net:jar:23.11 was not found in https://git.core.objective.com/api/v4/projects/1351/packages/maven during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of cs-releases has elapsed or updates are forced
[ERROR] com.aspose.ms.jdk.NetFramework:System.Net:jar:23.11 was not found in https://repository.springsource.com/maven/bundles/release during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of com.springsource.repository.bundles.release has elapsed or updates are forced
[ERROR] com.aspose.ms.jdk.NetFramework:System.Net:jar:23.11 was not found in https://repository.springsource.com/maven/bundles/external during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of com.springsource.repository.bundles.external has elapsed or updates are forced
[ERROR] com.aspose.ms.jdk.NetFramework:System.Net:jar:23.11 was not found in https://repository.jboss.org/nexus/content/groups/public-jboss/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of jboss-public-repository-group has elapsed or updates are forced
[ERROR] com.aspose.ms.jdk.NetFramework:System.Net:jar:23.11 was not found in https://repo1.maven.org/maven2/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of central has elapsed or updates are forced
[ERROR] com.aspose.ms.jdk.NetFramework:System.Net:jar:23.11 was not found in https://maven.alfresco.com/nexus/content/groups/public/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of maven.alfresco.com has elapsed or updates are forced
[ERROR] com.aspose.ms.jdk.NetFramework:System.Net:jar:23.11 was not found in https://packages.atlassian.com/mvn/maven-atlassian-external/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of atlassian-external-public has elapsed or updates are forced
[ERROR] com.aspose.ms.jdk.NetFramework:System.Net:jar:23.11 was not found in https://maven.restlet.talend.com/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of maven-restlet has elapsed or updates are forced
[ERROR] com.aspose.ms.jdk.NetFramework:System.Net:jar:23.11 was not found in https://packages.nuxeo.com/repository/maven-public/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of nuxeo.public has elapsed or updates are forced
[ERROR] com.aspose.ms.jdk.NetFramework:System.Net:jar:23.11 was not found in https://releases.aspose.com/java/repo during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of AsposeJavaAPI has elapsed or updates are forced
[ERROR] com.aspose.ms.jdk.NetFramework:System.Net:jar:23.11 was not found in file://${basedir}/misc/lib during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of aspose-repository has elapsed or updates are forced
[ERROR]
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
Oh by the way, when I try your code with versions prior to 24.9 (in my case 24.1) I get this error for some files:
com.simflofy.utils.aspose.exceptions.AsposeConversionException: class com.aspose.pdf.internal.l20y.l46u cannot be cast to class com.aspose.pdf.internal.l20y.l36v (com.aspose.pdf.internal.l20y.l46u and com.aspose.pdf.internal.l20y.l36v are in unnamed module of loader org.apache.catalina.loader.ParallelWebappClassLoader @1e7ab390)
Looks like there are dependency errors. Can you please clear your maven cache and make sure that repository URLs are correct and working? BTW, we tested in Windows Environment.
Can you please make sure that you are using the latest version of the API and if issue is still occurring, please share some details and steps to reproduce it in our environment. We will further proceed accordingly.
I have already downloaded all the fonts I need, but I get this when I try to convert a PDF with some images to DOCX. It works in Windows, but not in Ubuntu.
converting a simple pdf file containing only characters works fine
com.aspose.pdf.internal.ms.System.lh: Invalid parameter used. at com.aspose.pdf.internal.l65f.l0k.lj(Unknown Source) at com.aspose.pdf.internal.l65f.l0k.lj(Unknown Source) at com.aspose.pdf.internal.l65n.l2p.lj(Unknown Source) at com.aspose.pdf.internal.l65n.l2p.lf(Unknown Source) at [com.aspose.pdf.internal.l65n.l2p.lI](https://com.aspose.pdf.internal.l65n.l2p.li/)(Unknown Source) at [com.aspose.pdf.internal.l65n.l2p.lt](https://com.aspose.pdf.internal.l65n.l2p.lt/)(Unknown Source) at [com.aspose.pdf.internal.l65n.l2p.lI](https://com.aspose.pdf.internal.l65n.l2p.li/)(Unknown Source) at com.aspose.pdf.internal.l25j.lj.visitPathEnd(Unknown Source) at com.aspose.pdf.internal.foundation.rendering.l2if.accept(Unknown Source) at com.aspose.pdf.internal.foundation.rendering.l0if.accept(Unknown Source) at com.aspose.pdf.internal.foundation.rendering.lv.accept(Unknown Source) at com.aspose.pdf.internal.foundation.rendering.l0if.accept(Unknown Source) at com.aspose.pdf.internal.foundation.rendering.lv.accept(Unknown Source) at com.aspose.pdf.internal.foundation.rendering.l0if.accept(Unknown Source) at com.aspose.pdf.internal.foundation.rendering.lv.accept(Unknown Source) at [com.aspose.pdf.internal.l25j.lj.lI](https://com.aspose.pdf.internal.l25j.lj.li/)(Unknown Source) at [com.aspose.pdf.internal.l96p.le.lI](https://com.aspose.pdf.internal.l96p.le.li/)(Unknown Source) at [com.aspose.pdf.internal.l17n.ld.lI](https://com.aspose.pdf.internal.l17n.ld.li/)(Unknown Source) at [com.aspose.pdf.internal.l17n.lv.lI](https://com.aspose.pdf.internal.l17n.lv.li/)(Unknown Source) at com.aspose.pdf.internal.l17n.lb.lf(Unknown Source) at [com.aspose.pdf.internal.l17h.lj.lI](https://com.aspose.pdf.internal.l17h.lj.li/)(Unknown Source) at [com.aspose.pdf.internal.l2u.lf.lI](https://com.aspose.pdf.internal.l2u.lf.li/)(Unknown Source) at [com.aspose.pdf.l1p.lI](https://com.aspose.pdf.l1p.li/)(Unknown Source) at [com.aspose.pdf.l1p.lI](https://com.aspose.pdf.l1p.li/)(Unknown Source) at com.aspose.pdf.ADocument.ld(Unknown Source) at [com.aspose.pdf.ADocument.lt](https://com.aspose.pdf.adocument.lt/)(Unknown Source) at com.aspose.pdf.ADocument.lf(Unknown Source) at [com.aspose.pdf.ADocument.lI](https://com.aspose.pdf.adocument.li/)(Unknown Source) at [com.aspose.pdf.Document.lI](https://com.aspose.pdf.document.li/)(Unknown Source) at [com.aspose.pdf.ADocument.lI](https://com.aspose.pdf.adocument.li/)(Unknown Source) at [com.aspose.pdf.ADocument.save](https://com.aspose.pdf.adocument.save/)(Unknown Source)
As requested earlier, please try using 24.10 version. If issue still persists, please share a sample PDF with us so that we can test the scenario in our environment and address it accordingly.
I updated to version 24.10 but already have the same issue , here is the pdf that I try to convert to doc or docx
In windows everything is ok but in Ubuntu it doesn’t work
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): PDFJAVA-44533
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.