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

Issues with Grails PDF Renderer after using XWPF PDF Converter #43

Open
ilan18 opened this issue Feb 26, 2018 · 0 comments
Open

Issues with Grails PDF Renderer after using XWPF PDF Converter #43

ilan18 opened this issue Feb 26, 2018 · 0 comments

Comments

@ilan18
Copy link

ilan18 commented Feb 26, 2018

Existing Grails Code is as follows:

FileOutputStream os = new FileOutputStream(filename)
ITextRenderer renderer = new ITextRenderer()
configureRenderer(renderer)
org.w3c.dom.Document document = getTheDocument()
renderer.setDocument(document, grailsApplication.config.grails.serverURL)
renderer.layout()
renderer.createPDF(os)

Now added

org.apache.poi.xwpf.converter.pdf.PdfOptions options = org.apache.poi.xwpf.converter.pdfPdfOptions.create();
OutputStream outputStream = new FileOutputStream(fileNameWithDirectory)
PdfConverter.getInstance().convert(docxDocument, outputStream, options)
outputStream.close()

Now call the original code again. Get an Exception on line creating new ITextRenderer() :

java.lang.RuntimeException: Font 'Courier-BoldOblique' with 'Cp1252' is not recognized.
    at org.xhtmlrenderer.pdf.ITextFontResolver.createInitialFontMap(ITextFontResolver.java:470) ~[flying-saucer-pdf-9.1.12.jar:na]
    at org.xhtmlrenderer.pdf.ITextFontResolver.<init>(ITextFontResolver.java:40) ~[flying-saucer-pdf-9.1.12.jar:na]
    at org.xhtmlrenderer.pdf.ITextRenderer.<init>(ITextRenderer.java:124) ~[flying-saucer-pdf-9.1.12.jar:na]
    at org.xhtmlrenderer.pdf.ITextRenderer.<init>(ITextRenderer.java:110) ~[flying-saucer-pdf-9.1.12.jar:na]
    at org.xhtmlrenderer.pdf.ITextRenderer.<init>(ITextRenderer.java:106) ~[flying-saucer-pdf-9.1.12.jar:na]
    at org.xhtmlrenderer.pdf.ITextRenderer.<init>(ITextRenderer.java:102) ~[flying-saucer-pdf-9.1.12.jar:na]
Caused by: com.lowagie.text.DocumentException: Font 'Courier-BoldOblique' with 'Cp1252' is not recognized.
    at com.lowagie.text.pdf.BaseFont.createFont(BaseFont.java:696) ~[itext-4.2.1.jar:na]
    at com.lowagie.text.pdf.BaseFont.createFont(BaseFont.java:603) ~[itext-4.2.1.jar:na]
    at com.lowagie.text.pdf.BaseFont.createFont(BaseFont.java:438) ~[itext-4.2.1.jar:na]
    at org.xhtmlrenderer.pdf.ITextFontResolver.createFont(ITextFontResolver.java:483) ~[flying-saucer-pdf-9.1.12.jar:na]
    at org.xhtmlrenderer.pdf.ITextFontResolver.createFont(ITextFontResolver.java:479) ~[flying-saucer-pdf-9.1.12.jar:na]
    at org.xhtmlrenderer.pdf.ITextFontResolver.addCourier(ITextFontResolver.java:491) ~[flying-saucer-pdf-9.1.12.jar:na]
    at org.xhtmlrenderer.pdf.ITextFontResolver.createInitialFontMap(ITextFontResolver.java:459) ~[flying-saucer-pdf-9.1.12.jar:na]

build.gradle is as follows:

compile 'org.xhtmlrenderer:flying-saucer-core:9.1.12'
compile 'org.xhtmlrenderer:flying-saucer-pdf:9.1.12'
compile 'org.xhtmlrenderer:flying-saucer-log4j:9.1.12'

compile ('org.grails.plugins:rendering:2.0.3') {
        exclude group: 'org.xhtmlrenderer', module: 'core-renderer'
}

compile("com.lowagie:itext:4.2.1")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant