cancel
Showing results for 
Search instead for 
Did you mean: 

Margin error in SP 19/ 20 ?- Crystal reports for VS

Former Member
0 Kudos

I have rather simple report , no subreports, A4 horizontal. The trouble is on the second and following pages of the report. Top and left margins are set to 1 cm. On the preview everything is ok, margins are visible and about 1 cm. On the print top margin is not visible, top area is cut about 5mm, and left area is cut about 3 mm.

Printer model is OKI B411dn. I also tried with pdfCreator, and with 1 cm set , there's no margins in the PDF file- both top and left margins are nearly 0.

If I set top margin to 25 mm, there's about 3 mm margin on the paper.

The same report ( top/left = 1 cm) printed from SP 19 has top margin about 2 mm , no lost area, and left margin is about 7 mm instead of 10.

The issue is not caused by printer driver, because the same report with margins set at 1/1 cm printed from VB6 app with CR 8.5 has margins about 1/1 cm on the paper.

The second troupbe is different behaviour of the same report on different SP's. Changes are significant, and there' s a must to have different reports for every SP.

I hope there's a solution of above

Piotr

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I don't print rtf via Word. There' s even no MsOffice installed.- there's LibreOffice only.

I' m exporting from CR preview to rtf, and then I'm printing the file from .Net app via :

printProcess.StartInfo.FileName = @"my_file_location";
printProcess.StartInfo.Verb = "Print";
printProcess.StartInfo.CreateNoWindow = true;
printProcess.Start()

Does it still use word/LibreOffice underneath? ?

I will try with your app also.

Thanks

Piotr

Answers (3)

Answers (3)

0 Kudos

Word uses native C++ to build the application, same issue, you are comparing C++ to .NET now.

Try my test printer app, link is on the download page, KBA 2163438.

Try using the POC API, you can set the default to POC in the Viewer properties, to do the printing and see if that resolves the issue. POC uses and ActiveX control and the same printer dialog box CR Designer uses.

Don

Former Member
0 Kudos

Thanks for the example Don, but I'm not shure about conclusion.

I did as in example and when I export form preview to rtf and print - everything is OK.

When I print directly from CR preview , print is moved about 13 mm up and about 15 mm left . Firtst line ( about 8mm) of is cut, and left part of print (table border is cut also) .

I am not sure you ar right with "printer driver supports .Net". I didn't found notice about printer driver .Net compatibility. In my opinion printer drivers are created for OS rather than than for framework.

I can export every print to temporary rtf file, ad print this file, but it's not solution.

Still waiting for real solution.

Piotr

0 Kudos

Hi Piotr,

Comparing the RDC to CR for VS Does not work. RDC used COM, CR for VS uses .NET Framework. What you need is a printer driver that supports .NET Framework.

The real test is to remove CR from the test and use just the Framework.

I can't attach a project to these posts now so create a new C# project and call it DotNETPrint.

Export your report to RTF format or use any simple RTF file.

Paste this into the form1.cs file:

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";
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();

// update your location of any RTF file, keep it simple
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);
}
}

}
}

You can also try using POC to do the printing. Search for KBA 2163438 and see what happens using it.

Don