US and Worldwide: +1 (866) 660-7555
Results 1 to 4 of 4

Thread: save pdf with a given name

  1. #1
    Join Date
    Mar 2003
    Posts
    4,947

    Default save pdf with a given name

    Hi!!

    I want to know if its posible to save de .pdf with a given standard name... for example: A_Nummer.pdf...

    Thanks a lot!
    Lu.

  2. #2
    Join Date
    Mar 2003
    Posts
    7,557

    Default

    Hi,

    Saving the PDF-File is up to you - as you will be the one that supplies the FileOutputStream for the operation.

    If you want to save the PDF file in a web-environment, then using the Content-Disposition header will do the trick (see RFC1945 for the definition of the HTTP standard).

    Have mo' fun,
    said Thomas

  3. #3
    Join Date
    Mar 2003
    Posts
    4,947

    Default

    thanks taqua for your reply! but i still have the same problem... im not working with a web environment... im working with an application...

    i dont know how to control the FileOutputStream with the JFreeReport. Is there any Property I can config to give the name? or do I have to change any library from the JFreeReports?

    sorry, but im a litle bit lost...


    thanks again! ops:

  4. #4
    Join Date
    Mar 2003
    Posts
    7,557

    Default

    Hi,

    ok, I assume now, that you don't use the JFreeReport-GUI and that you already got the name of the file from the user (or defined it elsewhere).

    The simplest way to save the report is to use the PDFReportUtil class. It defines a default implementation of the report processing code that writes the generated content to a file:

    Code:
    String filename = // created elsewhere
    JFreeReport report = // created elsewhere
    
    PDFReportUtil.createPDF (report, filename);
    If you need more control over the write process, then this is the code that performs the writing:
    Code:
          OutputStream out = new BufferedOutputStream(new FileOutputStream(new File(fileName)));
          final PageFormat pf = report.getDefaultPageFormat();
          final PDFOutputTarget target = new PDFOutputTarget(out, pf);
          target.configure(report.getReportConfiguration());
          target.open();
    
          final PageableReportProcessor proc = new PageableReportProcessor(report);
          proc.setOutputTarget(target);
          proc.processReport();
    
          target.close();
          out.close();
    Have mo' fun,
    said Thomas

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •