Free Support Forum - groupdocs.com

Convert a document and release files/filehandles using Java

I am converting files from docx to pdf. I have done it both via files and streams, but I find I cannot access the file after conversion until I close the application.

Rather like in this other post, it seems that the conversion process doesn’t release the file handle.

That post says it is fixed in 19.11 but 19.11 doesn’t seem to be available, at least on my trial licence, for Java.

Could you advise?

Thanks,

1 Like

I see this was also reported for Java:

We have an update on CONVERSIONJAVA-856 . This issue will be fixed in some upcoming releases of the API (Probably in February).

But it’s now March. Please advise. Thanks.

Here as well:

Is this product maintained and worth paying for?

@davet-1,

We’re sorry for the inconvenience. But this issue is still under investigation. You’ll be notified about the outcomes soon. Your patience will be appreciated in this regard.

@davet-1,

This issue is resolved in API version 20.2. We’d recommend you to use/integrate latest version of the API and let us know if there is any issue.

Is it every class that you’ve moved around so that code that used to work no longer does, or is it only most of them?

1 Like

After changing nearly every import line I get this:

2020-03-10 13:55:38,360 ERROR conversion.ConversionServiceImpl - Exception: Absolute URI is too short
class com.groupdocs.conversion.internal.c.a.ms.System.UriFormatException: Absolute URI is too short
com.groupdocs.conversion.internal.c.a.ms.System.Uri.parse(Unknown Source)
com.groupdocs.conversion.internal.c.a.ms.System.Uri.parseUri(Unknown Source)
com.groupdocs.conversion.internal.c.a.ms.System.Uri.<init>(Unknown Source)
com.groupdocs.conversion.internal.c.a.ms.System.Uri.<init>(Unknown Source)
com.groupdocs.conversion.licensing.License.b(Unknown Source)
com.groupdocs.conversion.licensing.License.a(Unknown Source)
com.groupdocs.conversion.licensing.License.setLicense(Unknown Source)
1 Like

@davet-1,

GroupDocs.Conversion for Java 20.2 is more simple yet easy to implement. We have moved most of the old classes/methods to the legacy namespace. You can get a clear picture of the public API changes in 20.2 release notes.
Why to migrate to 20.2?
Please have a look at these migration notes.

Sure, if you really dislike backwards compatibility I guess that makes sense.

The temporary licence I acquired yesterday still doesn’t work with it, though.

@davet-1,

Can you please share the license file in a private message and sample code here?

@davet-1,

We cannot reproduce this issue using the provided license and following code:

License lic = new License();
lic.setLicense("D:\\GroupDocs.Conversion.lic");
Converter converter = new Converter("D:\\source.docx");
PdfConvertOptions options = new PdfConvertOptions();
converter.convert("D:\\converted.pdf", options);

Have a look at the source and output.zip (114.1 KB) files.

I’m afraid to report that that doesn’t work for me. Please see stacktrace below:

2020-03-16 09:07:06,281 ERROR conversion.ConversionServiceImpl - Exception: Absolute URI is too short
class com.groupdocs.conversion.internal.c.a.ms.System.UriFormatException: Absolute URI is too short
com.groupdocs.conversion.internal.c.a.ms.System.Uri.parse(Unknown Source)
com.groupdocs.conversion.internal.c.a.ms.System.Uri.parseUri(Unknown Source)
com.groupdocs.conversion.internal.c.a.ms.System.Uri.<init>(Unknown Source)
com.groupdocs.conversion.internal.c.a.ms.System.Uri.<init>(Unknown Source)
com.groupdocs.conversion.licensing.License.b(Unknown Source)
com.groupdocs.conversion.licensing.License.a(Unknown Source)
com.groupdocs.conversion.licensing.License.setLicense(Unknown Source)
1 Like

@davet-1,

Please share a simple console application using that we can reproduce this issue at our end (exclude license file from the application, you already shared license).

import com.groupdocs.conversion.licensing.License;

public class Main {

    public static final String licencePath = "./GroupDocs.Conversion.lic";
    
    public static void main(String[] args) {
        System.out.println("Hello, world\n");
        applyLicenceFromFile();
    }


    public static void applyLicenceFromFile() {
        //ExStart:applyLicenseFromFile
        try {

            System.out.println("licencePath is " + licencePath);

            // Setup license
            License lic = new License();
            lic.setLicense(licencePath);
        } catch (Exception e) {
            System.out.println("Exception: " + e.getMessage());
            e.printStackTrace();
        }
        //ExEnd:applyLicenseFromFile
    }

}

execution:

$ javac -cp groupdocs-conversion-20.2.jar Main.java
$ java -cp 'groupdocs-conversion-20.2.jar;.' Main
Hello, world

licencePath is ./GroupDocs.Conversion.lic
Exception: Absolute URI is too short
class com.groupdocs.conversion.internal.c.a.ms.System.UriFormatException: Absolute URI is too short
com.groupdocs.conversion.internal.c.a.ms.System.Uri.parse(Unknown Source)
com.groupdocs.conversion.internal.c.a.ms.System.Uri.parseUri(Unknown Source)
com.groupdocs.conversion.internal.c.a.ms.System.Uri.<init>(Unknown Source)
com.groupdocs.conversion.internal.c.a.ms.System.Uri.<init>(Unknown Source)
com.groupdocs.conversion.licensing.License.b(Unknown Source)
com.groupdocs.conversion.licensing.License.a(Unknown Source)
com.groupdocs.conversion.licensing.License.setLicense(Unknown Source)
Main.applyLicenceFromFile(Main.java:21)
Main.main(Main.java:9)
        at com.groupdocs.conversion.internal.c.a.ms.System.Uri.parse(Unknown Source)
        at com.groupdocs.conversion.internal.c.a.ms.System.Uri.parseUri(Unknown Source)
        at com.groupdocs.conversion.internal.c.a.ms.System.Uri.<init>(Unknown Source)
        at com.groupdocs.conversion.internal.c.a.ms.System.Uri.<init>(Unknown Source)
        at com.groupdocs.conversion.licensing.License.b(Unknown Source)
        at com.groupdocs.conversion.licensing.License.a(Unknown Source)
        at com.groupdocs.conversion.licensing.License.setLicense(Unknown Source)
        at Main.applyLicenceFromFile(Main.java:21)
        at Main.main(Main.java:9)
1 Like

@davet-1,

Thanks for the details.
This issue is reproduced at our end. Hence, we’ve logged it in our internal issue tracking system with ID CONVERSIONJAVA-933. As there’s any further update, you’ll be notified. Meanwhile, you can pass license file as an absolute path.