bwip-js
bwip-js copied to clipboard
Width text height
Hi, ich found your lib :) and its awesome. If i understand correctly i can set the maxheight and width with widht and height and it generates the biggest barcode possible in this size. This is awesome! But I have some issues with text. It looks very strechy. Can i somehow make the text auto resize in the height? So it looks more normal?

I try to create a barcode with max 200mm width and max 100mm height and render it to a pdf.
To generate a barcode without text stretching, set the scale to achieve the desired width. Then adjust the height, For your example, you could start with scale=3 and height=15.
@metafloor so to get a perfect barcode i need to generate it twice? First to get the default width and hight of the image. As an example 50mm. If i need a 200 width barcode i device it with 50mm (200/50=4) so i get a scale of 4 and i need to generate it again? Or is it possible to get the size without generate it?
So for the complete ratio: ratio = Math.min(maxWidth / srcWidth, maxHeight / srcHeight)
I have a simple place in the pdf and here should be the barcode with the maximum size in the available space.
I found the method raw which gets some data. But can I pass the raw to the render function?
Are you only generating ISBN barcodes? Because they are fixed format. Or are you looking for a generic solution for different barcode types?
@metafloor I will not only use ISBNs but all sorts of things. Therefore, I am already looking for a general solution that works for all barcodes. There is always a fixed coordinate and width and height.
@metafloor i think there is only the double generation for this or? So it can be closed?
Sorry, lost track of this issue. Yes, you will need to double generate. It is the same as with using BWIPP in a postscript environment.
Sorry, lost track of this issue. Yes, you will need to double generate. It is the same as with using BWIPP in a postscript environment.
@metafloor no problem :) thanks for the answer I can use raw so it doesn't generate to much data. And run it again to generate the pdf image.