i′m trying to render PDF with renderpdf grails plugin,
but their documentation is very short.
i made a button in my gsp view/file
<button type="button">PDF Me!</button>
and
ByteArrayOutputStream bytes = pdfRenderingService.render(template: "/pdfs/report", model: [data: data])
in a view for binding images
<rendering:inlinePng bytes="${imageBytes}" class="some-class" />
model data is domainInstance and how do i connect the button with this renderpdf?
may be i should more specify my code
def invoice ={
def vermittlungInstance = Vermittlung.get(params.id)
def aa = vermittlungInstance.lieferungen.id
def lieferungInstance = Lieferung.get(aa)
def bb = lieferungInstance.packete.id // .id
def packetInstance = Packet.findAllByIdInList(bb)
if (!vermittlungInstance & !lieferungInstance) {
flash.message = "${message(code: 'default.not.found.message', args: [message(code: 'vermittlung.label', default: 'Vermittlung'), params.id])}"
redirect(action: "list")
}
else {
if(vermittlungInstance.rechnungen.id!=null || vermittlungInstance.lieferungen.id!=null || lieferungInstance.packete.id!=null ){
def a = vermittlungInstance.rechnungen.id
def rechnungList = Rechnung.findById(a)
def b = vermittlungInstance.lieferungen.id
def lieferungList = Lieferung.findById(b)
def c = lieferungInstance.packete.id
//println c
def packetList = Packet.findAllByIdInList(c)//findById(c)
def d = packetInstance.artikel.id//id
def artikelList = Artikel.findAllByIdInList(d)//findById(d)
def e = lieferungInstance.adressen.id
def adresseList = Adresse.findById(e)
[vermittlungInstance: vermittlungInstance,
rechnungInstanceList:rechnungList,
lieferungInstanceList:lieferungList,
packetInstanceList: packetList,
artikelInstanceList: artikelList,
adresseInstanceList: adresseList
]
//System.out.println(c)
}
else{
def rechnungList = Rechnung.all
def lieferungList = Lieferung.all
def packetList = Packet.all
def artikelList = Artikel.all
def adresseList = Adresse.all
[vermittlungInstance: vermittlungInstance,
rechnungInstanceList:rechnungList,
lieferungInstanceList:lieferungList,
packetInstanceList: packetList,
artikelInstanceList: artikelList,
adresseInstanceList: adresseList
]
}
}
}
this is my def in a controller, i tried to put this renderpdf on many places, but it won't render the page, actually i am changing some values in html (browser), so it should render in html.
the controller seems to be a wrong place to renderpdf than, but there is no render function for .gsp
thanks
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…