翻譯|使用教程|編輯:胡濤|2023-03-30 10:04:58.627|閱讀 167 次
概述:在本文中,我們將學習如何生成 GS1-128 條形碼。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
Aspose.BarCode for .NET 是一個功能強大的API,可以從任意角度生成和識別多種圖像類型的一維和二維條形碼。開發人員可以輕松添加條形碼生成和識別功能,以及在.NET應用程序中將生成的條形碼導出為高質量的圖像格式。
Aspose API支持流行文件格式處理,并允許將各類文檔導出或轉換為固定布局文件格式和最常用的圖像/多媒體格式。
條形碼是用于識別產品的圖形符號。在零售行業,GS1-128 條碼無處不在。世界各地的許多公司都使用 GS1-128 標準交換數據。作為電子商務標準,它使公司能夠提供有關其產品的準確可靠的信息。在本文中,我們將學習如何生成 GS1-128 條形碼。完成上述步驟后,我們將擁有自己的Java GS1-128 條碼生成器。讓我們開始吧。
我們將使用Aspose.BarCode for Java API 生成 GS1-128 條碼。它是用于條形碼生成和識別的強大、可靠且易于使用的 Java API。它支持范圍廣泛的一維和二維條碼類型。
請下載 API 的 JAR或在基于 Maven 的 Java 應用程序中添加以下 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");
同樣,我們也可以按照前面提到的步驟生成一個條碼標簽,在同一圖像中放置一個額外的 GS1-128 優惠券條碼。但是,我們需要在第一步中將EncodeType設置為UPCA_GS_1_CODE_128_COUPON 。
以下代碼示例顯示如何在 Java 中生成 UPC-A GS1 代碼 128 優惠券。
// 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 優惠券的條形碼外觀。
// 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 條碼生成器,希望能幫到您,除此之外,你有其他方面的需求,也歡迎和我們互動,或這下體驗我們更多的產品~
歡迎下載|體驗更多Aspose產品
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn