|
So I've got an application handling employee timesheets and I'd like to be able to save a timesheet as a PDF for the current user and mail a copy to that user's manager.
I'm using the PDF Plugin and as it works now it seems to only create and save pdfs for the current user. How can I save a copy to the server as well? Thanks for any help, Nate |
|
Looks like the rendering plugin has an API that allows you to provide an OutputStream
Maybe time to switch plugins? Nathan Wells On Wed, Aug 1, 2012 at 11:32 AM, Penguin_Buddha <[hidden email]> wrote: So I've got an application handling employee timesheets and I'd like to be |
|
In reply to this post by Penguin_Buddha
Thanks for the help.
I'm looking over the manual and it talks about providing a destination for the render to write to. I'm unfamiliar with this, how do I provide the server as a destination? |
|
I assume that you'd write it the the filesystem, using the Java File and IO APIs: Good luck! Nathan Wells On Wed, Aug 1, 2012 at 12:30 PM, Penguin_Buddha <[hidden email]> wrote: Thanks for the help. |
|
if you have a chance, have a look at havent got a chance to write documentation yet to get binary Pdf it is as easy as: byte[] pdf = wkhtmltoxService.makePdf( view: "/pdf/invoice", model: [orderInstance: orderInstance], header: "/pdf/invoiceHeader", footer: "/pdf/invoiceFooter", marginLeft: 20, marginTop: 35, marginBottom: 20, marginRight: 20, headerSpacing: 10, ) to send the file to the user's browser, it is as easy as: render( filename:"Gutschrift ${orderInstance.id}.pdf",view:"/pdf/credit", model:[orderInstance:orderInstance], header:"/pdf/invoiceHeader", footer:"/pdf/invoiceFooter", marginLeft:20, marginTop:35, marginBottom:20, marginRight:20, headerSpacing:10 ) cheers tobias Am 01.08.2012 um 21:54 schrieb Nathan Wells:
|
|
In reply to this post by Penguin_Buddha
I've been trying to use the rendering plugin but to no avail. The service is creating a pdf, but something is wrong because my pdf reader claims the pdf isn't a pdf or is corrupted.
Here is my controller:
package testrender
class PrimaryController {
def pdfRenderingService
def index = {
def bytes = pdfRenderingService.render(template: '/primary/test', model: [name: "Nathan"])
new File("Test123.pdf").withOutputStream { outputStream ->
pdfRenderingService.render(template: '/primary/test', model: [name: "Nathan"])
}
}
}
Here is my template <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Title of document</title> </head> <body> Hello! </body> </html> Any idea why the pdf isnt being properly created? |
|
This post has NOT been accepted by the mailing list yet.
this works for me... have a look
def targetDir = adminService.getFilePath('itinerary')
def savedPdf = new File(targetDir + booking?.bookingNumber + '.pdf').withOutputStream { outputStream ->
pdfRenderingService.render(controller: this,
template: "/home/eTicket", model: [booking: booking, fare: fare, addOnAmount: addOnAmount, subTotal: subTotal, vatAmount: vatAmount, totalAmount: totalAmount, totalPayment: totalPayment, logo: logo, qrCodeImage: qrCodeImage],
outputStream)
}
|
| Powered by Nabble | Edit this page |
