You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Ted Young <ty...@ncoastsoft.com> on 2006/06/14 22:35:04 UTC

More Info: Card Printing and Mag Stripe Encoding

Well, through some more investigation and trial-and-error, I have found that
by using gradients anywhere on my document, all text in my document IS being
rasterized before going to the printer.  By taking the gradients out, once
can notice substantially clearer text.  Text that overlaps images is also
rasterized. 

 

I am assuming, at this point, that this rasterization is occurring at the
whim of the Graphics object.  I will pursue that possibility next.

 

Ted

  _____  

From: Ted Young [mailto:tyoung@ncoastsoft.com] 
Sent: Wednesday, June 14, 2006 2:59 PM
To: batik-users@xmlgraphics.apache.org
Subject: Card Printing and Mag Stripe Encoding

 

Good day to everyone,

 

I am using Batik to dynamically generate ID cards (XML + XSL = SVG ->
Batik/Printer).  The whole thing works great.  The only problem I am running
into is that I need to transmit a string of text to the printer to be
encoded on the mag stripe.

 

I am using Fargo's DTC 550 LC printer.  When it encounters a string of text
like ~1%123? It will, instead of printing that string, encode 123 on track 1
of the mag stripe.  I can open up Word, for example, and print this string,
along with any other text and graphics, and the printer will detect it and
forward it to the mag stripe.

 

However, when I include this string in my SVG, the printer just prints it to
the card.  I am pretty confident that the text on the card is being sent to
the printer as text (not as glyphs or raster) since the printer will print
black TrueType data in pure black (allowing for things like barcodes).  And,
it appears that this is working just fine.

 

My suspicion is that the text string ~1%123? Which I embed in a <text
.></text> tag is being broken up with formatting/layout information, but
this is just a guess.

 

First, here is how I am printing the SVG documents:

 

PrintTranscoder transcoder = new PrintTranscoder();

transcoder.transcode(new TranscoderInput(svg.front), null);

transcoder.transcode(new TranscoderInput(svg.back), null);

 

String title = ((SVGOMDocument)svg.front).getTitle();

                        

HashPrintRequestAttributeSet settings = new HashPrintRequestAttributeSet();

settings.add(OrientationRequested.PORTRAIT);

settings.add(new JobName(title, null));

settings.add(new MediaPrintableArea(0f, 0f, 2.125f, 3.375f,
MediaSize.INCH));

 

DocPrintJob printJob = Configuration.printer.createPrintJob();

SimpleDoc doc = new SimpleDoc(transcoder,
DocFlavor.SERVICE_FORMATTED.PRINTABLE, null);

printJob.print(doc, settings);

 

 

Thanks for your patience.  Here is where it gets a little more interesting.
I decided to verify that it isn't something with the Java print service or
the driver, so I tried:

 

Printable p = new Printable() {

            public int print(Graphics graphics, PageFormat pageFormat, int
pageIndex) throws PrinterException {

                        if (pageIndex == 0) {

                                    graphics.drawString("~1%123?", 10, 10);

                                    return Printable.PAGE_EXISTS;

                        } else {

                                    Return Printable.NO_SUCH_PAGE;

                        }

            }

};

 

This works!  The data is sent to the mag encoder.  So, I went one step
further:

 

