LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

cannot choose printer when printing HTML report

Solved!
Go to solution

nikosfs,

 

I believe your question is whether this is a bug in LabVIEW that you cannot change your default printer more than once.  I do not believe that is going to be a bug, since you are the one issuing the commands to your registry via the System Exec, and all that function does is execute the commands you send it.

 

Although it is a desirable feature, it is not a bug that the HTML report prints to the default printer.  Unfortunately, this is how the toolkit

works at this time.  If you would like to submit this as a product idea, I encourage you to visit: http://www.ni.com/ideas

 

If you would like to post a copy of your VI broken down into this printer part, I can try to reproduce on my system, and see if I can figure out what the discrepancy is here that is not allowing you to change the printer more than once.

Paul Davidson
National Instruments
Product Owner - ni.com Chat
0 Kudos
Message 11 of 22
(2,101 Views)

Hello,

I attach a DEMO vi that can run and print an HTML report that has an appended JPEG which can be choosed by the user.

Thank you for your help.

0 Kudos
Message 12 of 22
(2,088 Views)

 

nikosfs, I have been able to reproduce your problem on my system, but have not had a chance to fully diagnose it yet.  I am going to continue looking into it, and will get back with you soon.

 

Paul Davidson
National Instruments
Product Owner - ni.com Chat
0 Kudos
Message 13 of 22
(2,064 Views)

Thank you very much for your time.

0 Kudos
Message 14 of 22
(2,058 Views)

nikosfs, I dug down into your code, and found that you are in fact changing the printers in the registry properly, and observed such.  Regardless, however, the problem is with how the report generation toolkit handles printing HTML reports.  To make a long story short, the toolkit ultimately calls Internet Explorer open the HTML file, then print it.  You can actually dig down into our subVIs yourself and observe this.  

 

Internet Explorer has it's own way of reading what the default printer is for a system, and apparently does not always update from what the current registry value is.  It seems to have a cache somewhere that stores that default value at some point in time, and does not check back to your registry to see what the current default is.

 

At this time, I do not see any way to work around this.  Because the problem appears to be in the way that IE handles default printers, I do not know that we will be able to fix it.  I also do not know if there is any time frame on when we may update the HTML report functions in the Report Generation Toolkit.  You may have some luck on your own if you can figure out how IE handles it's default printers, but this goes beyond our expertise.

 

I am going to have this brought up at a meeting tomorrow to find out if there is anything else to look into, and I will let you know if there is.

Paul Davidson
National Instruments
Product Owner - ni.com Chat
0 Kudos
Message 15 of 22
(2,047 Views)

nikosfs, a little bit of good news.  Our LabVIEW experts took a look at this issue, and the issue is indeed because IE doesn't play by the rules when it reads its printer settings in.  Please check out the following article on how you can change the IE settings:

 

http://support.microsoft.com/kb/236777

Paul Davidson
National Instruments
Product Owner - ni.com Chat
Message 16 of 22
(2,035 Views)

I found also this article but the the registry key (Printer) that is said to be responsible for the default printer does not exist.

There are not any subkeys in "PageSetup" and its values do not contain the defaullt printer.

HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\PageSetup\Printer

 

The following registry key also, does not have any value for the default printer or a "PageSetup" key.

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer

 

I found also this article:

http://support.microsoft.com/kb/330628

but it doesn't seem to have something useful. It describes the bug that Internet Explorer has, and a fix that does not work.

 

So, I believe the only way is to change some code in LabVIEW, as far as the Reports is concerned.

The Standard Report has a bug when appending an Image. It cannot handle the margins and the fitting to page.

On the other hand, the HTML Report relies on Internet Explorer when printing, but Internet Explorer has a bug and it cannot see the change of the default printer.

It is disappointing to leave this bug in LabVIEW which is about 25 year-software-developing.

Notice that I use LabVIEW 8.2.1 and Internet Explorer 9.

 

I am always anticipating and kind of solution.

Thank you very much.

0 Kudos
Message 17 of 22
(2,025 Views)

Hi nikosfs,

 

First of all, I want to reiterate what Paul D said: PROGRAMMATICALLY CHANGING REGISTRY VALUES CAN BE VERY DANGEROUS AND HAS THE POTENTIAL TO MAKE YOUR SYSTEM UNUSABLE.

 

I did take a look at the articles you referenced and found this one as well: http://support.microsoft.com/kb/313723

 

It does not appear to be unexpected behavior for the registry keys to not be there.  In this case, IE uses the defaults.  I believe you will need to create these registry keys to get the behavior you are looking for.

 

Have a great day,

 

Chris

Applications Engineer
National Instruments
0 Kudos
Message 18 of 22
(2,010 Views)

I had tried to add the values myself, but with no success.

Firstly, I followed the following steps:

  1. Click Start, click Run, type regedit, and then click OK.
  2. Locate and then click the following key in the registry:
    HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main
  3. On the Edit menu, point to New, and then click String Value.
  4. Type AlwaysUseDefaultPrinter, and then press ENTER.
  5. On the Edit menu, click Modify.
  6. Type yes, and then click OK.

and I didn't see any difference.

 

Then, I added the value "Printer" in the key:

"HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\PageSetup"

and I modified the value data to the name of the printer that I wanted to print, but it printed to the printer that was previously used.

So, the solution is still a mystery, if there is !

0 Kudos
Message 19 of 22
(2,000 Views)

Hi nikosfs,

 

What if you tried to control Internet Explorer's printing through ActiveX?  Perhaps you could generate the report and then just print it with Internet Explorer using the ActiveX controls.  Take a look at this example:

 

http://zone.ni.com/devzone/cda/epd/p/id/1367 (Print File with Internet Explorer)

 

Hope this helps!

 

Chris

Applications Engineer
National Instruments
Message 20 of 22
(1,988 Views)