How do I print multiple ioComp Plotx plots to a Nova PDF 'printer'? - vb6

I am trying to print the images from the ioComp iPlotX object to a PDF printer. This object has iPlotX.SaveToBitmap, which does work and I can 'send' the file to the PDF printer, but the image is blurry, the bitmap is 96 DPI.
The control has iPlotX.PrintChart method which is supposed to go directly to a printer. There is also a method to indicate which Windows printer to direct the output to. I fumbled around to see if I could get anything to work and a couple times I produced an image in the PDF file that was very clear. But other items printed to the page were gone and I only had one page instead of 3 pages. Most of the times nothing is in the PDF file.
A snippet of my relevant code is below.
Me.SinglePlotObject1(iIndex).PlotControl.PrintShowDialog = False
Me.SinglePlotObject1(iIndex).PlotControl.Printername = modNovaPDFConstants.NOVAPDF_PRINTER_NAME
Me.SinglePlotObject1(iIndex).PlotControl.PrintOrientation = poLandscape
Me.SinglePlotObject1(iIndex).PlotControl.PrintChart
This note is from the ioComp.Help:
Note : If you have set PrintShowDialog to TRUE and have set
PrinterName to a non-empty string, then the printer selected by the
user will be ignored! The PrinterName property will always override
the user printer selection, if you are using our printer dialog If
you plan on showing our built-in printer selection dialog to your end
user, then you should set the PrinterName property to an empty string
for everything to work correctly.
Also from their help is :
property PrintXStart : Double Used to specify the starting x-axis Min
value when implementing multi-page printing.
Description: Use PrintXStart to get or set the starting x-axis Min
value when implementing multi-page printing. By default, the
PrintXStart and PrintXStop are initialized to the Min and Max of the
x-axis display on the screen and will only print out one page. You
must manipulate the PrintXStart and PrintXStop in the OnBeforePrint or
OnBeforePrintPage event to have multiple pages print out during a
single print session.
The only example they show is setting the XStart property to 0. I am not sure if this means multiple pages for the same graph, that is, the graph is stretched out over multiple page or is this has something to with different iPlots on separate pages. In the past we have always just used the iPlotX.SaveToBitmap to print. At that time the plots and text were good enough.
If anyone has any experience with ioComp plot controls and printing, I am willing to try any suggestions.
Right now I am trying to create a test application with as little code as possible to test all of their other printer options.
I have tried their FAQ section but could not find anything related to printing using VB6 and the ActiveX controls. When I sent a message to them, a smtp error appeared.
DaveInCaz: Good Idea. I tried a different PDF printer and results are the same. I tried a method of the control called iPrintToDC, passing in the Printer.hDC. This made some progress. I can print two graphs on two pages, but the graphs are about the size of my thumb. If I change width's or height's, it only makes things worse, by somehow placing the bottom of the graph 'above' the title and removing all the contents of the graph itself; it is as if the graph is wrapped around a cylinder and all I see is where the top and bottom meet. When I used the .PrintChart method, only the last of two charts would be printed and nothing else I printed would appear.
Thanks.

Related

Extract text from rectangle on Windows screen without using OCR

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.

use ghost script to extract single spot color

I am trying to use ghostscript to extract the image for a single spot color (from a PDF), REGARDLESS of whether it would be visible when printed.
I tried using the tiffsep device, but the problem is that any of the spot color that is hidden by objects above does not get sent out.
Is there any device, or settings that would allow simply any objects regardless of visibility to be extracted to a bitmap file.
If an object overlies another in PostScript then it is absolutely correct that it causes the underlying object not to render in that position (modulo overprint) because PostScript has an opaque imaging model.
So no, you can't prevent this, its supposed to work like that.

What is the best way to convert PDF pairs into single pages?

