翻譯|使用教程|編輯:胡濤|2023-03-30 10:04:58.627|閱讀 167 次
概述:在本文中,我們將學(xué)習(xí)如何生成 GS1-128 條形碼。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
Aspose.BarCode for .NET 是一個(gè)功能強(qiáng)大的API,可以從任意角度生成和識(shí)別多種圖像類型的一維和二維條形碼。開(kāi)發(fā)人員可以輕松添加條形碼生成和識(shí)別功能,以及在.NET應(yīng)用程序中將生成的條形碼導(dǎo)出為高質(zhì)量的圖像格式。
Aspose API支持流行文件格式處理,并允許將各類文檔導(dǎo)出或轉(zhuǎn)換為固定布局文件格式和最常用的圖像/多媒體格式。
條形碼是用于識(shí)別產(chǎn)品的圖形符號(hào)。在零售行業(yè),GS1-128 條碼無(wú)處不在。世界各地的許多公司都使用 GS1-128 標(biāo)準(zhǔn)交換數(shù)據(jù)。作為電子商務(wù)標(biāo)準(zhǔn),它使公司能夠提供有關(guān)其產(chǎn)品的準(zhǔn)確可靠的信息。在本文中,我們將學(xué)習(xí)如何生成 GS1-128 條形碼。完成上述步驟后,我們將擁有自己的Java GS1-128 條碼生成器。讓我們開(kāi)始吧。
我們將使用Aspose.BarCode for Java API 生成 GS1-128 條碼。它是用于條形碼生成和識(shí)別的強(qiáng)大、可靠且易于使用的 Java API。它支持范圍廣泛的一維和二維條碼類型。
請(qǐng)下載 API 的 JAR或在基于 Maven 的 Java 應(yīng)用程序中添加以下 pom.xml 配置。
<repository> <id>AsposeJavaAPI</id> <name>Aspose Java API</name> <url>//repository.aspose.com/repo/</url> </repository> <dependency> <groupId>com.aspose</groupId> <artifactId>aspose-barcode</artifactId> <version>22.10</version> </dependency>
我們可以按照以下步驟輕松生成 GS1-128 條形碼:
以下代碼示例顯示了如何在 Java 中生成 GS1-128 條形碼。
// This code example demonstrates how to generate a GS1-128 barcode. // Create an instane of the BarcodeGenerator class // Specify Encode type as GS1Code128 BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.GS_1_CODE_128); // Specify the code text generator.setCodeText("(01)12345678901231(21)ASPOSE(30)9876"); // Specify the X-dimension // the smallest width of the unit of BarCode bars or spaces generator.getParameters().getBarcode().getXDimension().setPixels(2); // Save the output generator.save("C:\\Files\\GS1Code128.jpg");
同樣,我們也可以按照前面提到的步驟生成一個(gè)條碼標(biāo)簽,在同一圖像中放置一個(gè)額外的 GS1-128 優(yōu)惠券條碼。但是,我們需要在第一步中將EncodeType設(shè)置為UPCA_GS_1_CODE_128_COUPON 。
以下代碼示例顯示如何在 Java 中生成 UPC-A GS1 代碼 128 優(yōu)惠券。
// This code example demonstrates how to generate a UPC-A GS1 Code 128 Coupon. // Create an instane of the BarcodeGenerator class // Specify Encode type as UpcaGs1Code128Coupon BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.UPCA_GS_1_CODE_128_COUPON); // Specify the code text generator.setCodeText("123456789012(8110)ASPOSE"); // Specify the X-dimension // the smallest width of the unit of BarCode bars or spaces generator.getParameters().getBarcode().getXDimension().setPixels(2); // Save the output generator.save("C:\\Files\\Gs1CouponUpcaCode128.jpg");
我們還可以按照前面提到的步驟自定義條形碼的外觀。但是,在最后一步保存圖像之前,我們需要指定其他屬性。
下面的代碼示例顯示了如何在 Java 中自定義 GS1 128 優(yōu)惠券的條形碼外觀。
// This code example demonstrates how to customize the barcode appearance of GS1 128 Coupon. // Create an instane of the BarcodeGenerator class // Specify Encode type as UpcaGs1Code128Coupon BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.UPCA_GS_1_CODE_128_COUPON); // Specify the code text generator.setCodeText("123456789012(8110)ASPOSE"); // Specify the X-dimension // the smallest width of the unit of BarCode bars or spaces generator.getParameters().getBarcode().getXDimension().setPixels(2); // Set coupon supplement space 50 pixels generator.getParameters().getBarcode().getCoupon().getSupplementSpace().setPixels(50); // Set Bar Height generator.getParameters().getBarcode().getBarHeight().setPixels(50); // Set Bar Color generator.getParameters().getBarcode().setBarColor(Color.RED); // Set Lable Color generator.getParameters().getBarcode().getCodeTextParameters().setColor(Color.BLUE); // Save the output generator.save("C:\\Files\\Gs1CouponAppearance.jpg");
以上便是如何在Java 中的 GS1-128 條碼生成器,希望能幫到您,除此之外,你有其他方面的需求,也歡迎和我們互動(dòng),或這下體驗(yàn)我們更多的產(chǎn)品~
歡迎下載|體驗(yàn)更多Aspose產(chǎn)品
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn