ActiveReports for .NET 3 Online Help Request technical support
Troubleshooting Printing
See Also
User Guide > Troubleshooting > Troubleshooting Printing

Glossary Item Box

Symptoms: The printing thread dies before the report is printed.

Cause: If printing is done in a separate thread and the application is shut down right after the print call, the separate thread will die before the report is printed.

Solution: Set the usePrintingThread parameter of the Print() method to False to keep the printing on the same thread.

 //C#
private void rptPrint_ReportEnd(object sender, System.EventArgs eArgs)

{ this.Document.Print(false, false, false); } 'Visual Basic Private Sub rptPrint_ReportEnd(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.ReportEnd Me.Document.Print(False, False, False) End Sub


Symptoms: In the viewer, the report is rendering to a different paper size than the one specified.

Cause: ActiveReports polls the printer driver assigned to the report to check for clipping, margins, and paper sizes supported by the printer.  If the paper size specified for the report is not supported by the printer, ActiveReports will use the printer's default paper size to render the report.

Solution: If the report is to be printed, the printer assigned to the report must support the paper size and margins. Please note that any changes to the print settings in code must be made in or before the ReportStart event. To use custom paper sizes not supported by the driver, set the PrinterName to an empty string to use the ActiveReports virtual print driver. This will not allow printing, but is recommended for reports that are only exported or viewed. This will prevent Activereports from making a call to the default printer driver. Use the following code in the ReportStart event, or just before .Run is called.

Me.Document.Printer.PrinterName = ""

The PaperHeight and PaperWidth properties, which take a float value defined in inches, will have no effect unless you set the PaperKind property to Custom. Here is some sample code which can be placed in the ReportStart event, or just before .Run.

Me.PageSettings.PaperKind = Drawing.Printing.PaperKind.Custom Me.PageSettings.PaperHeight = 2 'sets the height to two inches Me.PageSettings.PaperWidth = 4 'sets the width to four inches


Symptoms: Custom paper sizes do not work.

Cause: There can be several custom paper sizes, so setting only the PaperKind property is not enough to create a custom paper size.

Solution: In addition to setting the PaperKind property to Custom, you must also set the PaperName property to a unique string.


Symptoms: Blank pages are printed between pages of the report.

Cause: This problem occurs when the PrintWidth plus the left and right margins exceeds the paper width. For example, if the paper size were set to A4, the PrintWidth plus the left and right margins should not exceed 8.27"; otherwise blank pages will be printed. At run time, ActiveReports marks a page overflow by displaying a red line in the viewer at the position in which the breach has occurred.

Solution: The PrintWidth can be adjusted in the report designer using either the property grid or by dragging the right edge of the report. Page margins, height, and width can be adjusted either through the print properties dialog box in the Report menu under Settings. or programmatically in the Report_Start event.


Symptoms: The WebViewer will not automatically print a report without displaying it.

Cause: The WebViewer provides convenience in automating many of the steps involved in providing a reporting solution, but the cost of this automation is a loss of control of these steps.

Solution: In order to provide no touch printing in ASP.NET, stream the file to the ActiveX viewer control and then print using vbscript in the HTML view of the ASP rather than the ASP code behind.

  1. Place the ActiveX Control on the page as an object. Setting the version to -1,-1,-1,-1 forces Internet Explorer to check for updates each time the page is rendered. Setting the height and width to 0 allows you to print the report without displaying it. Here is the code that goes in the HTML view of the ASPX page.

    <OBJECT id=arv codeBase=bin/arview2.cab#version=-1,-1,-1,-1 height=0 width=0 classid=CLSID:8569d715-ff88-44ba-8d1d-ad3e59543dde>

  2. Load the data into the report. Set the DataPath of the viewer object. This can be anything from a byte array to a hard coded path.

    <script language=vbscript> <!-- sub window_onload() arv.datapath = "Default.aspx?ReturnReport=1" end sub

  3. Print the report. This is done by syncing the LoadCompleted event of the viewer. Inside a call is made to the Viewer's PrintReport method with False indicating that no UI is to be displayed.

Symptoms: The StartJob method of the interop system printer throws AccessViolationException.

Cause: The interop assembly was not initialized correctly.

Solution: Use the Initialize method of the ManagedWrapper class. Please note that you can initialize and terminate the ManagedWrapper class in your application only once per session.

 //C# 
public Form()
{ 
	InitializeComponent();
	ManagedWrapper.Initialize();
}

'Visual Basic
Public Sub New()
	MyBase.New()
	InitializeComponent()
	ManagedWrapper.Initialize()
End Sub

See Also

©2009. All Rights Reserved.