Print Page | Close Window

GetBarcodeWidth Return Value

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=2738
Printed Date: 31 Jan 26 at 6:43AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: GetBarcodeWidth Return Value
Posted By: btmi
Subject: GetBarcodeWidth Return Value
Date Posted: 23 Sep 13 at 11:47PM
It appears that the return value of GetBarcodeWidth does NOT respect the current SetMeasurementUnits setting, although the Nominal Width value appears to work.

Is this correct?



Replies:
Posted By: Gio
Date Posted: 01 Oct 13 at 9:10AM
I have the same problem and cannot understand the return valued that is much bigger than the expected one...
I have many doubts also concerning the "nominal width": can somebody explain me its meaning/usage?
 
Thank you,
Giorgio


Posted By: btmi
Date Posted: 02 Oct 13 at 12:11AM
From my experience the return value is in points (1/72 of an inch) and so you may need to apply some calculations to convert it into your preferred  unit of measurement.

For the NominalWidth I use 1mm and that seems to work with with all of the devices I use to provide a width that will work with the DrawBarcode routine.


Posted By: Gio
Date Posted: 02 Oct 13 at 9:17AM
Hi btmi and thank you.
It doesn't seem to be measured in points because, if applied as width in the DrawBarcode, the returned value should "oversize" the barcode even if "points" are the current unit of measure...
But independently by the correct value: which is the meaning of NominalWidth parameter?
 
Giorgio


Posted By: AndrewC
Date Posted: 02 Oct 13 at 1:29PM
Hello,

When you call DrawBarcode you specify a left, top, width and height parameter.  When the barcode is drawn it is scaled to squeeze or stretch all of the bars into the required width.  After it is drawn it is no longer a barcode but just a sequence of  lines.  You cannot obtain the width.

For variable length barcode is it handy to know the number or thin bars the barcode is in width so that you can calculate the width value.

You may want to try the following code to see visually what I mean.  If you use GetBarcodeWidth to scale the Width parameter for the DrawBarcode funvtion then the thinnest bar in each of the top 4 barcode is the same width.  The last 4 barcodes are scaled.

            double y = 50;
            QP.SetOrigin(1);

            QP.DrawBarcode(20, y, QP.GetBarcodeWidth(1, "1", 1), 30, "1", 1, 0);
            y += 50;

            QP.DrawBarcode(20, y, QP.GetBarcodeWidth(1, "12", 1), 30, "12", 1, 0);
            y += 50;

            QP.DrawBarcode(20, y, QP.GetBarcodeWidth(1, "123", 1), 30, "123", 1, 0);
            y += 50;

            QP.DrawBarcode(20, y, QP.GetBarcodeWidth(1, "1234", 1), 30, "1234", 1, 0);
            y += 50;

            QP.DrawBarcode(20, y, 50, 30, "1", 1, 0);
            y += 50;

            QP.DrawBarcode(20, y, 50, 30, "12", 1, 0);
            y += 50;

            QP.DrawBarcode(20, y, 50, 30, "123", 1, 0);
            y += 50;

            QP.DrawBarcode(20, y, 50, 30, "1234", 1, 0);
            y += 50;

            QP.SaveToFile("out.pdf");

Andrew.





Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk