PDF Export

edited March 2010 in FastReport .NET
I am trying to do a direct export to a PDF from a web application.

If I try the simple statement

export.export(rptMain) where rptMain is my report and export has been set as a PDFExport, I will get the following web error:

Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.

I can get around this by using export.export(rptMain, filename) but then I need to know where to save the file on the users machine.

So I have 2 questions:

1. Is there a way to export directly and let the standard download mechanism take over. For example if I use the WebReport control, show the report and then export it to PDF, I get a standard SAVE dialog box with the option to save to a particular directory and change the file name.

2. If #1 is not possible, is there a way to retrieve the default download directory used by the browser and then save the file into this directory? I am assuming this will be the standard windows My Documents\My Downloads directory.

Thanks.

Alan

Comments

  • edited 9:19AM
    Hello,

    Use Report component when exporting to pdf.
          // create report instance
          Report report = new Report();
    
          // load the existing report
          report.Load("report.frx");
    
          // register the data
          report.RegisterData(...);
    
          // run the report
          report.Prepare();
    
          // create export instance
          PDFExport export = new PDFExport();
          
          // export the report to a file. You may export to stream as well.
          report.Export(export, "result.pdf");
    
          // free resources used by report
          report.Dispose();
    

    You may export the report to a stream and write that stream to a page response.
  • edited 9:19AM
    AlexTZ wrote: »
    Hello,

    Use Report component when exporting to pdf.
          // create report instance
          Report report = new Report();
    
          // load the existing report
          report.Load("report.frx");
    
          // register the data
          report.RegisterData(...);
    
          // run the report
          report.Prepare();
    
          // create export instance
          PDFExport export = new PDFExport();
          
          // export the report to a file. You may export to stream as well.
          report.Export(export, "result.pdf");
    
          // free resources used by report
          report.Dispose();
    

    You may export the report to a stream and write that stream to a page response.

    This doesn't work any better than export.export(fname). I still do not get a save file dialog box which means I have to decide where on the users machine to place the report - it should be their decision. If I just do report.export(export, 'result.pdf'), I get a access denied error because it tried to right to the server.
  • edited 9:19AM
    Sorry, there is no way to show the "Save" dialog to the user of your web application using FastReport. You only may save the export result to the response stream, then it will be handled by the browser.
  • edited 9:19AM
    AlexTZ wrote: »
    Sorry, there is no way to show the "Save" dialog to the user of your web application using FastReport. You only may save the export result to the response stream, then it will be handled by the browser.


    Thank-you. I guess the only way to do this is to place a WebReport on the form, make it invisible and then have a button that calls PDFPrint. It seems like a lot of overhead for such a simple request.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.