cancel
Showing results for 
Search instead for 
Did you mean: 
Subscribe

We are using CRforVS 64bits 13.0.20 on .Net 4.5 all is working fine, but when we try to expor to pdf we find:

Method not found: 'Void CrystalDecisions.ReportAppServer.ReportDefModel.PDfExportFormatOptionsClass.set_CurrentPage(Int32)'.

It also happens to if we try to export to any other format. All is fine when print the report on a pdf printer.We believe that we have tried all possibilities but still it`s the only thing that we do not know how to put to work in all our Project.

Best Regards,

0 Likes
View Entire Topic

Try this:

if (ExportTypeSelected == "crReportExportFormatPDF")
#region PDF
{
    // This works do not alter
    // this gets the report name and sets the export name to be the same less the extension
    string outputFileName = "";
    string MyRptName = rpt.FileName.ToString();
    outputFileName = MyRptName.Substring(9, rpt.FileName.Length - 9);
    outputFileName = outputFileName.Substring(0, (outputFileName.Length - 3)) + "pdf";

    try
    {
        if (File.Exists(outputFileName))
        {
            File.Delete(outputFileName);
        }

        CrystalDecisions.ReportAppServer.ReportDefModel.PDFExportFormatOptions RasPDFExpOpts = new PDFExportFormatOptions();

        try
        {
            RasPDFExpOpts = rptClientDoc.get_SavedExportOptions(CrReportExportFormatEnum.crReportExportFormatPDF);
        }
        catch (Exception ex)
        {
            btnSQLStatement.Text = "ERROR: " + ex.Message;
            //return;
        }

        // Set them now:
        //RasPDFExpOpts.CreateBookmarksFromGroupTree = false;
        //RasPDFExpOpts.EndPageNumber = 1;
        //RasPDFExpOpts.StartPageNumber = 1;

        // Save the udpated info
        if (RasPDFExpOpts != null )
            rptClientDoc.set_SavedExportOptions(CrReportExportFormatEnum.crReportExportFormatPDF, RasPDFExpOpts);

        CrystalDecisions.ReportAppServer.ReportDefModel.ExportOptions exportOpts1 = new CrystalDecisions.ReportAppServer.ReportDefModel.ExportOptions();
        exportOpts1.ExportFormatType = CrReportExportFormatEnum.crReportExportFormatPDF;
        exportOpts1.FormatOptions = RasPDFExpOpts;

        // And Export
        rptClientDoc.PrintOutputController.ExportEx(exportOpts1).Save(outputFileName, true);
        MessageBox.Show("Export to PDF Completed", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
    }
    catch (Exception ex)
    {
        btnSQLStatement.Text = "ERROR: " + ex.Message;
        return;
    }

    //// change selection formula and export again
    //rpt.RecordSelectionFormula = "{Customer.Customer Credit ID} >= 11";
    //rpt.Refresh();
    //outputFileName = outputFileName.Substring(0, (outputFileName.Length - 3)) + "1.pdf";

    //try
    //{
    //    if (File.Exists(outputFileName))
    //    {
    //        File.Delete(outputFileName);
    //    }

    //    CrystalDecisions.ReportAppServer.ReportDefModel.PDFExportFormatOptions RasPDFExpOpts = new PDFExportFormatOptions();

    //    try
    //    {
    //        RasPDFExpOpts = rptClientDoc.get_SavedExportOptions(CrReportExportFormatEnum.crReportExportFormatPDF);
    //    }
    //    catch (Exception ex)
    //    {
    //        btnSQLStatement.Text = "ERROR: " + ex.Message;
    //        //return;
    //    }

    //    // Set them now:
    //    //RasPDFExpOpts.CreateBookmarksFromGroupTree = false;
    //    //RasPDFExpOpts.EndPageNumber = 1;
    //    //RasPDFExpOpts.StartPageNumber = 1;

    //    // Save the udpated info
    //    if (RasPDFExpOpts != null)
    //        rptClientDoc.set_SavedExportOptions(CrReportExportFormatEnum.crReportExportFormatPDF, RasPDFExpOpts);

    //    CrystalDecisions.ReportAppServer.ReportDefModel.ExportOptions exportOpts1 = new CrystalDecisions.ReportAppServer.ReportDefModel.ExportOptions();
    //    exportOpts1.ExportFormatType = CrReportExportFormatEnum.crReportExportFormatPDF;
    //    exportOpts1.FormatOptions = RasPDFExpOpts;

    //    // And Export
    //    rptClientDoc.PrintOutputController.ExportEx(exportOpts1).Save(outputFileName, true);
    //    MessageBox.Show("Export to PDF Completed 2nd time", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
    //}
    //catch (Exception ex)
    //{
    //    btnSQLStatement.Text = "ERROR: " + ex.Message;
    //    return;
    //}
    // This works do not alter
    }
#endregion PDF