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

trying to get RC18 working on Google App Engine #337

Closed
Rob46 opened this issue Mar 16, 2019 · 5 comments
Closed

trying to get RC18 working on Google App Engine #337

Rob46 opened this issue Mar 16, 2019 · 5 comments

Comments

@Rob46
Copy link

Rob46 commented Mar 16, 2019

I think I've got all the libraries, but I get this exception:

java.lang.NoSuchMethodError: com.openhtmltopdf.pdfboxout.PdfRendererBuilder.useFastMode()Lcom/openhtmltopdf/outputdevice/helper/BaseRendererBuilder;

My code:

	ByteArrayOutputStream baos = new ByteArrayOutputStream();
		
	// create PDF
	PdfRendererBuilder builder = new PdfRendererBuilder();
			
        builder.useFastMode(); // NEW v18

	builder.withHtmlContent(sourceHtml, baseUrl);
	builder.toStream(baos);
	builder.run();
	baos.flush();

libraries:

image

@danfickle
Copy link
Owner

It looks like you have both RC18 and RC12 on your classpath. Remove RC12 and the earlier versions of pdfbox, fontbox and graphics2d. Also be aware of #336 until RC19 is released.

@Rob46
Copy link
Author

Rob46 commented Mar 17, 2019

That is strange... only the ones with the orange tick should be included, but removing them completely from eclipse did give me a different error ... it looks like xmpbox was not needed in rc12 but it is in rc18... does that sound about right?

@Rob46
Copy link
Author

Rob46 commented Mar 17, 2019

So RC18 works on App Engine, but I see the following in the logs... I'm assuming because you can't write to disk in AppEngine. Maybe it would be better (?) to test if its running on app engine
via something like System.getProperty("com.google.appengine.runtime.version") which will return a string like "Google App Engine/1.9.71" only if its app engine. Then maybe handle the fonts differently?

org.apache.pdfbox.pdmodel.font.FileSystemFontProvider : Building on-disk font cache, this may take a while (FileSystemFontProvider.java:233)
2019-03-17 12:19:21.702 EDT
org.apache.pdfbox.pdmodel.font.FileSystemFontProvider : Finished building on-disk font cache, found 0 fonts (FileSystemFontProvider.java:236)
2019-03-17 12:19:21.705 EDT
org.apache.pdfbox.pdmodel.font.PDType1Font : Using fallback font LiberationSans for base font Times-Roman (PDType1Font.java:161)
2019-03-17 12:19:21.706 EDT
org.apache.pdfbox.pdmodel.font.PDType1Font : Using fallback font LiberationSans for base font Times-Bold (PDType1Font.java:161)
2019-03-17 12:19:21.707 EDT
org.apache.pdfbox.pdmodel.font.PDType1Font : Using fallback font LiberationSans for base font Times-Italic (PDType1Font.java:161)
2019-03-17 12:19:21.709 EDT
org.apache.pdfbox.pdmodel.font.PDType1Font : Using fallback font LiberationSans for base font Times-BoldItalic (PDType1Font.java:161)
2019-03-17 12:19:21.710 EDT
org.apache.pdfbox.pdmodel.font.PDType1Font : Using fallback font LiberationSans for base font Helvetica (PDType1Font.java:161)
2019-03-17 12:19:21.711 EDT
org.apache.pdfbox.pdmodel.font.PDType1Font : Using fallback font LiberationSans for base font Helvetica-Bold (PDType1Font.java:161)
2019-03-17 12:19:21.798 EDT
org.apache.pdfbox.pdmodel.font.PDType1Font : Using fallback font LiberationSans for base font Helvetica-Oblique (PDType1Font.java:161)
2019-03-17 12:19:21.800 EDT
org.apache.pdfbox.pdmodel.font.PDType1Font : Using fallback font LiberationSans for base font Helvetica-BoldOblique (PDType1Font.java:161)
2019-03-17 12:19:21.801 EDT
org.apache.pdfbox.pdmodel.font.PDType1Font : Using fallback font LiberationSans for base font Courier (PDType1Font.java:161)
2019-03-17 12:19:21.803 EDT
org.apache.pdfbox.pdmodel.font.PDType1Font : Using fallback font LiberationSans for base font Courier-Bold (PDType1Font.java:161)
2019-03-17 12:19:21.804 EDT
org.apache.pdfbox.pdmodel.font.PDType1Font : Using fallback font LiberationSans for base font Courier-Oblique (PDType1Font.java:161)
2019-03-17 12:19:21.806 EDT
org.apache.pdfbox.pdmodel.font.PDType1Font : Using fallback font LiberationSans for base font Courier-BoldOblique (PDType1Font.java:161)
2019-03-17 12:19:21.807 EDT
org.apache.pdfbox.pdmodel.font.PDType1Font : Using fallback font LiberationSans for base font Symbol (PDType1Font.java:161)
2019-03-17 12:19:21.808 EDT
org.apache.pdfbox.pdmodel.font.PDType1Font : Using fallback font LiberationSans for base font ZapfDingbats (PDType1Font.java:161)
2019-03-17 12:19:22.112 EDT
[s~parasql-app/v83.416836884445995973].: com.openhtmltopdf.load INFO:: SAX XMLReader in use (parser): com.sun.org.apache.xerces.internal.parsers.SAXParser

2019-03-17 12:19:22.199 EDT
[s~parasql-app/v83.416836884445995973].: com.openhtmltopdf.load INFO:: SAX XMLReader in use (parser): com.sun.org.apache.xerces.internal.parsers.SAXParser

@danfickle
Copy link
Owner

Hi @Rob46,

I believe the font cache is built by PDFBOX for rendering PDFs to images (not for generating PDFs). These logs are just saying that since the filesystem didn't provide any fonts, LiberationSans will be used as a fallback for rendering the base fonts.

Ideally, PDFBOX wouldn't generate a font cache at all if just used for generating PDFs, but that's an issue for PDFBOX.

@Rob46
Copy link
Author

Rob46 commented Mar 18, 2019

Thanks for the answer. Also, I just wanted to say that the repeating table headers is a GREAT feature... something people have asked me for multiple times.

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

2 participants