Skip to Content
author's profile photo Former Member
Former Member

Produce PDF of report directly

Our Windows system is running Crystal Reports. The viewer on the server works great, no issues. The viewer offers a print to PDF option and the PDF is generated, downloaded and all that works great.

What I would like to do is skip the viewer and get straight to the PDF somehow, some way - be that using URL manipulation, form post, whatever. I'm not quite sure what to search for or how to approach this problem as I have 0 experience with Crystal Reports.

To make things more interesting, the Windows report server is on a different machine from the (LAMP) web application.

I'm hopping someone can set me in the right direction.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on May 27, 2014 at 11:47 PM

    Let me try and take another swing at describing the situation.

    We have 2 servers, one of which is a Linux based server and that one runs our web application. Our web application has Crystal Reports embedded in it using an html viewer so the clients can view all the cool reports. Inside of that viewer there is a print button. Clicking on the print button will show a prompt and ask if you want to export to PDF. If you do that you will get a download of the appropriate PDF. Works like a charm. Producing the PDF isn't the issue. It already does that.

    I would like to know if there is a way that I can skip all of that front end stuff and just get a PDF directly.

    The viewer is located eg. example.com/crystalreports/viewer.aspx?gid=t6gdg2g3r6t4d7ddghgb86cd38f4e74fdb3

    I have tried using the following URL parameters with no success (including the OpenDocument URL options).

    &cmd=EXPORT&EXPORT_FMT=U2FPDF%3A0

    &sOutputFormat=P

    I apologize if that's not any more helpful. I am a Linux dev op with clues < 0 when it comes to Windows or Crystal Reports. I'm also not the developer who originally set up the CR viewer.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 20, 2014 at 10:58 PM

    I think You can use OpenDoc link to the report which has a parameter for output format URL parameter. Check the OpenDoc guide

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 20, 2014 at 11:15 PM

    If it is a web / win app processing the reports than, assuming it's .NET (no idea what LAMP is), you'd use code as:

    Dim crReportDocument As New CrystalDecisions.CrystalReports.Engine.ReportDocument
            Dim crExportOptions As ExportOptions
            Dim crDiskFileDestinationOptions As DiskFileDestinationOptions
    
    
    
            ''The path/location where the exported file will be saved
            Dim exportFilePath As String = Application.StartupPath + "\exported.pdf"
    
    
    
            crReportDocument.Load("C:\TESTS\formulas.rpt")
            ''Set the options for saving the exported file to disk
            crDiskFileDestinationOptions = New DiskFileDestinationOptions()
            crDiskFileDestinationOptions.DiskFileName = exportFilePath
    
            ''Set the exporting information
            crExportOptions = crReportDocument.ExportOptions
            With crExportOptions
                .DestinationOptions = crDiskFileDestinationOptions
                .ExportDestinationType = ExportDestinationType.DiskFile
                .ExportFormatType = ExportFormatType.PortableDocFormat
            End With
    
            ''Export the report
            crReportDocument.Export()
    
            ''Display a message letting the user know the export is complete
            MessageBox.Show("Report exported to: '" & exportFilePath & "'")
    
    

    - Ludek

    Senior Support Engineer AGS Product Support, Global Support Center Canada

    Follow us on Twitter

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      I think this answer might be more helpful if I knew what file to edit, where to find that file and how to access that file using a URL, what port it listens on, etc...

      Sorry to be just that ignorant, but I have never used a Windows server and in fact I haven't even used a Windows desktop since 1999. I've been using, supporting and developing Linux servers exclusively for the past 15 years.

      I see a lot of .dll files that I can't open and a lot xml conifg files that seem related, but I don't know. I see javascript files for the aspx viewer and what not.

      I see this kind of thing.

      @ page language="C#" autoeventwireup="true" inherits="_Viewer, App_Web_5r4srsoe"

      Register TagPrefix="CR" Namespace="CrystalDecisions.Web" Assembly="CrystalDecisions.Web, Version=13.0.2000.0,

      and this kind of thing

      <configSections>

      <sectionGroup name="businessObjects">

      <sectionGroup name="crystalReports">

      <section name="crystalReportViewer" type="System.Configuration.NameValueSectionHandler" />

      </sectionGroup>

      </sectionGroup>

      </configSections>

      Am I close?

  • Posted on May 28, 2014 at 02:45 PM

    Hi Mike,

    you can schedule the Crystal Report to PDF in Business Objects Central management Console.

    Thanks,
    Prasad


    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 30, 2014 at 02:31 PM

    Sorry this is so simple but... perhaps you can install Adobe on the report PC and have the default printer be an Adobe printer. The way I do it here is SQL Server has a scheduler which has export to PDF as an option.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 03, 2014 at 07:44 PM

    Update:

    I have done a lot of reading, researching and brain picking. I have found the .NET source code, installed Visual Studio Ultimate (30 day trial as VS Express doesn't work with Crystal Reports).

    In the viewer.aspx.cs code I see the System.Web libraries and the following dependencies:

    using CrystalDecisions.Shared;

    using CrystalDecisions.CrystalReports.Engine;

    using CrystalDecisions.Web;

    using CrystalDecisions.ReportAppServer.ClientDoc;

    using CrystalDecisions.ReportAppServer.DataDefModel;

    using CrystalDecisions.ReportAppServer.Controllers;

    To satisfy those dependences I installed the CR runtime version 13.0.9.1312 and I have been able to debug and build the original source without any issues.

    In the default.aspx.cs file I have located the place in the code where the report is generated and also where it redirects to the viewer.aspx file using a session data; seen here

    Session["rpt_"+gid] = (CrystalDecisions.CrystalReports.Engine.ReportDocument)crReportDocument;
    Response.Redirect("viewer.aspx?gid="+gid);
    
    

    I'm thinking I need to do something like this (correct me if I'm wrong)

    if (Request["format"]=="pdf")
    {
        Response.Redirect("pdf-viewer.aspx?gid=" + gid);
    }
    else
    {
        Response.Redirect("viewer.aspx?gid=" + gid);
    }
    
    

    What I think I need to do after that is to create pdf-viewer.aspx.cs, set headers for a PDF document, get Session["rpt_"+gid] into a PDF generator something/somehow (whatever that may be) and spit it out using something else like buffer or write file to disk and read that out? Not sure how this part works. Advice?

    Also of interest: We are running Windows Server 2008, Crystal Reports 2011, .NET Framework 4. MySQL database, but I can / would like to update to whatever to whatever is currently best practices if / where it isn't a big time sink to do so.

    Thanks for help.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.