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