# dependencies org.apache.pdfbox.pdmodel

**URL:** https://discuss.gradle.org/t/dependencies-org-apache-pdfbox-pdmodel/26943
**Category:** Help/Discuss
**Created:** [May 15, 2018, 6:45pm UTC](https://discuss.gradle.org/t/dependencies-org-apache-pdfbox-pdmodel/26943 "2018-05-15T18:45:23Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Numerikstudent](https://avatars.discourse-cdn.com/v4/letter/n/7993a0/32.png) [@Numerikstudent](https://discuss.gradle.org/u/Numerikstudent)
#### Post date: [May 15, 2018, 6:45pm UTC](https://discuss.gradle.org/t/dependencies-org-apache-pdfbox-pdmodel/26943/1 "2018-05-15T18:45:23Z")

</div>

Hello.

I tested my java code with  
import org.apache.pdfbox.pdmodel.PDDocument  
and it worked very well.

Then I used:  
import org.apache.pdfbox.pdmodel.PDDocument;  
import org.apache.pdfbox.pdmodel.PDPage;  
import org.apache.pdfbox.pdmodel.PDPageContentStream;  
import org.apache.pdfbox.pdmodel.font.PDType1Font;

public class GradleTutorial {

gradle clean works. But gradle build produces a lot of errors.  
It seems to build a fat-jar. Is there another method to accomplish it?

my build.gradle

repositories {  
mavenCentral()  
}

apply plugin: “java”

dependencies {

```
compile 'org.apache.pdfbox:pdfbox:1.8.14'

```

}

sourceSets {  
main.java.srcDir “src/main/java/”  
}

jar {  
from configurations.compile.collect { zipTree it}  
manifest.attributes “Main-Class”: “GradleTutorial”  
}

---

<div class="post-metadata">

### Author: ![shiroukamui](https://avatars.discourse-cdn.com/v4/letter/s/6de8d8/32.png) [@shiroukamui](https://discuss.gradle.org/u/shiroukamui)
#### Post date: [August 5, 2020, 11:06pm UTC](https://discuss.gradle.org/t/dependencies-org-apache-pdfbox-pdmodel/26943/2 "2020-08-05T23:06:34Z")

</div>

Hi everyone,  
I have such a similar problem. My project is a Spring Boot with Gradle as a dependency manager. I included PdfBox dependency in my “build.gradle” file, but from my app I’m not able to use its classes since they “cannot be resolved”. I don’t know what’s wrong with my files.  
Here is my build.gradle

```gradle
plugins {
	id 'org.springframework.boot' version '2.3.0.RELEASE'
	id 'io.spring.dependency-management' version '1.0.9.RELEASE'
	id 'java'
}

group = 'com.demo'
sourceCompatibility = '11'

configurations {
	compileOnly {
		extendsFrom annotationProcessor
	}
}

repositories {
	mavenCentral()
}

dependencies {
	implementation('org.springframework.boot:spring-boot-starter-web-services') {
		exclude group: 'org.springframework.boot', module: 'spring-boot-starter-tomcat'
	}
	implementation 'commons-io:commons-io:2.7'
	implementation 'commons-codec:commons-codec:1.14'
	compileOnly 'com.googlecode.xades4j:xades4j:1.5.1'
	compileOnly 'org.projectlombok:lombok'
	compileOnly 'org.apache.pdfbox:pdfbox:2.0.20'
	developmentOnly 'org.springframework.boot:spring-boot-devtools'
	annotationProcessor 'org.projectlombok:lombok'
	testImplementation('org.springframework.boot:spring-boot-starter-test') {
		exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
	}
}

test {
	useJUnitPlatform()
}

```

Then I try to do this in my java app

```gradle
    PDDocument doc = PDDocument.load(pdfFile);

```

And it shows me “PDDocument cannot be resolved”. What am I doing wrong? please help.

---

<div class="post-metadata">

### Author: ![gotson](https://avatars.discourse-cdn.com/v4/letter/g/7bcc69/32.png) [@gotson](https://discuss.gradle.org/u/gotson)
#### Post date: [August 7, 2020, 3:48am UTC](https://discuss.gradle.org/t/dependencies-org-apache-pdfbox-pdmodel/26943/3 "2020-08-07T03:48:22Z")

</div>

@shiroukamui You are using `compileOnly 'org.apache.pdfbox:pdfbox:2.0.20'` so the classes are not available in your code. You need to use `implementation` instead.

---

<div class="post-metadata">

### Author: ![shiroukamui](https://avatars.discourse-cdn.com/v4/letter/s/6de8d8/32.png) [@shiroukamui](https://discuss.gradle.org/u/shiroukamui)
#### Post date: [August 7, 2020, 4:33am UTC](https://discuss.gradle.org/t/dependencies-org-apache-pdfbox-pdmodel/26943/4 "2020-08-07T04:33:04Z")

</div>

Hi [gotson](https://discuss.gradle.org/u/gotson),  
Thank you so much for your help, that solved my problem. Now everything is nice and smooth. 😁 👍
