Search in sources :

Example 21 with PdfAction

use of com.lowagie.text.pdf.PdfAction in project qcadoo by qcadoo.

the class ReportPdfView method buildPdfDocument.

@Override
protected void buildPdfDocument(final Map<String, Object> model, final Document document, final PdfWriter writer, final HttpServletRequest request, final HttpServletResponse response) {
    String fileName;
    try {
        PdfAction ac = PdfAction.gotoLocalPage(1, new PdfDestination(PdfDestination.XYZ, -1, -1, 1f), writer);
        writer.setOpenAction(ac);
        fileName = addContent(document, model, LocaleContextHolder.getLocale(), writer);
    } catch (DocumentException e) {
        throw new IllegalStateException(e.getMessage(), e);
    } catch (IOException e) {
        throw new IllegalStateException(e.getMessage(), e);
    }
    response.setHeader("Content-disposition", "inline; filename=" + fileName.replaceAll(",", ".") + "." + ReportService.ReportType.PDF.getExtension());
}
Also used : PdfAction(com.lowagie.text.pdf.PdfAction) DocumentException(com.lowagie.text.DocumentException) PdfDestination(com.lowagie.text.pdf.PdfDestination) IOException(java.io.IOException)

Aggregations

PdfAction (com.lowagie.text.pdf.PdfAction)21 Document (com.lowagie.text.Document)13 Chunk (com.lowagie.text.Chunk)12 Paragraph (com.lowagie.text.Paragraph)10 PdfWriter (com.lowagie.text.pdf.PdfWriter)9 PdfContentByte (com.lowagie.text.pdf.PdfContentByte)8 FileOutputStream (java.io.FileOutputStream)7 PdfDestination (com.lowagie.text.pdf.PdfDestination)6 Rectangle (com.lowagie.text.Rectangle)5 Test (org.junit.Test)5 DocumentException (com.lowagie.text.DocumentException)4 Phrase (com.lowagie.text.Phrase)4 IOException (java.io.IOException)4 Image (com.lowagie.text.Image)3 PdfFormField (com.lowagie.text.pdf.PdfFormField)3 Font (com.lowagie.text.Font)2 PdfAnnotation (com.lowagie.text.pdf.PdfAnnotation)2 PdfFileSpecification (com.lowagie.text.pdf.PdfFileSpecification)2 PdfLayer (com.lowagie.text.pdf.PdfLayer)2 PdfLayerMembership (com.lowagie.text.pdf.PdfLayerMembership)2