Comments (34)
I am able to reproduce. Looks like something happened between Grails 3.0.7 and 3.0.8
from grails-wkhtmltopdf.
The difference is that is that response.format is "pdf" in Grails 3.0.7 but "all" in Grails 3.0.8 (in WkhtmltopdfRenderer). Must have a look at the Grails source to see what changed between those versions.
from grails-wkhtmltopdf.
try to response.setContentType ("application/pdf") before render()
Saludos...
from grails-wkhtmltopdf.
+1, same problem here
from grails-wkhtmltopdf.
Seems to have been resolved by a change in mail plugin between 2.0.0.RC2 and 2.0.0.RC4.
from grails-wkhtmltopdf.
I just tested it with brand new app. Now it creates an empty PDF
Grails Version: 3.1.1
Groovy Version: 2.4.5
JVM Version: 1.8.0_60
I just modified show method
def show(MyPdfTea myPdfTea) {
println "------myPdfTea------show----------"+myPdfTea
//respond myPdfTea
response.setContentType ("application/pdf")
render( filename:"File bla.pdf",
view:"/myPdfTea/show",
model:[myPdfTea:myPdfTea],
//header:"/pdf/someHeader",
//footer:"/pdf/someFooter",
marginLeft:20,
marginTop:35,
marginBottom:20,
marginRight:20,
headerSpacing:10)
}
from grails-wkhtmltopdf.
And if i comment out
response.setContentType ("application/pdf")
It will render normally as show
from grails-wkhtmltopdf.
Can you try 1.0.0.RC4 ?
from grails-wkhtmltopdf.
I just tried. Still it is producing empty PDF
compile "org.grails.plugins:wkhtmltopdf:1.0.0.RC4"
any my action is
def show(MyPdfTea myPdfTea) { response.setContentType ("application/pdf") render( filename:"File bla.pdf", view:"/myPdfTea/show", model:[myPdfTea:myPdfTea], //header:"/pdf/someHeader", //footer:"/pdf/someFooter", marginLeft:20, marginTop:35, marginBottom:20, marginRight:20, headerSpacing:10) }
from grails-wkhtmltopdf.
The fix was to make sure response.format
is pdf
, not all
, so you no longer need response.setContentType ("application/pdf")
to get pdf output. Can you confirm that setContentType is no longer needed?
Now I also get an empty pdf. Looks like a different issue.
I get this error message in console:
ERROR org.grails.plugins.wkhtmltopdf.WkhtmltoxExecutor - QFont::setPixelSize: Pixel size <= 0 (0)
QFont::setPixelSize: Pixel size <= 0 (0)
QFont::setPixelSize: Pixel size <= 0 (0)
QFont::setPixelSize: Pixel size <= 0 (0)
Do you get the same error?
from grails-wkhtmltopdf.
This shows a normal show not a pdf.
http://localhost:8080/myPdfTea/show/1
def show(MyPdfTea myPdfTea) { println "--> show pdf tea <---" //response.setContentType ("application/pdf") render( filename:"File bla.pdf", view:"/myPdfTea/show", model:[myPdfTea:myPdfTea], //header:"/pdf/someHeader", //footer:"/pdf/someFooter", marginLeft:20, marginTop:35, marginBottom:20, marginRight:20, headerSpacing:10) }
from grails-wkhtmltopdf.
Try to put ${response.format}
in the view. Does it output "pdf" or "all"?
from grails-wkhtmltopdf.
I changed the code a bit. But still the same. "mypdfaction" contains only one line "${response.format}" . Result is a white page.
Could it be because i have no header and no footer?
def mypdfaction (MyPdfTea myPdfTea){ println "--> mypdfaction <---" //response.setContentType ("application/pdf") render( filename:"File bla.pdf", view:"/myPdfTea/mypdfaction", model:[myPdfTea:myPdfTea], //header:"/pdf/someHeader", //footer:"/pdf/someFooter", marginLeft:20, marginTop:35, marginBottom:20, marginRight:20, headerSpacing:10) }
from grails-wkhtmltopdf.
Shouldn't need a header and footer.
Try adding println response.format
before render. Does it print all
or pdf
?
If all
, do you have other plugins installed?
from grails-wkhtmltopdf.
Result is a white page.
White pdf or white HTML response?
from grails-wkhtmltopdf.
This action
def mypdfaction (MyPdfTea myPdfTea){ println "--> mypdfaction <---" println response.format //response.setContentType ("application/pdf") render( filename:"File bla.pdf", view:"/myPdfTea/mypdfaction", model:[myPdfTea:myPdfTea], //header:"/pdf/someHeader", //footer:"/pdf/someFooter", marginLeft:20, marginTop:35, marginBottom:20, marginRight:20, headerSpacing:10) }
view contains only one line
${response.format}
and the url
Produces a white page. No pdf. And console out put is
--> mypdfaction <---
all
from grails-wkhtmltopdf.
URL needs to be http://localhost:8080/myPdfTea/mypdfaction/1.pdf
from grails-wkhtmltopdf.
Do i have to configure plugin?
I already have installed in my mac
wkhtmltopdf -V
wkhtmltopdf 0.12.2.1 (with patched qt)
now url
produces error. From console
--> mypdfaction <---
ERROR org.grails.web.errors.GrailsExceptionResolver - WkhtmltoxException occurred when processing request: [GET] /myPdfTea/mypdfaction/1.pdf
Cannot find wkhtmltopdf executable at /usr/bin/wkhtmltopdf. Stacktrace follows:
org.grails.plugins.wkhtmltopdf.WkhtmltoxException: Cannot find wkhtmltopdf executable at /usr/bin/wkhtmltopdf
at com.me.MyPdfTeaController.mypdfaction(MyPdfTeaController.groovy:25) ~[main/:na]
at grails.transaction.GrailsTransactionTemplate$2.doInTransaction(GrailsTransactionTemplate.groovy:96) ~[grails-core-3.1.1.jar:3.1.1]
at grails.transaction.GrailsTransactionTemplate.execute(GrailsTransactionTemplate.groovy:93) ~[grails-core-3.1.1.jar:3.1.1]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[na:1.8.0_60]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[na:1.8.0_60]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_60]
from grails-wkhtmltopdf.
in mac it is installed in
which wkhtmltopdf
/usr/local/bin/wkhtmltopdf
from grails-wkhtmltopdf.
Yes, add
grails.plugin.wkhtmltopdf.binary = "/usr/local/bin/wkhtmltopdf"
to application.groovy
or corresponding property to application.yml
if you prefer yml.
from grails-wkhtmltopdf.
I added application.groovy
and not it create a file called "File" no extension. Renamed the "File" to "File.pdf" and opened it. It is blank PDF. Here is console output.
--> mypdfaction <---
ERROR org.grails.plugins.wkhtmltopdf.WkhtmltoxExecutor - QFont::setPixelSize: Pixel size <= 0 (0)
QFont::setPixelSize: Pixel size <= 0 (0)
from grails-wkhtmltopdf.
Command line works perfectly well
$ wkhtmltopdf http://localhost:8080/myPdfTea/show/1 my.pdf
from grails-wkhtmltopdf.
Good, then at least a pdf is created and we're getting the same error. Have no idea what the QFont error is. Any help is appreciated.
from grails-wkhtmltopdf.
Maybe related.
QFont::setPixelSize
from grails-wkhtmltopdf.
The QFont issue is caused by zoom being set to 0.0 due to the fix for #8. The comment for zoom
says "default 1", but results in "--zoom, 0.0" in the argument list. I need to find out how to set default zoom to 1 or disable zoom property again. In the meantime, try adding zoom:1.0
as parameter to render
.
from grails-wkhtmltopdf.
Should be fixed in 1.0.0.RC5
from grails-wkhtmltopdf.
With RC5 i am getting different error.
ERROR org.grails.web.errors.GrailsExceptionResolver - IllegalArgumentException occurred when processing request: [GET] /myPdfTea/mypdfaction/1.pdf
Could not locate mail body /myPdfTea/show/1. Is it in a plugin? If so you must pass the plugin name in the [plugin] variable. Stacktrace follows:
java.lang.IllegalArgumentException: Could not locate mail body /myPdfTea/show/1. Is it in a plugin? If so you must pass the plugin name in the [plugin] variable
at grails.plugins.mail.MailMessageContentRenderer.createTemplate(MailMessageContentRenderer.groovy:95) ~[mail-2.0.0.RC6.jar:na]
at grails.plugins.mail.MailMessageContentRenderer$_render_closure1.doCall(MailMessageContentRenderer.groovy:58) ~[mail-2.0.0.RC6.jar:na]
at grails.plugins.mail.MailMessageContentRenderer$RenderEnvironment.with(MailMessageContentRenderer.groovy:174) ~[mail-2.0.0.RC6.jar:na]
at grails.plugins.mail.MailMessageContentRenderer.render(MailMessageContentRenderer.groovy:57) ~[mail-2.0.0.RC6.jar:na]
at com.me.MyPdfTeaController$$EPfQbamu.mypdfaction(MyPdfTeaController.groovy:28) ~[na:na]
at grails.transaction.GrailsTransactionTemplate$2.doInTransaction(GrailsTransactionTemplate.groovy:96) ~[grails-core-3.1.1.jar:3.1.1]
at grails.transaction.GrailsTransactionTemplate.execute(GrailsTransactionTemplate.groovy:93) ~[grails-core-3.1.1.jar:3.1.1]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[na:1.8.0_60]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[na:1.8.0_60]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_60]
from grails-wkhtmltopdf.
But ${response.format} create a pdf with "all" in it.
from grails-wkhtmltopdf.
Tested 1.0.0.RC5 in Grails 3.1.1 and had no problems. In 3.1.1 I get 'pdf' for println response.format
in controller but 'all' for ${response.format} in view. But as long as the controller thinks the format is pdf it should work.
Do you have any other non default plugins installed?
from grails-wkhtmltopdf.
I just created a test project with one domain and added 1.0.0.RC5 to Grails 3.1.1. My expectation it to convert the view of an object "/myPdfTea/show/1" into PDF.
From command line works perfectly.
wkhtmltopdf http://localhost:8080/myPdfTea/show/1 my.pdf
from grails-wkhtmltopdf.
Can you show the content of the show
method?
from grails-wkhtmltopdf.
def show(MyPdfTea myPdfTea) { println "--> show <---" respond myPdfTea }
from grails-wkhtmltopdf.
I see. There is currently no support for that. You need to call render with a file name and view + other params.
Could possibly enhance WkhtmltoxService.makePdf(config)
called from WkhtmltopdfRenderer
to use a default file name and params and try to generate pdf for all requests that has pdf as response.format.
from grails-wkhtmltopdf.
Generating pdf with blank data.
from grails-wkhtmltopdf.
Related Issues (17)
- Replace render method HOT 1
- "getOutputStream() has already been called" when rendering pdf HOT 1
- Don't replace the render method in the controller HOT 2
- Header doesn't work on Windows HOT 3
- Float options (--zoom) ignored in Wrapper HOT 1
- Add options for viewport? HOT 2
- Render Image from another controller won't work HOT 1
- Error Bad artifact HOT 1
- Cannot invoke method getBean() on null object when gsp contains g:select HOT 1
- A proper guide to add as a Gradle dependency HOT 1
- IllegalArgumentException: Could not locate mail body HOT 5
- Pagination not configurable HOT 1
- Demo request
- Invalid type of printMediaType attribute causing "--page-size specified in incorrect location" HOT 1
- Not able to render font-awesome icons in generated PDFs.
- Deprecated warning
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grails-wkhtmltopdf.