I need to take an existing PDF (created with Prawn), and combine pairs after page 1 (the cover) into single pages. I would also like to add a vertical line in the center of the joined pages. The pages are to be printed in books, and the goal is to make single PDF pages that are similar to the side by side view in Acrobat. I know I can convert them to images, do what I need to with ImageMagick, then put them back into a PDF format, but I am trying to minimize the number of conversions so I can save as much quality as possible.
I also realize I can do this from the start with Prawn, but I am trying to avoid that as it would require a very large change to our application.
It is possible to do this with Ghostscript and the pdfwrite device, but its by no means simple. You need to write some PostScript to do the job.
You would need to add BeginPage and EndPage procedures, the BeginPage would need to check the current page number (and you would need to track this yourself). If its page 1, process normally. If its an even page, throw away the current PageSize and replace it with one which covers a pair of pages. Process the even page. Do not transmit the content.
If the page is odd (and not 1) then translate the origin so that its offset to the right by the width of the page. Process the odd page. use moveto, lineto and stroke to draw the required line between the two pages. Transmit the page.
This assumes that all the pages are the same size and orientation, or least that the sizes of each page are known in advance. It would be possible to retrieve those programmatically as well, but more complex.
Its definitely non-trivial, but if you rummage through my answers in the PostScript tags and look for anything with the word 'imposition' you'll probably find program outlines to do the job.
I did a quick look and here's an answer I wrote some time back. It uses a different approach to that outlined above, it copies some of the guts of the PDF interpreter and repurposes them. It does a chunk of what you want though.

Telerik report fit into a page

I am using telerik reports. Some of my reports are large sized. When printing these reports not fit into default page size. I need to fit it into page by default. How can I implement this? Pls reply
Each report has a defined size in its definition which you can change and the same goes for page margins. You should also have in mind that each printer has hardware margins which is not possible to override. With that taken into account, you should be able to set an appropriate size that prints correctly. If still in dilema, elaborate on the report size, its pagesettings and the printer and paper format you're trying to print to.

Which should not be included in this ZPL Code?

I am developing a Windows Mobile App that requires printing into a Zebra printer. Problem is, I do not have the printer with me here in my country since the client did not provide any.
My approach was to design a label first in ZebraDesigner2, then print out the label into a text file. Printing the label to a text file instead of a printer sends out the ZPL Code to produce the label I was trying to print. Hence, I can generate ZPL codes faster by designing a label first then seeing the ZPL code. Kinda like having a drag and drop GUI with a background XML.
Say that I have this simple label that contains this text:
Hello World!
If I print this in ZebraDesigner2 it would be written to my text file as:
CT~~CD,~CC^~CT~
^XA~TA000~JSN^LT0^MNW^MTT^PON^PMN^LH0,0^JMA^PR5,5~SD15^JUS^LRN^CI0^XZ
^XA
^MMT
^PW609
^LL0406
^LS0
^FT1,29^A0N,28,28^FH\^FDHello World!^FS
^PQ1,0,1,Y^XZ
My main question is, which one do I include in my C# Code if im going to send this code to the printer via my Windows Mobile C# app? Do I include the part with ^XA until ^XZ? I believe that CT~~CD,~CC^~CT~ should not be included in my code If im not mistaken.
Late answer, but since this is getting viewed...
The CT line and first set of XA..XZ sequence sets up the modes, label length, printable area, etc.
If you remove those, it will take those settings from the label/printer settings, which is usually what you want. The printers can sense the length and width of the label.
Leaving them in can cause big problems, because if you define the printable area in your label, and then the next label type submitted does not, it will use the settings you have defined -- which can cause blank areas in the label, eg. cutoff USPS Label barcodes that are printed after your Zebra Designer custom labels.
Found this out the hard way - leave those out, and you should leave out of the remaining XA..XZ sequence the MMT, PW609, LL0406, and LS0 as well - your Hello World will not be affected.
If you really want to limit the area printed to, set up margins inside the printable area, etc, refer to the manual.
you have to look at the programmers guide before you remove anything of the code. The CT~ command for example changes the control prefix.
Search the internet or zebra.com site for "ZPL Programming guide".
So, leave the text file as is and then include that into your windows mobile application.
PS: zebra offers SDKs for label/receipt printers: http://www.zebra.com/gb/en/products-services/software/adapt-software.html
PS2: without a test printer you may get bad final results.

Resources