Hi to all
I'm using Flying Saucer, via the grails pdf plugin
i don't know why, because in the last days i did many thing about how
i use css and i tried to update the pdf plugin of grails (that use
Flying Saucer), but now Flying Saucer is ignoring CSS
Both css embedded and linked, and i really don't know why
here the code of the service of the plugin:
byte[] buildPdfFromFile(url) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ITextRenderer renderer = new ITextRenderer();
try {
renderer.setDocument(url);
renderer.layout();
renderer.createPDF(baos);
byte[] b = baos.toByteArray();
return b
}
catch (Throwable e) {
log.error e
}
}
here how I call it
def baseUri = request.scheme + "://" + request.serverName + ":" +
request.serverPort + grailsAttributes.getApplicationUri(request)
def tmpDirectory = System.getenv("TMP")
def urlFile = tmpDirectory + File.separator +
params.id + ".html"
def fileName = params.filename ?:
params.id + ".pdf"
String testo = new File(urlFile).text
byte[] b
b = pdfService.buildPdfFromString(testo, baseUri)
response.setContentType("application/pdf")
response.setHeader("Content-disposition", "attachment; filename=" +
fileName)
response.setContentLength(b.length)
response.getOutputStream().write(b)
in the urlFile there will be a HTML file like this one (I tried also
with embedded and liked css) but the css is totally ignored... i can
see images (so the base uri is correct) but no the css... i tryed also
with absolute url (for the liked css) but nothing
can someone help?
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<title>Elenca Chiamate</title>
<style type="text/css">body{color:red;font-size:29px;}</style>
</head>
<body>
<a href="/HelpDeskGwt/report/creaPdfDaIdReport/
chiamata_reportElencaChiamate_010420111136_60">Crea e stampa Pdf <img
border="0" src="/HelpDeskGwt/images/pdf_button.png" alt="stampa come
pdf"/></a> || Altre opzioni
<div class="header once">
<div>
<div class="titolo_report">Report Chiamate Manutenzione Preventiva</
div>
<div class="logo"><img class="img_logo" src="/HelpDeskGwt/images/
logo_gestore_120X100.gif" alt="logo"/></div>
<div class="az">
<Strong>Provincia di Varese - Lotto N° 2 (MANUTENCOOP)</
Strong><br/>
<SPAN>Via dei Tigli 10</SPAN><br/>
<SPAN> GALLARATE (VA)</SPAN><br/>
<SPAN>tel 0331 793610 - fax 0331 791652</SPAN><br/>
<SPAN>P.IVA - C.F.: </SPAN>
</div>
</div>
</div>
<div class="header other">
<div>
<div class="titolo_report">Report Chiamate Manutenzione Preventiva</
div>
<div class="logo"><img class="img_logo" src="/HelpDeskGwt/images/
logo_gestore_50X40.gif" alt="logo"/></div>
<div class="az">
<Strong>Provincia di Varese - Lotto N° 2 (MANUTENCOOP)</
Strong><br/>
<SPAN>Via dei Tigli 10</SPAN><br/>
<SPAN> GALLARATE (VA)</SPAN><br/>
<SPAN>tel 0331 793610 - fax 0331 791652</SPAN><br/>
<SPAN>P.IVA - C.F.: </SPAN>
</div>
</div>
</div>
</body>
</html>