Possible To Print 4-Up From Visual Studio? - visual-studio

I got nowhere Googling for this question so if this is a "Google Is Your Friend (GIYF)" question, I apologize in advance.
I always print source code duplex to save paper. Is there an add-in for VS (2003) which allows you to print two pages on one side of the paper so I can print 4 pages on one sheet? I think this is called 4-Up printing. I'm almost certain I can do this if I drop the printing out to a file and then use an external utility but I'd like to be able to do this all from within VS.

This is usually a function of the printer driver. I use it on the Canon printers to print out pamphlets and the like.
If you have the features for duplex and multipage printing, it'll be in the printer properties of the Print dialog.
To print both sides of the page (duplex), you'll need a duplex attachment on the printer or do the old even/odd page two-pass printing.

As spoulson says, its a function of the printer,
Go File->Print
Click on "Properties . . ." button
Find an option called "Pages per
sheet" (on my currently selected
printer it's on the "Finishing" tab.
Set it to the desired number of
pages
Hope this helps

If you want more control than your printer driver provides, take a look at FinePrint.
It works as a virtual printer and can do all sorts of layout manipulations on print jobs. It can even combine several print jobs into one.

Related

why are the extended properties lost if printing to prn file

if printing direct to printer, all the extended properties of printer setup dialog will work, f.e. stapling, scaling to 50 % or make a watermark on the document. they are very important for the printer finisher to work as expected.
But if I first print to file and then copy the file to printer, all the extended properties are lost on HP Laserjet (PCL).
To reproduce this, I simulated this also in Delphi with a very simple code.
After normal printing to printer worked as expected, I only changed lpszOutput in DocInfo to "...\test.prn" (not more!) and the prn-file has been generated.
Then I opened the file in binary mode and wrote it to same printer ("StartDocPrinter","WritePrinter","EndDocPrinter").
And then the document has been printed correct, but all the settings in extended properties are lost, no scaling, no watermark..
I thought, the printer should get exactly the same binary data stream, but please what can be the reason, that obviously the driver writes different content to prn file and different to printer?
or are there some flags or commands, which I must set by code? is it an HP specific problem?
thank's in advance.
Are you calling PrintDlgEx or PageSetupDlg in both cases?
The properties are in the print job's DEVMODE structure which the driver uses when rendering the job. It sounds like your DEVMODE isn't being set up correctly or is being ignored when you set lpszOutput. The behaviour you're seeing is very similar to that when you uncheck a printer's "Enable advanced printing features" checkbox.
There's some info on using the print dialog with lpszOutput here.

How do I use VBIDE in a VB6 Addin to programmatically print source code..?

How do I programmatically print source code in a VB6 Addin..? There are no print or preview methods that I can find for VBIDE in the Object Browser.
I've searched high & low on Google, and there's a strange lack of information on VBIDE code module printing. I get lots of hits for PrettyPrint, but that's all. The lack is so great that it makes me wonder if there's some fundamental concept that I'm completely missing.
I scared up a copy of the O'Reilly book mentioned by Herb in https://stackoverflow.com/a/41034211/2705042, and it makes no mention of the printing of source code. The only way I can see is to export the code to text files and print those through usual means unrelated to VBIDE.
I also checked Chip Pearson's guide to VBE at http://www.cpearson.com/excel/vbe.aspx, which is almost identical to VBIDE, and even there is no clue to printing of code, other than the idea I mentioned of saving to text files and then printing.
** Ideally, I'd like to use the existing VB6 File > Print dialog, with one extra checkbox added to it. I realize the addition of controls to an existing dialog is another topic, and I'm not averse to creating my own version of the print dialog.
It is possible with a CommandBarButton proxy and SendKeys.
Getting a handle to the Print CommandBarControl is simple enough, but pressing the button throws a dialog in your way, so we have to use SendKeys to set the options and submit the form....
You can use code similar to the following:
Dim printCommand As CommandBarControl
Set printCommand = Application.VBE.CommandBars.FindControl(ID:=4)
printCommand.Execute
'Yep, SendKeys, erghhh
Application.SendKeys "P" 'Force the whole project to print
Application.SendKeys "{ENTER}"

Retrieve CPrintInfo

Is there a way to retrieve CPrintInfo, not only when application do print or print preview (for instance, when I click on some dummy button or something) ? If yes, how can I achieve that ?
No you can't. Maybe with a lot of plumbing you can reuse the MFC print preview stuff, but honestly it's easier to drop down to GDI level printing and do your own print preview. See http://msdn.microsoft.com/en-us/library/windows/desktop/ff819270%28v=vs.85%29.aspx . You need to calculate your own amount of pages etc yourself anyway depending on the printer your print preview should 'emulate'.

How Imitate a [Ctrl+Left mouse click] on the center of the form or open another program and type in a word?

Babylon dictionary and a couple of other dictionaries allow to click on any word in any windows program
and automatically recognize the word under the cursor, and at once open the dictionary window while searching for that word in installed dictionaries.
You can on the other hand open your dictionary, type in your word and press Enter, the result will be the same.
There's a Delphi form, containing a text label, for example with the word "Automaton".
My question is:
How to send a word from my Delphi application right into the dictionary window, as if you typed it manually and pressed Enter?
The best solution is to send some message through the Windows mechanism, but if it is too complicated, there's another solution, and so the second answer: as I described, we need to model a [Ctrl+left mouse] click on a form where this word is displayed on a form [ a visual label on the screen of my Delphi application], to be exact, on some central pixel of this label.
Could you kindly give an advice how to do one thing or another in Delphi ?
** edit:
The problem with AppActivate is this: Babylon dict has a daemon part that seats in the tray.
In the task manager a real window where the text should be input also is named 'Babylon'.
So AppActivate('Babylon') tries to bring to front the non-visual part of the application.
Do you have any suggestion how to determine the windows handle or something of a real visual part of the application? In the task manager, I repeat both visual and non-visual parts are named 'Babylon'.
I cannot offer an answer so much as some insight and advice...
There are certain applications which "intercept" keyboard and mouse instructions, and essentially "nullify" them if they are being immitated by software. Generally-speaking, you'd only see this in proper AntiVirus software such as Kaspersky by design... however:
The way some (not many, but some) programs hook keyboard and mouse inputs, as a side-effect, behave the same way. If you have attempted all of the advice given as comments above, and cannot get Babylon to trigger an action as a result, it is likely Babylon behaves as I have described.
If what I suspect is true, then the method you are attempting is simply not possible (at least, not using any simple Pascal code on its own... ASM might be able to do it but that's beyond my knowledge).
A better solution may be to do a little research to see if any of the following options are available to you:
1) Does Babylon have a Pipeline or API you can use to interface your application(s) with it?
2) Is the particular functionality you require of Babylon accessible through one (or more) DLL files distributed as part of Babylon?
3) Is there an alternative to using Babylon for your needs?
I know it's not an answer as such (certainly not one you'd want to hear), but it may point you in a better direction.

How can I print to a label printer from a web page

I have an e-commerce web application and I'd some how like to make that print to a label printer for the back end stuff
I have two questions
1) I can't print from a normal webpage straight to the printer (A zedbra LP2844 i think) it just throws out junk
2) I want to be able to print labels to the label printer, but all other printing, such as invoices would go to the default printer - a laser, so need someway of selecting the right printer
It will all happen at a fixed location, so I can insist on for example using Firefox with a specific (custom?) plugin installed (already using firefox so this would be a neat way)
Does anybody know if this is possible, is a firefox extention a possible and/or good way of doing this?
Anybody out there that can write ff plugins?
I would presume this must have been done before surely, but cannot find anything on google
Thanks for any help
Dave
Surely the label printer comes with a Windows driver? Then it might be enough to produce pages with the right dimensions in the browser using CSS or, if that won't work out, a PDF.
You can use "cm" or "in" units in your CSS for the label printer; you should be able to set page dimensions and orientation in Firefox's print dialog .
As much as I can see there are Windows drivers for this particular printer. Printing shouldn't be a problem after you install them.
Thanks for your comments people, I've actually come up with a different solution which comes at the problem from a different angle as selecting the correct printer would likely always be an issue
At the moment we have a windows program that we enter the order number into, it then draws a label and prints it out, but its not pretty and getting changes done to the layout is difficult but more than anything I want the ability to print from the webpage
So what I'm planning is this -
Update the program so it sits in the background and polls the database for a list of orders to be printed, for each order it finds, request an image from the server and print that image to the label
On the server, an image is created on the fly using ASPJpeg which gives me full control over how the label looks
From the webapp, I then have a button on the order to print, this adds the order to a print table... I can then have an interface to the print table which shows whats waiting to print, whats been printed etc, and I can clear the print queue or delete individual items from it just as if it were the windows print queue
Only problem I'm worried about is polling often enough that staff aren't waiting for labels to print and not polling too often that too much bandwidth is being used up
I might make it so that when they hit despatch it sends the label to be printed, or some other existing function that ties into the order process

Resources