Is there any possibility of printing any document (e.g. image, PDF, Office document, etc) with a text label at the top of page? Modifying actual files isn't an option for me. I'm wondering if there's anything like that provided in Windows printing system.
Thanks.
Some printers allow you to add a "watermark" to every page they print (but that functionality is all in the printer drivers, now in Windows itself). If that's available to you, you could probably tweak the watermark to be what you need.
Another tactic--but a challenging one!--would be to create your own printer driver that accepts the Print command from any program, just like a printer, then adds the text label you want, then forwards the print job on to a real physical printer.
Related
I am trying to find a generalized solution on how to save the document as PDF while giving print on my actual printer on Windows 7/10 OS.
Scenario: Whatever I am printing whether an image or a file or from the third party app like POS or Screen Print (like user press pint button on the third party application or press CTRL+P if the third party app supported this hot key), i need to save the document as PDF which this document is reaching to the actual printer which is printing the hard copies. I wanted to generalized to support all kinds of printers be it dot matrix or laser or thermal etc...
Solution which I have tried out:
Virtual Printer which will print pdf and then route the pdf to the actual printer. But few printers doesn't support PDF like Thermal printer do not support PDF, moreover for this i need to take care of the paper settings and page settings.
I have tried Virtual Printers like Win2PDF / ClawPDF
I have looked into the Windows Printing architecture, and tried saving spool file and listening the printing event and routing the spool file to virtual printer to create pdf. This works partially as some of the printer drivers emits the RAW Spool file.
PCL & Postscript can be fine to convert to PDF.
Using Print processor like PrintMulti but the same issue like the 2nd one.
I have tried to look into the even if I can get some kind of input file from which Windows Printing creating the Spool file, but I am unable to get that.
I tried Printer Pooling but that is like a load sharing kind of things.
Could anyone help me on this. I am unable to find any solution over google as well so posting it here. It looks a normal thing to achieve but even after two weeks i am unable to find any solution for this. Is this something difficult to achieve the generalized solution?
Consider an approach using something like the ePrint Virtual Printer which works by capturing the Windows EMF file from the print job and converting it to PDF while also being able to still send the EMF to the physical printer and print it. The application itself allows for the creation of Print Tasks in a Virtual Printer, which can be configured to save to PDF and batch print to other printers.
On the other hand, ePrint is based on the LEADTOOLS Virtual Printer SDK, which could be useful for you to look into if you are looking to code your own approach.
For example, the code for an event that is hooked to a virtual printer to save the captured EMF as PDF:
// Write the EMF as file to disk as PDF.
static void VirtualPrinter_EmfEvent( object sender, EmfEventArgs e )
{
string pdfPath = Path.Combine(
#"c:\Output\PDF\",
Path.GetFileNameWithoutExtension( Path.GetRandomFileName() )
) + ".pdf";
Directory.CreateDirectory( Path.GetDirectoryName( pdfPath ) );
// Create an instance of the LEADTOOLS DocumentWriter
DocumentWriter docWriter = new DocumentWriter();
docWriter.BeginDocument( pdfPath, DocumentFormat.Pdf );
DocumentEmfPage page = new DocumentEmfPage() {
EmfHandle = new Metafile( e.Stream ) )
.GetHenhmetafile()
};
docWriter.AddPage( page );
docWriter.EndDocument();
}
If you are interested in more details, you can check out this article here.
Given a rectangle that represents an area on a Windows screen that contains text, what is the best way to extract the text?
I know that it is possible using OCR, but even after significant pre processing, the quality is really poor.
Getting the Window Text using Win32 API does not always work as well.
Assuming that the text was rendered using a font, is it possible to get it from there?
Any directions would be extremely helpful. Thanks!
Given a rectangle that represents an area on window screen, the best way to extract text is indeed OCR. Use a better OCR library like this one from Microsoft.
The reason getting the window text using Win32 API does not work well is because there may be multiple windows in that rectangle. You will have to find out what all windows the rectangle contains and send a message to get the text for each window. It is not impossible but difficult to do and even if you manage to do that, you will run into issues of text alignment, etc. OCR is your best option.
It does seem possible without using OCR, as NirSoft SysExporter can do this:
https://www.nirsoft.net/utils/sysexp.html
This may be suitable for programmatic use as it can be run from a command line:
Starting from version 1.70, you can export the content of Windows
control from command-line, without displaying any user interface.
You may not be able to target it at a specific rectangle on the screen, but maybe the same result could be achieved by first scraping everything followed by some post-processing.
Further basic info:
SysExporter utility allows you to grab the data stored in standard
list-views, tree-views, list boxes, combo boxes, text-boxes, and
WebBrowser/HTML controls from almost any application running on your
system, and export it to text, HTML or XML file.
...
Known Limitations
SysExporter can export data from most combo boxes, list boxes,
tree-view, and list-view controls, but not from all of them. There are
some applications that use these controls to display data, but the
data itself is not actually stored in the control, but in another
location in the computer's memory. In such cases, SysExporter won't be
able to export the data.
Personally I've used it to grab text from what look like label controls.
I can extract text from a Win7 print driver generated PostScript file, but not from Win8.
For example, creating some text in Windows' "Notepad", telling Notepad to print using an HP PostScript print driver, and telling the print driver to output to a file, I obtain a file that I then want to extract text from.
I have tried Ghostscript's ps2ascii and pstopdf | pdftotext and a number of other things on a Ubuntu platform, and while some of these work on the Win7 output, I can not find any combination that work on the Win8 output.
Is there an Open Source solution to this?
You cannot guarantee getting text from any PostScript program, its not designed for that.
However Ghostscript's txtwrite device will do a decent job on the output from the Windows PostScript printer driver. Its much better than ps2ascii because (amongst other things) it can handle Unicode, so its not limited to ASCII.
Beware that applications may generate PostScript themselves, so even if the output appears to be from the Windows PostScript printer driver, the actual content might be generated by the application.
Also you will only get text out of the Windows PostScript printer driver if the application actually writes text to the device context. For example if you print a PDF from the Edge browser then you will get text in the output. If you print the same PDF from Chrome on the same system, then the text is instead rendered as vectors (ie line, arc, stroke fill etc) not text.
Just be aware that what you are trying to do isn't going to be 100% successful in the general case.
I have two different Zebra printers, the RW420 and the iMZ320.
I am trying to print images on them.
I am using the Java/Android SDK provided by Zebra to first upload the image.
printer.storeImage("R:IMAGE.GRF", ZebraImageFactory.getImage(bmp), ImageUtils.IMAGE_DIMEN, ImageUtils.IMAGE_DIMEN);
On the iMZ320, the image uploads just fine and I am able to print it out.
However, on the RW420, I cannot print the image and when I print the config page with the list of file names, the file is listed as 'IMAGE.PCX'
The printer's language is set to 'ZPL'
Any ideas on why this is happening?
So it depends upon how you created 'printer' in your example. If you used the ZebraPrinterFactory.getInstance(Connection connection) call directly, the SDK will communicate with the printer and determine the type of printer based on a few criteria. For RW420 it will use CPCL as the default language of choice (even though it is in ZPL mode) which will force it to use PCX rather than GRF.
To override this, you can create the printer using the explicit language you wish to use.
ZebraPrinter printer = ZebraPrinterFactory.getInstance(PrinterLanguage.ZPL, connection);
I would like to change colors on printed documents for color-blind people.
Currently I am hooking startDocPrinter, EndDocPrinter, ... with a pdf virtual printer which use postscript and it works well. I am able to change colors.
But I have several printers from different companies : HP, Canon. Each of them seems to use different printing language. When I click on "print into a file", the file written seems always different : PCL, EMF, PostScript, ...
When I look at printing process it seems that GDI API is generic and not related on which printing device I will use. If I hook GDI function, could I be able to change colors on all my printers ?
Do you have any advices about this ?
Thank you.