Using window.print() to grouping the paper - c#

I am using asp.net. I want to group the output paper from printer printer.
Normaly I use windows.print().
But I don't know how to control the output paper on output paper tray. grouping / shift paper
As you can see on image that the the paper is group from page 1-20, and the printer make a shift to grouping page 20-45.
46-50 in black position
51-80 in blue position ...etc.
So when I took all paper, it easy for me to separate page, because it already done by the printer.

Related

How to print customized barcode labels

I have a windows application which is responsible for printing customized barcode labels roll based on user's needs like specifying the texts, dimensions and size.
The user will use Zepra and TSC barcode printers, I just need to know how to let the user choose determine the size of label and the space between labels and also the all margins (top, right, bottom and left).
I need a code-snippet does that in C# and the final result to be like this.
So, any ideas?
For Zebra part:
Here is an example how to send ZPL commands into printer:
https://km.zebra.com/kb/index?page=content&id=SA301&cat=ZISV_PL_ZPL&actp=LIST
Here you can find pdf document from ZPL commands which are send to printer. Build a suitable set of codes which will produce the label and barcode that you need:
https://www.zebra.com/content/dam/zebra/manuals/en-us/software/zpl-zbi2-pm-en.pdf
Happy Coding!

C# POS receipt printing issue while print commands directly to the printer, bypassing the driver

As per suggestion and provided link by #HansPassant and #Juan from (C# POS receipt printing issue), i have made the changes in code and now writing the print commands directly to the printer, bypassing the driver (using RawPrinterHelper class). But still there is an issue with the POS printer receipt. It is not taking full width to print the row though the text is not cutting now and it is showing as full text (Screenshot attached)
But as you can see in screenshot, there are enough space left in between the right side border (Marked black) and where the text ends. If text is large string then it breaks into new line but not printing to the right side.The receipt is printing with max width which is up-to the end of dotted line.Rest right side part is blank.
Also, Can you tell me how to print Rupee Symbol before the price or amount while writing the print commands directly to the printer. Earlier when i was using the printer driver for a POS printer, there in c# code i was writing as following:
CultureInfo ci = new CultureInfo("hi-IN"); String.Format(ci, "{0:c}",ProductPrice);
But this is not working with print commands directly to the printer. It prints as "?" as you can see just before the price of each item in attached screenshot.
Thanks in advance.

Creating custom size PDF document with Debenu Quick PDF

Hi I am using Debenu Quick PDF Lib.
I couldn't see any sample or info about creating custom size PDF document.
For example I want to create a new document in size of 80mm x 100mm in 300 dpi. Is that possible with QP ?
Thank you .
user3253797,
QP.SetMeasurementUnits(1); // Set the measurement units to mm
QP.SetPageDimensions(80.0, 100.0); // Set the page size to 80mm x 100mm
In a PDF file there is no DPI value as nearly all the values in a PDF are based on floating point numbers.
When SetMeasurementUnits is set to 1 then all values you use for drawing are assumed to be in millimetres. ie. QP.DrawLine(0, 0, 25.4, 25.4); will draw a diagonal line from the bottom left corner (0,0) to a point 1 inch up and 1 inch to the right of the bottom corner of the page. If you need the Origin to be based a the top right then you need to call QP.SetOrigin(1); first.
Also, the "Debenu Quick PDF Library 10 Developer Guide.pdf" is the perfect place to start to learn about Debenu Quick PDF Library. It explains the basics of creating PDF files using the library and some of the fundamentals of PDF files.
Andrew.
Disclaimer: I work for Debenu.

iTextSharp get PDF DPI

How can I get the DPI of the PDF that I am reading from my hard drive into iTextSharp?
PDF's do not necessarily use DPI in their definitions. PDF's allow the document creator to define their own user coordinate space which may or may not map to anything similar to Dots Per Inch.
Check this How to calculate the correct image size in out pdf using itextsharp ?
PDF UserUnit shall give the size of default user space units, in multiples of 1 ⁄ 72 inch.
ISO-32000-1 (section 8.3.2.3) tells us
“the default for the size of the unit in default user space (1/72
inch) is approximately the same as a point (pt), a unit widely used in
the printing industry. It is not exactly the same; there is no
universal definition of a point.”
Conceptually, user space is an infinite plane. Only a small portion of this plane corresponds to the imageable area of the output device: a rectangular region defined by the CropBox entry in the page dictionary. The region of default user space that is viewed or printed can be different for each page.
Coordinates in user space (as in any other coordinate space) may be specified as either integers or real numbers, and the unit size in default user space does not constrain positions to any arbitrary grid. The resolution of coordinates in user space is not related in any way to the resolution of pixels in device space.

