Skip to Content
0

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

Jun 20, 2017 at 11:36 AM

156

avatar image
Former Member

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)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

6 Answers

Best Answer
Don Williams
Apr 24 at 04:40 PM
0

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

thanks for your answer.

0
Don Williams
Jun 20, 2017 at 08:02 PM
0

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Thanks.
but the problem does not solve.

0
Don Williams
Jun 22, 2017 at 06:21 PM
0

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

Show 1 Share
10 |10000 characters needed characters left 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)
0
Don Williams
Jun 26, 2017 at 10:21 PM
0

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

Don

Show 3 Share
10 |10000 characters needed characters left characters exceeded
Former Member

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

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

0
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.

0
Don Williams
Jul 05, 2017 at 05:04 PM
0

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

Show 1 Share
10 |10000 characters needed characters left 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.

0
Don Williams
Jul 18, 2017 at 03:01 PM
0

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

Share
10 |10000 characters needed characters left characters exceeded