SAP Knowledge Base Article - Public

1848698 - Fonts are printed as blocky images printing from the Crystal Reports Windows .NET Viewer using PDF Printer drivers

Symptom

When using a third party PDF Printer driver which generates a PDF file and not send it directly to the printer, CR .NET Windows Form Viewers Print button generates the PDF file and inserts the report page as an image. This page is not editable, as well as the fonts and character spacing can be fuzzy and have poor spacing between each letter.

Environment

Crystal Reports Developer for Visual Studio ( Service Pack 5 )

Amyuni PDF Printer driver

Black Ice PDF printer driver

NOTE: there are multiple third party PDF printer drivers available, not all will have these same results.

Reproducing the Issue

  • Install the various third party PDF printer driver packages. In this case I used the Black Ice PDF printer driver package.
  • From the Report Designer and using the Various drivers run a simple report and print to that printer, it will prompt you for a hard disk folder location to save the file to.
  • Open the PDF document, in Adobe Reader 10 or Adobe Pro 10 and notice the page allows you copy individual objects.
  • In the Black Ice driver there is an option to set the output type, PDF, PDF/A, PDF Image, XML with PDF image.
  • Set the option to PDF, if it is not the default, and print the report again.
  • Notice now the text objects are editable or can be copied.
  • In a Windows .NET test application using the PrintToPrint API with an additional warning, BI outputs the report page as an image and warning is popped up by the BI driver - "This Application has Compatibility issues with the Black Ice Printer Driver. Try setting the BIPD as the default printer. Printing will be aborted...."

The Print button in the Windows Viewer uses the same options as the PrintToPrinter API.

 

 

Resolution

For the .NET app you can replace the Print button with your own or disable it and create your own Print button.

Here is an example of using CR .NET code to make this work at runtime using the PrintOutputController, use the SetPrinter API to set the report to the PDF print driver:

private void btnPOController_Click_1(object sender, System.EventArgs e)

