我使用库IText-2.1.3生成条形码128。这是我使用的代码:
private void createbarcode(string koddokumentu,string idsadowka,string projekt)throws ioexception,documentexception
{
file barcodepdf=新文件(pathtopdf);
files.deleteifexists(barcodepdf.topath());
document document=new document();
矩形大小=新矩形(151,60);
document.setmargins(5,1,-6,0);
document.setpagesize(大小);
fileoutputstream fos=新的fileoutputstream(pathtopdf);
pdfwriter writer=pdfwriter.getInstance(文档,fos);
document.open();
pdfContentByte cb=writer.getDirectContent();
barcode128=新的barcode128();
条码128.设定条码高度(40);
条形码128.setx(1.04f);
barcode128.setcode(“vl”+koddokumentu.touppercase());
条形码128.setcodetype(barcode.code128);
image code128image=barcode128.createImageWithBarcode(cb,空,空);
字体代码=新字体(fontfamily.times_roman,8,font.normal,basecolor.black);
段落p=新段落(“id:+idsadowka+”,项目:“+projekt.substring(0,2),代码);
文件添加(P);
document.add(code128图像);
document.close();
fos.close();
}
我希望尽可能小的实现h(查看图像),最好是h=0.01因为我想为id:xxxxx,projkt:xx保存更多的位置,以使它更大,更容易被人类读取。
首先(底部条码)我使用了8号字体,然后(上部条码)我试图将字体大小更改为10,但当我这样做时,它his bigger than previous.我知道字体大小与上面的条码和文本之间的间隙有关,但是否可以使用更大的字体大小,并将这个间隙设置得非常小?
.
我想实现小的目标h(看一下图片)如果可能的话,最好是h=0.01因为我想为ID: xxxxx, Projekt: xx使之更大,更容易被人阅读。
首先(底部的条形码)我使用了8号字体,然后(上部的条形码)我试图将字体大小改为10号,但当我这样做的时候H大于上一个。我知道字体大小与上面的条码和文本之间的间隙有关,但是否可以使用更大的字体大小,并将这个间隙设置得非常小?