Printable p = new Printable() {

            public int print(Graphics graphics, PageFormat pageFormat, int
pageIndex) throws PrinterException {

                        if (pageIndex == 0) {

                                    graphics.drawString("~1%123?", 10, 10);

                        return transcoder.print(graphics, pageFormat,
pageIndex);

            }

};

 

Now we are back to the same problem.  The text appears on the card.

 

Would anyone know why this happens, and/or how to work around it.

 

Thank you,

 

Ted Young

 


Re: More Info: Card Printing and Mag Stripe Encoding

Posted by th...@kodak.com.
Hi Ted,

"Ted Young" <ty...@ncoastsoft.com> wrote on 06/14/2006 04:35:04 PM:

> Well, through some more investigation and trial-and-error, I have found 
that 
> by using gradients anywhere on my document, all text in my document IS 
being 
> rasterized before going to the printer.  By taking the gradients out, 
once can
> notice substantially clearer text.  Text that overlaps images is also 
rasterized. 
> 
> I am assuming, at this point, that this rasterization is occurring at 
the whim
> of the Graphics object.  I will pursue that possibility next.

   Yes, the print method is actually called multiple times, the first
time it 'scopes things out' and tries to identify regions where it will
have to rasterize content (opacity and bitmaps, etc).  Then it actually
calls your print method to generate output (usually in stripes so this
may involve a great many calls).  I should note that this is the JVM's
Graphics object, not ours...

   If your drawing has an empty border around it (common for cards) I
would try drawing the text there as long as any part of the text is
'on the page' it should be included, hopefully.

   Anyway, good luck!

> From: Ted Young [mailto:tyoung@ncoastsoft.com] 
> Sent: Wednesday, June 14, 2006 2:59 PM
> To: batik-users@xmlgraphics.apache.org
> Subject: Card Printing and Mag Stripe Encoding
> 
> Good day to everyone,
> 
> I am using Batik to dynamically generate ID cards (XML + XSL = SVG -> 
> Batik/Printer).  The whole thing works great.  The only problem I am 
running 
> into is that I need to transmit a string of text to the printer to be 
encoded 
> on the mag stripe.
> 
> I am using Fargo’s DTC 550 LC printer.  When it encounters a string of 
text 
> like ~1%123? It will, instead of printing that string, encode 123 on 
track 1 
> of the mag stripe.  I can open up Word, for example, and print this 
string, 
> along with any other text and graphics, and the printer will detect it 
and 
> forward it to the mag stripe.
> 
> However, when I include this string in my SVG, the printer just prints 
it to 
> the card.  I am pretty confident that the text on the card is being sent 
to 
> the printer as text (not as glyphs or raster) since the printer will 
print 
> black TrueType data in pure black (allowing for things like barcodes). 
And, 
> it appears that this is working just fine.
> 
> My suspicion is that the text string ~1%123? Which I embed in a <text 
> …></text> tag is being broken up with formatting/layout information, but 
this 
> is just a guess.
> 
> First, here is how I am printing the SVG documents:
> 
> PrintTranscoder transcoder = new PrintTranscoder();
> transcoder.transcode(new TranscoderInput(svg.front), null);
> transcoder.transcode(new TranscoderInput(svg.back), null);
> 
> String title = ((SVGOMDocument)svg.front).getTitle();
> 
> HashPrintRequestAttributeSet settings = new 
HashPrintRequestAttributeSet();
> settings.add(OrientationRequested.PORTRAIT);
> settings.add(new JobName(title, null));
> settings.add(new MediaPrintableArea(0f, 0f, 2.125f, 3.375f, 
MediaSize.INCH));
> 
> DocPrintJob printJob = Configuration.printer.createPrintJob();
> SimpleDoc doc = new SimpleDoc(transcoder, 
DocFlavor.SERVICE_FORMATTED.PRINTABLE, null);
> printJob.print(doc, settings);
> 
> 
> Thanks for your patience.  Here is where it gets a little more 
interesting.  I
> decided to verify that it isn’t something with the Java print service or 
the 
> driver, so I tried:
> 
> Printable p = new Printable() {
>             public int print(Graphics graphics, PageFormat pageFormat, 
int 
> pageIndex) throws PrinterException {
>                         if (pageIndex == 0) {
>                                     graphics.drawString("~1%123?", 10, 
10);
>                                     return Printable.PAGE_EXISTS;
>                         } else {
>                                     Return Printable.NO_SUCH_PAGE;
>                         }
>             }
> };
> 
> This works!  The data is sent to the mag encoder.  So, I went one step 
further:
> 
> Printable p = new Printable() {
>             public int print(Graphics graphics, PageFormat pageFormat, 
int 
> pageIndex) throws PrinterException {
>                         if (pageIndex == 0) {
>                                     graphics.drawString("~1%123?", 10, 
10);
>                         return transcoder.print(graphics, pageFormat, 
pageIndex);
>             }
> };
> 
> Now we are back to the same problem.  The text appears on the card.
> 
> Would anyone know why this happens, and/or how to work around it.
> 
> Thank you,
> 
> Ted Young
>