Skip to Content
avatar image
Former Member

ReportDocument.PrintToPrinter, CrystalReportsViewer (toolbar print button) result is different.

first sorry.. my bad english
i made program CR13 (WPF+C#, VS 2017 Community)


? CrystalReportsViewer -> print button (toolbar)
? ReportDocument.PrintToPrinter()

? It seems that the left margin is different and it is reduced.

I think there is a problem in ?.

How can solve this problem?

img-9051.jpg (145.9 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

6 Answers

  • Best Answer
    Apr 24 at 04:40 PM

    SP 23 will have more updates to the WPF viewer. See if that resolves the issue.

    Add comment
    10|10000 characters needed characters exceeded

  • Jun 20, 2017 at 08:02 PM

    I change the Tag to CR for VS.

    Install the latest SP 20 MSI and test again, note VS 2017 is not supported yet so install the 32 and 64 bit MSI:

    https://wiki.scn.sap.com/wiki/display/BOBJ/Crystal+Reports%2C+Developer+for+Visual+Studio+Downloads

    Don

    Add comment
    10|10000 characters needed characters exceeded

  • Jun 22, 2017 at 06:21 PM

    Ok, need more details then.

    What printer are you using?

    Have you updated to a printer driver that supports .NET Framework?

    Create a new app that just prints a text document, do not use CR just the framework to do the printing.

    Like this:

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Drawing.Printing;
    using System.IO;
    using System.Text;
    using System.Windows.Forms;

    namespace DotNETPrint
    {
    public partial class Form1 : Form
    {
    private Button printButton;
    private PrintDocument printDocument1 = new PrintDocument();
    private string stringToPrint;
    public Form1()
    {
    InitializeComponent();
    this.printButton = new System.Windows.Forms.Button();
    this.printButton.Location = new System.Drawing.Point(12, 51);
    this.printButton.Size = new System.Drawing.Size(75, 23);
    this.printButton.Text = "Print";
    this.printButton.Click += new System.EventHandler(this.printButton_Click);
    this.ClientSize = new System.Drawing.Size(292, 266);
    this.Controls.Add(this.printButton);

    // Associate the PrintPage event handler with the PrintPage event.
    printDocument1.PrintPage +=
    new PrintPageEventHandler(printDocument1_PrintPage);
    }

    private void ReadFile()
    {
    string docName = "don.rtf"; //"begunix.txt"; // "don.rtf"; //
    string docPath = ".\\";
    printDocument1.DocumentName = docName;
    using (FileStream stream = new FileStream(docPath + docName, FileMode.Open))
    using (StreamReader reader = new StreamReader(stream))
    {
    stringToPrint = reader.ReadToEnd();
    }
    }

    private void printDocument1_PrintPage(object sender, PrintPageEventArgs e)
    {
    //int charactersOnPage = 0;
    //int linesPerPage = 0;

    //// Sets the value of charactersOnPage to the number of characters
    //// of stringToPrint that will fit within the bounds of the page.
    //e.Graphics.MeasureString(stringToPrint, this.Font,
    // e.MarginBounds.Size, StringFormat.GenericTypographic,
    // out charactersOnPage, out linesPerPage);

    //// Draws the string within the bounds of the page
    //e.Graphics.DrawString(stringToPrint, this.Font, Brushes.Black,
    // e.MarginBounds, StringFormat.GenericTypographic);

    //// Remove the portion of the string that has been printed.
    //stringToPrint = stringToPrint.Substring(charactersOnPage);

    //// Check to see if more pages are to be printed.
    //e.HasMorePages = (stringToPrint.Length > 0);

    // print word doc

    System.Diagnostics.Process printProcess = new System.Diagnostics.Process();
    printProcess.StartInfo.FileName = @"D:\CPP Net 2010\DotNETPrint\bin\Debug\don.rtf";
    printProcess.StartInfo.Verb = "Print";
    printProcess.StartInfo.CreateNoWindow = true;
    printProcess.Start();

    }

    private void printButton_Click(object sender, EventArgs e)
    {
    ReadFile();
    try
    {
    printDocument1.Print();
    }
    catch (Exception ex)
    {
    MessageBox.Show("ERROR: " + ex.Message);
    }
    }

    }
    }

    Does that work?

    Don

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Ok. I tried testing this source.
      But I don't know if it was right....
      i make don.rtf file with 'TEST PRINT' text .
      this image output without '//' in printDocument1_PrintPage()
      Otherwise, two pages are printed 1st page is 'TEST PRINT' 2nd page is blank.
      thanks.

      img-9083.jpg

      img-9083.jpg (94.0 kB)
  • Jun 26, 2017 at 10:21 PM

    Use an RTF file and not a text file so it is formatted and see if the margins are correct.

    Don

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Don Williams

      I tested it.. and it's OK.
      The printer has been tested with the Samsung M2070 and HP Officejet Pro 8100,
      but the problem seems to be the same on all other printers.

      It seems to be reduced as well as margin.

      thanks.

  • Jul 05, 2017 at 05:04 PM

    All I can suggest then is don't use the CR WPF viewer.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Is there a patch plan for this issue in the future?
      It is supposed to delete the print function of the upper toolbar and make a separate print function after preview.

      thanks.

  • Jul 18, 2017 at 03:01 PM

    Do those "other" printers have the ability to not scale the page?

    Add comment
    10|10000 characters needed characters exceeded