I am working with Zebra MZ320 printer to integrate Black mark. I am facing issue when black mark is set to True. The printer feeds 2-3 line after black mark is encountered on paper
The command used to calibrate black mark successfully :
! DF CONFIG.SYS
! UTILITIES
BAR-SENSE
LABEL
PRINT
Sample print text :
! 0 200 200 700 1
COUNTRY UK
COUNTRY UK
TEXT 4 0 0 0 -----------------------------------
TEXT 4 0 0 20 xxxxxxxxxxxxxxxxxxxxxxxxxxx
TEXT 4 0 0 50 xxxxxxxxxxxxxxxxxxxxxxxxxxx
TEXT 4 0 0 80 xxxxxxxxxxxxxxxxxxxxxxxxxxx
TEXT 4 0 0 120 xxxxxxxxxxxxxxxxxxxxxxxxxxx
TEXT 4 0 0 150 xxxxxxxxxxxxxxxxxxxxxxxxxxx
TEXT 4 0 0 180 xxxxxxxxxxxxxxxxxxxxxxxxxxx
TEXT 4 0 0 220 xxxxxxxxxxxxxxxxxxxxxxxxxxx
TEXT 4 0 0 260 xxxxxxxxxxxxxxxxxxxxxxxxxxx
TEXT 4 0 0 310 xxxxxxxxxxxxxxxxxxxxxxxxxxx
TEXT 4 0 0 350 xxxxxxxxxxxxxxxxxxxxxxxxxxx
! DF CONFIG.SYS
! UTILITIES
BAR-SENSE
SETFF 0 0
LABEL
PRINT
I have seen many links that prevent extra feeding but they work with FORM / Continuous mode
Already visited and tried these links :
Zebra iMZ320 image printing feeds too much paper
Stop my mobile printer from feeding extra paper using continuous roll?
Stop a Zebra Printer from automatically feeding lots of extra pape
It seems I am missing some configuration while sending commands to printer. Any suggestion is appreciated.
Sometimes these printers need calibration, did you calibrate it? See the calibration procedure in the user manual.
You can recalibrate the printer with Zebra Tools but also with ZPL commands. Sometimes only recalibration with ZPL commands helps.
Related
I'm using pdfium to add annotations to pdf files.
I opened the pdf file using Notepad++ and viewed its objects. Annotation object was present inside the Page object as follows,
3 0 obj
<</Annots[<</C[ 1 1 0]/CA 1/F 4/QuadPoints[ 0 300 300 300 0 0 300 0]/Rect[ 216.182 702.94 368.75 686.38]/Subtype/Highlight/Type/Annot>>]/Contents 4 0 R /Group<</CS/DeviceRGB/S/Transparency/Type/Group>>/MediaBox[ 0 0 612 792]/Parent 2 0 R /Resources<</ExtGState<</GS7 7 0 R /GS8 8 0 R >>/Font<</F1 5 0 R >>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/StructParents 0/Tabs/S/Type/Page>>
endobj
I used following code to add the rect and attachment points to the annotation.
FPDF_ANNOTATION highlightAnnot = FPDFPage_CreateAnnot(page, FPDF_ANNOT_HIGHLIGHT);
FPDFAnnot_SetRect(highlightAnnot, &rect);
FPDFAnnot_AppendAttachmentPoints(highlightAnnot, &new_quadpoints);
As I understood, Attachment points are set to give the location of Highlight annotation where we want it to be. But I don't understand the purpose of setting the Rect for this annotation.
Can someone please tell the reason for using FPDFAnnot_SetRect function?
Another thing,
FPDFAnnot_SetRect defines the bounding box, while FPDFAnnot_AppendAttachmentPoints defines the actual shape. Consider a multiline highlight annotation, it has only one Rect, but several AttachmentPoints.
A Rect could be used as a "collision box" at application level so that when you click on it, you select the contained annotation. Or it can be an "updating box".
Rect is more general and only text-related annotation types have AttachmentPoints.
I'm developing a printer emulator (partly) in PostScript. The command system I want to emulate is designed for roll paper thermal printers, mostly used for printing Point of Sale receipts. I'd prefer to execute the operations in the same order as the real printer would do, which means my program doesn't know the page size until it encounters a "cut" command. I want the program to work with variable paper size CUPS printers¹.
Can I change the page height after I issued painting/show commands without the filled parts of the document disappearing?
I have tried modifying the page device dictionary at the end of the document, but if I change the PageSize array, everything on the document disappears.
For example if I run the following program:
<< /PageSize [ 100 30 ] >> setpagedevice
0 0 moveto
(Text) show
showpage
I get the output:
But when I modify the code to adjust the page size right before the showpage command:
<< /PageSize [ 100 30 ] >> setpagedevice
0 0 moveto
(Text) show
<< /PageSize [ 100 100 ] >> setpagedevice
showpage
I only get a blank image:
I'm aware I can defer the execution of the painting/show operators, so my program calculates the document size before painting, and only executes the operations when it encounters the cut command. I would be able to implement that by myself, I don't need help with such a solution currently. I'm rather wondering, whether a simpler solution is possible for cutting an already drawn document to a calculated page size.
You cannot use marking operations and then select the page size in PostScript. Setting the media size in PostScript executes an implicit erasepage which clears any marks on the page.
See the note on page 408 of the 3rd edition PLRM (Section 6.1.1 PageDevice Dictionary):
Note: setpagedevice is a page-oriented operator used to control the
output processing of one or more pages of a page description. Any call
to setpagedevice implicitly invokes erasepage and initgraphics, and
thus must precede the descriptions of the pages to be affected.
Thanks to KenS I realized what was wrong with my original approach so I came up with an alternative solution, deferring the execution of the marking operators and calculating the page height beforehand. Below is an incomplete proof of concept of my method of implementing a simple receipt printer with variable page size:
%!
/feed {
0 % return to left margin
currentpoint exch pop % y coordinate
20 sub moveto % feed 20 points
} def
% deferred feed
/_feed {
/feed cvx % push executable name on stack
dup exec % execute procedure, to save position in current point
} def
% deferred show
/_show {
dup % duplicate string
stringwidth rmoveto % simulate position change
/show cvx % push show operator on stack
2 array
astore cvx % create procedure for showing the text
} def
Each time I run the underscore procedures, they will push a procedure on the operand stack, but apply all position changes that will happen during the final execution.
% Set font
/DejaVuSansMono findfont
16 scalefont
setfont
% The receipt itself
0 0 moveto
(text) _show
_feed
(text) _show
_feed
% Save coordinates
currentpoint
/y exch def
/x exch def
% Calculate and set document height based on position
/pageheight y neg def
<< /PageSize [ 100 pageheight ] >> setpagedevice
% Translate the negative y coordinates
0 pageheight 16 sub translate
% reset position
0 0 moveto
% Execute all procedures on the operand stack
count array astore { exec } forall
showpage
The output of this script: the word "text" appearing twice, the image is automatically cut to the right height
It is incomplete of course, but I wanted to demonstrate it the simplest possible way. I hope some will find it interesting/useful.
I have written a C code to generate postscript files from PWG raster files. The output is working on (format is color model - bit depth): black-1, black-8, black-16, rgb-8, rgb-16, gray-1, gray-8, gray-16, srgb-8, srgb-16, adobergb-8, sgray-1, sgray-8, cmyk-1, cmyk-8, cmyk-16.
But the output of adobergb-16 and sgray-16 given is wrong. I get the pattern similar to the input file but the colors are all pixelated.
Actual code is very big, so I am posting what I did:
take all the image pixels in an unsigned char* variable (this sometimes becomes very large)
encode the pixels using deflate algorithm from zlib
display the result
For adobergb-16 I am setting PS colorspace to /DeviceRGB and the decode array is /Decode [0 1 0 1 0 1].
For sgray-16 I am setting the PS colorspace to /DeviceGray and the decode is /Decode [0 1]
These setting are similar to adobergb-8 and sgray-8.
EDIT 1:
Adding the example files I used to test HERE
If you want any further information or the code snippets, please feel free to ask.
Well you've set "/BitsPerComponent 16"; as I said above, that's not a legal value, since PostScript only supports 1, 2, 4, 8 and 12 bits per component.
Running this file through Adobe Acrobat Distiller gives:
%%[ Error: rangecheck; OffendingCommand: imageDistiller; ErrorInfo: BitsPerComponent 16 ]%%
Rewriting your image like this:
gsave
/DeviceRGB setcolorspace
/Input currentfile /FlateDecode filter def
4958 7017 scale
<<
/ImageType 1
/Width 4958
/Height 7017
/BitsPerComponent 8
/Decode [0 1 0 1 0 1]
/DataSource {3 string 0 1 2 {1 index exch Input read {pop}if Input read pop put } for} bind
/ImageMatrix [4958 0 0 -7017 0 7017]
>> image
Sets the BitsPerComponent to 8, discards the top byte of every 16-bit value, and the output works as expected.
When I said 'a nice simple small example' I didn't mean 30 MB of data, that is not necessary to exhibit the problem I am certain. When posting examples make a simple, small, example and use that. I haven't bothered to download your other files.
To reiterate; you cannot set /BitsPerComponent 16, PostScript does not support 16 bits per component.
I'm trying to put a stamp on the top right corner of a PDF file. I have a PS file created from Excel using driver for HP Color LaserJet 4500 printed to file.
I am using GhostScript to create a PDF.
GSWIN32C.EXE #S:\Temp\PS\Options.txt
Here is the contents of the Options.txt file:
-sDEVICE=pdfwrite -q -dSAFER -dNOPAUSE
-sOUTPUTFILE="S:\Temp\PS\Sample.pdf" -dBATCH
"S:\Temp\PS\Stamp.txt"
"S:\Temp\PS\Sample.ps"
Here is the contents of Stamp.txt modified from here:
<<
/EndPage
{
2 eq { pop false }
{
gsave
/Helvetica_Bold 15 selectfont
0 setgray
475 767 moveto
(STATE COPY) show
grestore
true
} ifelse
} bind
>> setpagedevice
The PDF is created just fine, but the stamp is causing me problems. The stamp shows very tiny on the upper left but flipped vertically.
Here is a section with the tiny stamp upper left:
Here is the stamp enlarged 800%
On a multi-page PDF I want the stamp on all pages. I understand that using the /EndPage should let me do that.
So how do I get my stamp on the upper right corner?
I assume the problem with the stamp resides in the previous transformations. So I used scale to flip the stamp upright and adjusted until I got it in the right place.
<<
/EndPage
{
2 eq { pop false }
{
gsave
/Helvetica_Bold 15 selectfont
0 setgray
10 10 scale
375 17 moveto
1 -1 scale
(STATE COPY) show
grestore
true
} ifelse
} bind
>> setpagedevice
I didn't test it but I assume using a different print driver to produce the PS file would give different results.
Guys,
I see ImageMagick is capable to generate image using Pango formatted text, which looks like quite a good approach.
Just want to know if there's anything else out there, what's the most recommended way of doing this.
imagemagick is probably the easiest, but ghostscript can also be used to render images with text.
Here's a little postscript program that displays some text.
%!
5 5 moveto
/Palatino-Roman 20 selectfont
(Some Text) show
showpage
Using ps2eps will calculate the Bounding-Box and add this information as a comment conforming to the Document Structuring Conventions.
%!PS-Adobe-2.0 EPSF-2.0
%%BoundingBox: 5 5 97 20
%%HiResBoundingBox: 5.500000 5.000000 97.000000 19.500000
%%EndComments
% EPSF created by ps2eps 1.64
%%BeginProlog
save
countdictstack
mark
newpath
/showpage {} def
/setpagedevice {pop} def
%%EndProlog
%%Page 1 1
5 5 moveto
/Palatino-Roman 20 selectfont
(Some Text) show
showpage
%%Trailer
cleartomark
countdictstack
exch sub { end } repeat
restore
%%EOF
Then imagemagick's convert utility can render this as an image.
The ps2eps is necessary so the final image is cropped to the interesting part, rather than at the bottom of a page-sized image.
Here's a typescript of the whole sequence. 0> is the command prompt.
0> cat > t.ps
%!
5 5 moveto
/Palatino-Roman 20 selectfont
(Some Text) show
showpage
0> ps2eps t.ps
Input files: t.ps
Processing: t.ps
Calculating Bounding Box...ready. %%BoundingBox: 5 5 97 20
Creating output file t.eps...** Warning **: Weird heading line -- %! -- ready.
0> convert t.eps t.png