{

    System.Drawing.Printing.PrintDocument pDoc = new System.Drawing.Printing.PrintDocument();

    CrystalDecisions.ReportAppServer.Controllers.PrintReportOptions rasPROpts = new CrystalDecisions.ReportAppServer.Controllers.PrintReportOptions();

    CrystalDecisions.Shared.PrintLayoutSettings PrintLayout = new CrystalDecisions.Shared.PrintLayoutSettings();

    CrystalDecisions.ReportAppServer.ReportDefModel.PrintOptions RASPO = new CrystalDecisions.ReportAppServer.ReportDefModel.PrintOptions();

     if (pDoc.PrinterSettings.SupportsColor)

    {

        MessageBox.Show("Printer Supports Color", pDoc.PrinterSettings.SupportsColor.ToString());

    }

    if (rdoCurrent.Checked)

    {

        rasPROpts.PrinterName = cboCurrentPrinters.Text;

        int[] sizes = PaperSizeGetter.Get_PaperSizes(cboCurrentPrinters.Text);

        int paperSizeid = sizes[this.cboCurrentPaperSizes.SelectedIndex];

        if (paperSizeid > 0)

        {

            rasPROpts.PaperSize = (CrystalDecisions.ReportAppServer.ReportDefModel.CrPaperSizeEnum)paperSizeid;

        }

        rasPROpts.BinName = cboCurrentPaperTrays.SelectedItem.ToString();

        rasPROpts.NumberOfCopies = 1;

        rasPROpts.PrinterDuplex = CrPrinterDuplexEnum.crPrinterDuplexSimplex;

        System.Drawing.Printing.Duplex myDup = new Duplex();

        myDup = Duplex.Simplex;

        rasPROpts.PrinterDuplex = (CrPrinterDuplexEnum)myDup;

        if (pDoc.DefaultPageSettings.PaperSize.Height > pDoc.DefaultPageSettings.PaperSize.Width)

        {

            RASPO.DissociatePageSizeAndPrinterPaperSize = true;

            rptClientDoc.PrintOutputController.ModifyPaperOrientation(CrPaperOrientationEnum.crPaperOrientationPortrait);

        }

        else

        {

            RASPO.DissociatePageSizeAndPrinterPaperSize = true;

            rptClientDoc.PrintOutputController.ModifyPaperOrientation(CrPaperOrientationEnum.crPaperOrientationLandscape);

        } 

        string MyRptName = rpt.FileName.ToString();

        MyRptName = MyRptName.Substring(MyRptName.LastIndexOf(@"\") + 1, (rpt.FileName.Length - 3) - (MyRptName.LastIndexOf(@"\") + 2));

        rasPROpts.JobTitle = MyRptName;

    }

    else

    {

        rasPROpts.PrinterName = cboCurrentPrinters.Text;

 

        int[] sizes = PaperSizeGetter.Get_PaperSizes(cboCurrentPrinters.Text);

        int paperSizeid = sizes[this.cboCurrentPaperSizes.SelectedIndex];

        if (paperSizeid > 0)

        {

            rasPROpts.PaperSize = (CrystalDecisions.ReportAppServer.ReportDefModel.CrPaperSizeEnum)paperSizeid;

        }

 

        rasPROpts.BinName = cboDefaultPaperTrays.SelectedText;

        rasPROpts.NumberOfCopies = 1;

 

        rasPROpts.PrinterDuplex = CrPrinterDuplexEnum.crPrinterDuplexSimplex;

 

        System.Drawing.Printing.Duplex myDup = new Duplex();

        myDup = Duplex.Simplex;

        rasPROpts.PrinterDuplex = (CrPrinterDuplexEnum)myDup;

 

        // (CrystalDecisions.ReportAppServer.ReportDefModel.CrPaperOrientationEnum.crPaperOrientationPortrait)

        if (pDoc.DefaultPageSettings.PaperSize.Height > pDoc.DefaultPageSettings.PaperSize.Width)

        {

            RASPO.DissociatePageSizeAndPrinterPaperSize = true;

            rptClientDoc.PrintOutputController.ModifyPaperOrientation(CrPaperOrientationEnum.crPaperOrientationPortrait);

        }

        else

        {

            RASPO.DissociatePageSizeAndPrinterPaperSize = true;

            rptClientDoc.PrintOutputController.ModifyPaperOrientation(CrPaperOrientationEnum.crPaperOrientationLandscape);

        }

 

        string MyRptName = rpt.FileName.ToString();

        MyRptName = MyRptName.Substring(MyRptName.LastIndexOf(@"\") + 1, (rpt.FileName.Length - 3) - (MyRptName.LastIndexOf(@"\") + 2));

        rasPROpts.JobTitle = MyRptName;

    }

 

    try

    {

        rptClientDoc.PrintOutputController.PrintReport(rasPROpts);

    }

    catch (Exception ex)

    {

        MessageBox.Show("ERROR: " + ex.Message);

        return;

    }

    MessageBox.Show("Printing report.", "RAS", MessageBoxButtons.OK, MessageBoxIcon.Information);

    // the next flag is use to set the Viewer to RAS report object

    IsRpt = false;

}

try

{

    if (!IsRpt)

    {

        crystalReportViewer1.ReportSource = rptClientDoc.ReportSource;

    }

    else

    {

        crystalReportViewer1.ReportSource = rpt;

    }

}

catch (Exception ex)

{

    crystalReportViewer1.ReportSource = rpt;

}

See Also

See this kbase article on how to customize the viewers buttons to replace our default functionality to custom code:

1765153 - How to customize .NET Viewer Control Export button to manage custom export options and enable Application as the destination

Keywords

PDF printer, CR for VS, Crystal Reports Developer for Visual Studio, Black Ice,   , KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , Problem

Product

SAP Crystal Reports, developer version for Microsoft Visual Studio