Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use OpenPDF instead of iText for generating PDF. #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,13 @@ dependencyManagement {
}

dependencies {
// flying-saucer-pdf declares a profile using openpdf instead of itext, but we cannot declare it in gradle, so we
// need to manually exclude itext and add openpdf dependency
compile("org.xhtmlrenderer:flying-saucer-pdf:9.1.7") {
exclude group: 'com.lowagie', module: 'itext'
}
compile('com.github.librepdf:openpdf:1.0.3')

compile("org.xhtmlrenderer:core-renderer:R8")
compile("com.lowagie:itext:2.1.0")
testCompile("org.apache.pdfbox:pdfbox:1.0.0") {
exclude module:'jempbox'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@ class DataUriAwareITextUserAgent extends ITextUserAgent {
def image = Image.getInstance(dataUri.bytes)
def factor = sharedContext.dotsPerPixel
image.scaleAbsolute((image.plainWidth * factor) as float, (image.plainHeight * factor) as float)
resource = new ImageResource(new ITextFSImage(image))
resource = new ImageResource(uri, new ITextFSImage(image))
_imageCache.put(uri, resource)
resource
} catch (Exception e) {
GrailsUtil.deepSanitize(e)
log.error("exception creating image from data uri (will use empty image): $dataUri", e)
new ImageResource(null)
new ImageResource(uri, null)
}
} else {
log.error("data uri has a non image mime type (will use empty image): $dataUri")
new ImageResource(null)
new ImageResource(uri, null)
}
} else {
super.getImageResource(uri)
Expand Down