[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1208
  • Last Modified:

How to setup html templateprinter to set number of copies and collate = true?

Hello,
I need to use html to set the number of copies of the html document and set collate = true for the printer settings.  I have been able to modify a sample from an online source but it is so complicated that I wasn't able to incorporate it into my simple html file.

What are the basic components needed to set this up in my file?

Searching on the web I came up with something like this this.. but it doesn't seem to work..

..
..
<?import implementation="#default" namespace="IE">
</head>

<body style="font-family: Arial; font-size: 10pt">

<IE:templateprinter id=printer />

<script language="JavaScript">
printer.copies = 10;
printer.collate = true;
</script>
..
..

Thanks in advance for any help.
0
stringsandbeyond
Asked:
stringsandbeyond
  • 5
  • 4
1 Solution
 
COBOLdinosaurCommented:
You cannot control printer setting from a web page without activex or some other executable.

Cd&
0
 
stringsandbeyondAuthor Commented:
Thanks for the feedback..

Anyone know the cleanest way to do what I want to do?

Thanks
Mike
0
 
COBOLdinosaurCommented:
Okay w'll do it th ehard way:

"The most important requirement is that you work in C++. Even though print templates are HTML files, they can only be used from C++ in an application, Microsoft ActiveX® control, binary behavior, or other binary executable file that hosts the WebBrowser control. There is currently no scriptable mechanism for using print templates, nor any mechanism to use them in Microsoft Visual Basic®. To pass a print template to the WebBrowser control, you must be able to issue or intercept the IDM_PRINT and IDM_PRINTPREVIEW commands through IOleCommandTarget::Exec. The print template path is passed to the WebBrowser control in the pVarArgIn VARIANT argument to IOleCommandTarget::Exec."

Source:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnie55/html/beyondprintpreview.asp#beyondprintpreview_topic5


SO:
" You cannot control printer setting from a web page without activex or some other executable."

Source: COBOLdinosaur

Allyour looking at is a template setup. The browser does not run it. It is simply input to an executable that does the printing. So do the C++ to create the a WebBrowser control and then you ca use your template.

Cd&
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
stringsandbeyondAuthor Commented:
COBOLdinosaur,

Actually what I am doing is hosting a IWebBroser2 interface in a C++ application and am needing to print from it so doing it as you described is very easy.  I am really just facing two problems now:

1. When I call the Exec with the template path in the argument it returns right away.  This causes problems because I need to know when the print is finished so I can release my IWebBrowser2 pointer once it is finished (but not before).  When you call Exec and pass flags in instead of the template path all you have to do is include a WAITFORCOMPLETION flag, but I don't know how to do it when I am passing the path in instead.  Any ideas?

2. I need just an extremely basic template that I can add my template printer settings like collate and number of copies to.  I just want one that will print it using the defaults from the dlg that would come up when you do a normal print.  Have you seen anything like this available?  The only one I have seen that looks like it would work is the template6 from the "Beyond Print Preview..." series samples.  This template crashes when I try to use it, though.

I will increase the points to 500 if you can help us get past these stumbling blocks.

Thanks,
stringsandbeyond
0
 
COBOLdinosaurCommented:
You may be trying to execute before the document is fully loaded. The way to insure you don't try to print until the page is loaded probably requires onreadystatechange to control it.  The M$ documentation for it is here:
http://msdn.microsoft.com/workshop/author/dhtml/reference/events/onreadystatechange.asp

The ready state property is here:
http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/readystate_1.asp

and you will probably have to look at the contentDocument property:
http://msdn.microsoft.com/workshop/browser/hosting/printpreview/reference/properties/contentdocument.asp

About the best I can do beyond that is offer moral support because I don't work with MS specific environments.

Cd&

0
 
stringsandbeyondAuthor Commented:
Cd&,

The code does wait until get_Busy returns FALSE and get_ReadyState returns READYSTATE_COMPLETE.  I am sure it is issuing the command.  Once I have had it start to print, then fail and other times just not have a chance to even send it to the printer.  It does seem that it launches the print, but gets killed when I release the IWebBrowser2 pointer.

Thanks,
David
0
 
COBOLdinosaurCommented:
Yeah well we are outside my area of experise so I don't have a clue where to go from here except you might try posting a  pointer question in C++ to see if you can get C++ expert to cme over here and see if they acan help.

Cd&
0
 
stringsandbeyondAuthor Commented:
Hello Cd&..

The code is setup to print our html file, but going back to our original problem, we aren't quite sure how to setup the printer template file that needs to be passed into the print command.  If we are only trying to set the number of copies to 10, or some other number, then what should the print template file look like?  

and do we need to do anything to our html file that we actually want to print? or do we just specify the number of copies in the print template file?



Thanks
Mike
0
 
COBOLdinosaurCommented:
Within the origial context of the quetion I think I answered it.  However, what they really need isa C++ solution.  If points are awarded, they should go to me; but I have no problem with a dlete/refund.

Cd&
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now