Dithering problems with a barcode in a PDF document

Helge Blischke h.blischke at acm.org
Mon Dec 12 10:24:08 PST 2011


Johan Henselmans wrote:

> Op 12/12/11 2:53 PM, Helge Blischke schreef:
>> Johan Henselmans wrote:
>>
>>> Some years ago, I have developed a printer driver for a 200/300/600 dpi
>>> boca printer that translates the black/white cupsraster images in the
>>> raster of the printer.
>>>
>>> The printer supports downloadable fonts and has internal barcode fonts,
>>> and a possibility to download images etc.
>>>
>>> So the filter is defined as
>>>
>>> Filter application/vnd.cups-raster 100 rastertoboca.
>>>
>>> That works well with standard data, like text and images (allthough this
>>> could have some improvement...) but it is not working well with
>>> barcodes: If the barcodes are small in the pdf document, then the
>>> rastering is really horrible and makes the result unusable for scanning.
>>> the bars look ragged, and sometime the empty space between bars is
>>> completely filled up.
>>>
>>> The path that was used for the output was: pstoappeps| pstocupsraster|
>>> rastertoboca.
>>>
>>> I did some measurements of the PDF: the narrowest bar in the barcode is
>>> about 0.29 mm (0.029 cm), which is about 2.3  pixels at 200 dpi and 3.42
>>> pixels at 300 dpi.I can imagine that this might result in pixel sometime
>>> to become black, and sometime to become white, if barcode is not layed
>>> out exactly on the margin of a pixel.
>>>
>>> Is there any way I can make this barcode look like it should be, by
>>> adjusting the dithering?
>>>
>>> Should I consider to parse the pdf file into text and image objects and
>>> feed these to the printer?
>>>
>>> Kind Regards,
>>>
>>> Johan Henselmans
>>
>> My suggestion is to replace the pstocupsraster filter by the latest
>> gstoraster filter (see the links on the CUPS web site for details) and
>> then add
>> -c true setstrokeadjust
>> to the array of Ghostscript options (see the documentation and look into
>> the Perl script.
>>
>> Helge
>>
> 
> Dear Helge,
> 
> I looked into the documentation (the gstoraster.pdf file) and the perl
> script.
> 
> I do not understand where I would add the "-c true setstrokeadjust".
> Where would I add this?
> 
> Also I do not understand why this filter would solve my problem. As far
> as I understand from the documentation, gstoraster fixes some
> pagerotation transformation.
> 
> Care to elaborate?
> 
> 

Well, the Ghostscrip options array is about line Nr. 335. The structure 
reads

@gsopts = (
        "$gs",
        "-q",
        "-dDELAYBIND",
        "-dNOPAUSE",
        "-dBATCH",
        "-dNOMEDIAATTRS",
        "-sPPD_LANDSCAPE=$landscape",           # initial value from PPD
        "-sDEVICE=cups",
        '-sstdout=%stderr',
        '-sOutputFile=%stdout',
        );

Insert the "-c true strokeadjust" anywhere in this array. You need to 
bracket it whith quotes or double quotes and append a komma to it (after the 
closeing quote,

As I cannot guarantee that this will solve your problen, but I think it is 
worh a try.

Helge







More information about the cups-devel mailing list