print on dot matrix printer in .net

anyone can please tell me the code how to print documents on dot matrix printer in C# windows application.
You can print to dot matrix "graphically", which is built-in in Windows, albeit slower.
But if you only want to print pure text with simple formattings, you need to send escape commands to your dot matrix printer, which is faster than graphical printing. Different printers has different escape commands.
Here are typical escape commands(for epson): http://www.printfil.com/manualen/c5.htm
This might help: https://web.archive.org/web/20051212193242/http://sacpcug.org:80/archives/0306/prc0603.html
What I do in VB6 then was to print to Generic / Text Only printer, you open the PRN or LPT1 as a file handle, then print escape commands on the file handle, all escape commands will be redirected to whatever printer is attached to LPT1 or PRN. You can do the same thing with C#, just open the PRN or LPT1 as a file, then print to it.
To add Generic / Text Only printer, Control Panel > Printers > Add Printer. On manufacturer, select Generic, then on printers, select Generic / Text only.
You can do the same (printing on Generic / Text Only) for Zebra printers which have their own escape commands for printing bar codes, which is faster than letting Windows print to it graphically.
When you print to an inkjet or laser printer, you generally do not use built-in fonts of the printer. You use Windows fonts. What happens is that the printer driver either builds an image of pixels (including the text) and sends it to the printer, or sends commands designed to draw lines, spline curves, and other shapes to the printer, with fonts expressed as lines and splines (outlines).
When you print to an older dot matrix printer, you can do it that way, but it’s slow. Each line of text has to be “built” from pixels, and often the lines of text do not match up with the passes of the print head (especially for fonts much larger or smaller than 12-point).
The old way of using these printers, the way they were intended, was to send the actual ASCII codes of the text to the printer. Send the number 65 (decimal), and you get a capital (upper-case) “A” for instance. The number 49 (decimal) would print the digit “1” while the number 32 would be a blank space, 33 an exclamation point (“!”), and so on. One byte = one character. The dot-matrix printer had its own built-in font, and would look the ASCII code up in its font ROM, and from there determine the exact timings of which print wires would have to strike the page exactly when to produce those letters.
By using ESCape codes, you could specify such effects as pseudo-boldfaced (basically striking the letter twice, with the second copy shifted to the right by only one dot width), double-wide (striking each column of wires twice in a row for each one time that it would normally be struck, thus doubling the width of the letter), underline (striking the bottom print wire throughout regardless of whether the letter shape calls for it at that point or not), and so on.
The printer’s own ROM handled all of these mechanical details about print wires and such. All your program had to supply is the actual ASCII codes of the text (including control codes such as the number 13 [Carriage Return aka CR] to return the print head to the left margin [or, for a bidirectional printer, prepare to print the next line in the reverse order of the previous line], usually followed by the number 10 [Line Feed aka LF] to roll the paper up one line to prepare for printing the next line).
If you wanted to print in fancy fonts that the printer didn’t have, or print graphics, you had to use an ESCape code to set the printer into “graphics mode” in which you basically sent bytes whose bits would specify to fire the individual wires of the printhead under direct program control, rather than looking up character shapes in the printer’s Font ROM. When you print normally from Windows using a printer-specific driver, this is usually what happens.
For daisy-wheel or other fixed-character printers (e.g. IBM Selectric type-ball mechanisms), the ASCII code would spin the wheel or ball to the proper position and then strike the ribbon and thus print the letter on the page, or send the right hammer up to hit the ribbon and thus the page (TeleType or old typewriter mechanism). It was not possible to do pixel graphics with these except by printing repeated periods and micro-advancing the print head and paper the width/height of a period instead of a character / row of text, respectively (which would generally wear out the period character of the daisy-wheel or ball really quickly, so many of them had metal-reinforced periods for that very reason).
How is this different from printing on inkjet or laser printer?
MSDN: Printing Overview
Preview and Print from Your Windows Forms App with the .NET Printing Namespace
Whilst it wasn't in C#, I have written Access reports that used the native fonts of an Epson printer. It was a few year ago - using Windows XP - but when the printer was selected as the default it was possible to choose the "native" fonts of the printer via the font chooser.
It was pretty neat - I could use any font I liked for the headings, which were slow to print. Then I could select the native printer font for the detail rows, which were fast. Doing it that way I had to be careful that all the "native" font detail stauff had exactly the same vertical alignment, otherwise it became slow again.

Categories