LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

NI Reports printing problem.

Hi,

I have an application that uses NI Reports. When I attempt to print the
report using some printers I get an error but with other printers there
is no problem at all. The printers tried are;

1. Brother MFC 9760 USB, network. OK.
2. Brother MFC 9760 USB, local. OK.
3. Epson Stylus Centronics, network. FAILS.
4. Epson Stylus Centronics, local. FAILS.
5. Cannon BJ-10EX, Centronics, network. FAILS.
6. Cannon BJ-10EX, Centronics, local. FAILS.
7. Win2PDF (a virtual PDF printer), local. OK.

The print function "NIReport_Print ()" returns -4 in all cases of
failure. Unfortunately the error messages "Misc/unknown error calling
method" & "Unknown automation error" don't mean a lot to me.

I am using CVI 6.0.0 and Windows XP Home SP1 with 496Mbytes RAM.

The printer is selected by the user from a ring control. The ring
control is populated at run time by the following function;

/* Populate the printer ring control. */
int findPrinters(void)
{
/* Variables. */
char **allPrinters;
char **printer;
char *defaultPrinter;
int numberOfPrinters = 0;
int defaultPrinterNumber;

ClearListCtrl (reportHandle, REPORT_PRINTERS);
SetCtrlVal(reportHandle,REPORT_COPIES,1);

if(0 != NIReport_GetPrinters (&defaultPrinter, &allPrinters)){
MessagePopup(title,"ERROR - unable to find printers.");
return -1;
}
printer = allPrinters;
while (*printer != NULL){
InsertListItem (reportHandle, REPORT_PRINTERS, -1,
*printer, *printer);
if(0 == strcmp(*printer,defaultPrinter))
defaultPrinterNumber = numberOfPrinters;
++numberOfPrinters;
NIReport_FreeMemory (*printer++);
}
NIReport_FreeMemory (allPrinters);

if(0 < numberOfPrinters)
SetCtrlIndex (reportHandle, REPORT_PRINTERS,
defaultPrinterNumber);

return numberOfPrinters;
}

The code to print the report is as follows;

/* Get the printer name and the number of copies required. */
GetCtrlIndex (reportHandle, REPORT_PRINTERS, &index);
GetValueLengthFromIndex (reportHandle, REPORT_PRINTERS,
index, &length);
if(500 < length){
MessagePopup(title,"ERROR - printer name too long.");
return;
}
GetCtrlVal(reportHandle,REPORT_PRINTERS,printerName);
GetCtrlVal(reportHandle,REPORT_COPIES,&copies);

/* Print the report.*/
if(0 != (status=NIReport_Print (niReportHandle, printerName,
copies))){
sprintf(msgStr,"Error %d; %s occured when printing the
report to %s.",status,NIReport_GetErrorString (status),printerName);
MessagePopup(title,msgStr);
}
else{
MessagePopup(title,"Report printed.");
}

If you can help at all I'd be very grateful.
--
John Cameron
0 Kudos
Message 1 of 9
(4,904 Views)
Hello John,

The problem that you are having with certain printers when using NIReport_Print() is a known issue and work is being done to resolve it. This problem has been reported previously, but there has been some trouble in reproducing the error. The problem doesn�t appear to be with the code that you submitted. The fault seems to be with the drivers for those particular printers.

Here are a couple of suggestions:

1) Check with Epson and Cannon to be sure that you are using the most recent drivers for your printers (If you are already using the most recent drivers, try downgrading. This has been known to solve similar problems in the past). You should be able to acquire their newest drivers at their respective websites.

2) For the time being,
continue using the printers that have been proven to work and try replacing the ones that don�t.

Hopefully, continued work on this issue will lead to a more concrete solution. Let me know if you have any additional questions on this issue.

