Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #26415

    Hi (again :-p),

    I search to open a dialog with save/open when I generate a PDF. How can I do it ?
    I know that it seems to be possible to do it with tags but I can’t to use them easily.

    I tried to do it with setContentType(), setHeader()… but I didn’t succeed…

    Thanks for your help.

    #28103

    If you use PD4ML JSP taglib, just define inline=”false” and fileName=”file.pdf” attributes of <pd4ml:transform>

    In servlet/PHP/etc scenarios, define

    Content-disposition: attachment; filename=file.pdf

    HTTP response header.

    #28104

    Ok, thanks.

    It was difficult but I succeed. It is a little bit sad and it need to be ameliorated but it works. A simple example :

    int userSpaceWidth = 780;
    File output = new File("document.pdf");
    FileOutputStream fos =  new FileOutputStream(output);
    PD4ML pd4ml =  new PD4ML();
    pd4ml.setHtmlWidth(userSpaceWidth);
    pd4ml.render("http://www.w3.org/", fos);
    
    response.setContentType("application/pdf");
    response.setHeader("Content-Disposition", "attachment; filename=document.pdf");
    FileInputStream fileInputStream = new FileInputStream(output);
    int i;
    while ((i=fileInputStream.read())!=-1)
    {
    response.getOutputStream().write(i);
    }
    response.getOutputStream().flush();
    response.getOutputStream().close();
    fileInputStream.close();
    output.delete();

Viewing 3 posts - 1 through 3 (of 3 total)

The forum ‘General questions / FAQ’ is closed to new topics and replies.