why are the extended properties lost if printing to prn file - windows

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.

Related

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}"

How can I make a console-like textbox?

I am making a program called "BasicSys". It is a BASIC System simulator that uses a textbox for the console. So far I have everything working great but I need to have the text box act like a command prompt window. It needs to be able to ask for input and retreive the value without allowing the user to modify anything outside of the prompt space (the space where the user should only be able to type is after a ":" or a ">"). Some feilds are password feilds that require either no echoing or having the chartacters replaced by *'s. Is it possible to make a console out of a textbox?
P.S. I also want to know if there are any small BASIC v2 compilers for Win32 so BasicSys can compile and run BASIC programs.
Depending on how realistic you want it to be you can use the API to open a real console window and interact with it. There are many examples available that you can find by searching such as this one. My suggestion though would be to fake it with a multi-line textbox. It would not be very tricky. Set an index every time you draw the prompt, then as long as the cursor is positioned after the index the textbox is read / write. If the user scrolls backwards make the textbox read only. It should be fairly simple using the KeyDown event and setting the ReadOnly property True / False to get a passable "command" window.

How can I programatically print a DataReport to a pdf file?

I'm updating old VB6 code to save its DataReports out to a PDF, rather than bringing up a print dialog.
I cannot simply write the PDF within the code (using a VB6 PDF library, etc.), since all our software already uses DataReports, and writing print code for each one would be tedious, at best. Currently, the process requires an employee to print the DataReport to a PDF print driver, naming it manually and saving it to where it needs to go. I need to automate this all, so that the name and location of the saved PDF can be specified programatically, rather than entered by hand.
The best solution would be if DataReport simply had a .SaveToPdf(filename) routine. Worst-case scenario, I see myself automating the process using SendKeys. However, this solution needs to work in an environment with multiple possible printers (so the PDF print driver might not be the default,) and on Windows XP, Vista, or 7.
I've fruitlessly tried Googling the problem, which returns only tutorials on how to do it by hand, much as we do now.
You might consider using a PDF Printer Driver that allows you to configure silent "printing" to a preset directory using auto-generated names.
For an example of such a product, see:
http://www.iteksoft.com/modules.php?op=modload&name=Sections&file=index&req=viewarticle&artid=21
I would create a dialog that lets the user enter the printer (driver) name, directory to save to, and a file naming guideline, then save that to either a local ini file or the registry. You would then need two print buttons / menus. One to print straight to the printer using the default (saved) settings, and one that opens the print window they see now so they can perform a custom print.
Remember an ellipsis on a menu item indicates additional dialogs, Print vs Print...
Just use Crystal Report Viewer Control and follow the steps:
Set objRpt = objApp.OpenReport("type report path and name")
objRpt.DiscardSavedData
dim filepath as string
filepath = report path & report filename
With objRpt
.ExportOptions.FormatType = crEFTPortableDocFormat
.ExportOptions.DestinationType = crEDTDiskFile
.ExportOptions.DiskFileName = 'filepath string goes here
.ExportOptions.PDFExportAllPages = True
.Export False
End With
Follow these steps and the export is done.

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

Possible To Print 4-Up From 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.

Resources