Scott Romine
National Instruments
Scott Romine
Course Development Engineer
National Instruments
0 Kudos
Message 2 of 9
(4,903 Views)
In message <5065000000050000005F6C0100-1079395200000@exchange.ni.com>,
Scott R writes
>Hello John,
>
> The problem that you are having with certain printers when using
> NIReport_Print() is a known issue and work is being done to resolve
> it. This problem has been reported previously, but there has been
> some trouble in reproducing the error. The problem doesn?t appear to
> be with the code that you submitted. The fault seems to be with the
> drivers for those particular printers.
>
>Here are a couple of suggestions:
>
>1) Check with Epson and Cannon to be sure that you are using the most
>recent drivers for your printers (If you are already using the most
>recent drivers, try downgrading. This has been known t
o solve similar
>problems in the past). You should be able to acquire their newest
>drivers at their respective websites.
>
>2) For the time being, continue using the printers that have been
>proven to work and try replacing the ones that don?t.
>
> Hopefully, continued work on this issue will lead to a more
> concrete solution. Let me know if you have any additional questions
> on this issue.
>
>Scott Romine
>National Instruments

Oh dear,

My customer won't like that very much - I heard today that they have the
same problem with 2 HP Laser printers.

I'll try what you suggest, but reverting to an older driver isn't really
a deliverable solution on machines with printers installed for other
uses as well.

If I can do anything to help you solve this problem please let me know,
I will be very happy to help if I'm able.

Enjoy South by South West (I'm assuming that your in Austin).
--
Regards,

John Cameron.
Type softly, read gently.
0 Kudos
Message 3 of 9
(4,903 Views)
John,

The problem is reproducibility of the error. If you are willing to send one of the printers so that we can see the error for ourselves, we can then take steps to repair it. Fixing the error for one of the printers should take care of it for the others as well.

Let me know if this is a viable option for you.

Scott Romine
National Instruments
Scott Romine
Course Development Engineer
National Instruments
0 Kudos
Message 4 of 9
(4,903 Views)
In message <506500000005000000316E0100-1079395200000@exchange.ni.com>,
Scott R writes
>John,
>
>The problem is reproducibility of the error. If you are willing to
>send one of the printers so that we can see the error for ourselves,
>we can then take steps to repair it. Fixing the error for one of the
>printers should take care of it for the others as well.
>
>Let me know if this is a viable option for you.
>
>Scott Romine
>National Instruments

Where would you like it sent to? Let me know and I'll check the cost for
shipping the small Canon BJ-10.
--
Regards,

John Cameron.
Type softly, read gently.
0 Kudos
Message 5 of 9
(4,903 Views)
In message , John Cameron
writes
>In message <506500000005000000316E0100-1079395200000@exchange.ni.com>,
>Scott R writes
>>John,
>>
>>The problem is reproducibility of the error. If you are willing to
>>send one of the printers so that we can see the error for ourselves,
>>we can then take steps to repair it. Fixing the error for one of the
>>printers should take care of it for the others as well.
>>
>>Let me know if this is a viable option for you.
>>
>>Scott Romine
>>National Instruments
>
>Where would you like it sent to? Let me know and I'll check the cost
>for shipping the small Canon BJ-10.


Hi Scott,

This is a serious offer.
--
Regards,

John Cameron.
Type s
oftly, read gently.
0 Kudos
Message 6 of 9
(4,903 Views)
John,

I will send you an email soon with the information that you will need to ship the printer to us.

Scott Romine
National Instruments
Scott Romine
Course Development Engineer
National Instruments
0 Kudos
Message 7 of 9
(4,903 Views)

I have the same PB with HP 5940 and HP 840C. How have you resolved your problem?

Have you had a list of printers where NI-REPORTS print fetaure works?

I am working with CVI 8.0.1 and XP service pack 2.

Thanks.

0 Kudos
Message 8 of 9
(4,595 Views)
jyd,

The problem is that the default margins selected in CVI are not valid for the printers that return the error. Different printers have different acceptable print margins. Decreasing the print area height and width in CVI will result in proper report printing.

The default margins that the NIReport_Print function uses are not valid for some printers. In order to resolve the problem, you have to programmatically change the margins used by the NIReport functions, by adding the following lines of code to your application:

NIReport_SetReportAttribute (reportHandle, NIR_ATTR_LEFT_MARGIN, 2.5);
NIReport_SetReportAttribute (reportHandle, NIR_ATTR_RIGHT_MARGIN, 2.5);
NIReport_SetReportAttribute (reportHandle, NIR_ATTR_TOP_MARGIN, 2.5);
NIReport_SetReportAttribute (reportHandle, NIR_ATTR_BOTTOM_MARGIN, 2.5);

Message Edited by Jon M on 12-11-2006 01:30 PM

Test Engineer - CTA
0 Kudos
Message 9 of 9
(4,558 Views)