cancel
Showing results for 
Search instead for 
Did you mean: 

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

inthegroove
Explorer
0 Kudos

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?

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

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

inthegroove
Explorer
0 Kudos

thanks for your answer.

Answers (5)

Answers (5)

0 Kudos

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

0 Kudos

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

inthegroove
Explorer
0 Kudos

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.

0 Kudos

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

Don

inthegroove
Explorer
0 Kudos

OK!

I'll try again.

But it seems strange.
There is no problem in Excel, and there is no problem in this computer at CR 9.

If CR9 and CR13 runtime modules are installed together, can error or this problem occur?

thanks

0 Kudos

WPF is native to Office, CR is new to WPF, it is still early in it's history.

What printer are you using? If it's the XPF printer then don't, know issues with it. Try a real printer.

Don

inthegroove
Explorer
0 Kudos

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.

0 Kudos

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

inthegroove
Explorer
0 Kudos

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

0 Kudos

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

inthegroove
Explorer
0 Kudos

Thanks.
but the problem does not solve.