Trying to compress PDF files with dc-services and pdf-tools

New Here ,
Jul 20, 2020 Jul 20, 2020

Copy link to clipboard

Copied

I am trying to implemet a REST Api in Spring Boot to OCR and compress my pdf files. The OCR operation is working fine, but when I try to compress them I get the following error: 

 

java.lang.NoSuchMethodError: com.adobe.platform.operation.internal.api.CPFApi.cpfPredictApi(Lcom/adobe/platform/operation/internal/InternalExecutionContext;Lcom/adobe/platform/operation/internal/cpf/dto/request/ContentAnalyzerRequests;Ljava/util/List;Ljava/lang/Class;Ljava/lang/String;)Lcom/adobe/platform/operation/internal/http/HttpResponse;

 

I have these two dependencies in my pom: 

 

        <dependency>
            <groupId>com.adobe.documentcloud</groupId>
            <artifactId>dc-services-sdk</artifactId>
            <version>1.0.0</version>
        </dependency>
        <dependency>
            <groupId>com.adobe.documentservices</groupId>
            <artifactId>pdftools-sdk</artifactId>
            <version>1.1.0</version>
        </dependency>
    </dependencies>

 

And through the developer console I've already added the PDF Embed API. What am I doing wrong?

 

Thank you in advance!

TOPICS
How to, PDF Embed API, PDF Services API

Views

91

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 20, 2020 Jul 20, 2020

Copy link to clipboard

Copied

Can you share your code? Also, How does Embed API play a role in your solution?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 21, 2020 Jul 21, 2020

Copy link to clipboard

Copied

ocrocrcompresscompress

I added the embed api through the dev console to be able to use the sdk in other projects, with private key and auth-json.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Oct 19, 2020 Oct 19, 2020

Copy link to clipboard

Copied

LATEST

@darvasr 
Firstly, the Credentials require PDF Tools API subscription and not PDF Embed API. Since OCR operation is working fine, the credentials have the PDF Tools API subscription. 

Secondly, Compress operation was introduced in 1.1.0 version. The dependency of its previous version 1.0.0 with artifactId dc-services-sdk must be creating conflicts during class loading and thus, NoSuchMethodError is coming up. Please remove 1.0.0 version dependency and only keep following dependency in pom.xml:

        <dependency>
            <groupId>com.adobe.documentservices</groupId>
            <artifactId>pdftools-sdk</artifactId>
            <version>1.1.0</version>
        </dependency> 


Now, latest version is 1.2.0 and you can refer to its samples here: https://github.com/adobe/pdftools-java-sdk-samples  

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines