Barcode Generation

Hi,

The Barcode generation for the below format is failing.
• UPC-A
• UPC-A GS1 Code 128 Coupon
• UPC-A GS1 Databar Coupon
• Aurstralia Poste Parcel.

We explored in total 66 Barcode formats, in which the above 4 formats are failing. Please let me know if something can be done to fix the issue.

Code Snippet:
package com.asset;

import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;

import com.aspose.barcode.License;
import com.aspose.pdf.*;

import com.aspose.barcode.generation.BarCodeImageFormat;
import com.aspose.barcode.generation.BarcodeGenerator;
import com.aspose.barcode.generation.BaseEncodeType;
import com.aspose.barcode.generation.EncodeTypes;
import com.aspose.pdf.Document;
import com.aspose.pdf.SvgLoadOptions;
import com.aspose.pdf.SvgSaveOptions;

public class BarcodeGeneration {

Map<String, BaseEncodeType> encodeTypeMap = new HashMap<String, BaseEncodeType>();
void loadEncodeTypes()
{
	//encodeTypeMap.put("", EncodeTypes.AUSTRALIA_POST);
	encodeTypeMap.put( "AztecCode",EncodeTypes.AZTEC );
	encodeTypeMap.put( "CodablockF",EncodeTypes.CODABLOCK_F );
	encodeTypeMap.put( "Code16K", EncodeTypes.CODE_16_K );
	encodeTypeMap.put( "DataMatrix", EncodeTypes.DATA_MATRIX );
	encodeTypeMap.put( "DotCode",EncodeTypes.DOT_CODE );
	encodeTypeMap.put( "GS1DataMatrix",EncodeTypes.GS_1_DATA_MATRIX );
	encodeTypeMap.put( "GS1QRCode",EncodeTypes.GS_1_QR );
	encodeTypeMap.put( "MaxiCode",EncodeTypes.MAXI_CODE );
	encodeTypeMap.put( "MicroPDF417",EncodeTypes.MICRO_PDF_417 );
	encodeTypeMap.put( "PDF417",EncodeTypes.PDF_417 );
	encodeTypeMap.put( "QRCode", EncodeTypes.QR );
	encodeTypeMap.put( "Codabar",EncodeTypes.CODABAR );
	encodeTypeMap.put( "Code128", EncodeTypes.CODE_128 );
	encodeTypeMap.put( "Code39Extended", EncodeTypes.CODE_39_EXTENDED );
	encodeTypeMap.put( "Code39",EncodeTypes.CODE_39_STANDARD );
	encodeTypeMap.put( "Code93Extended",EncodeTypes.CODE_93_EXTENDED );
	encodeTypeMap.put( "Code93",EncodeTypes.CODE_93_STANDARD );
	encodeTypeMap.put( "GS1128",EncodeTypes.GS_1_CODE_128 );
	//encodeTypeMap.put( "ItalianPharmacode",EncodeTypes.ItalianPost25 );//in the list, but not supported in Aspose
	encodeTypeMap.put( "PZN",EncodeTypes.PZN );
	encodeTypeMap.put( "Planet",EncodeTypes.PLANET );
	//encodeTypeMap.put( "RoyalMail4StateCustomerCode",EncodeTypes.r );//in the list, but not supported in Aspose
	encodeTypeMap.put( "VIN",EncodeTypes.VIN );
	encodeTypeMap.put( "Code11", EncodeTypes.CODE_11 );
	encodeTypeMap.put( "Datalogic2of5",EncodeTypes.DATA_LOGIC_2_OF_5 );
	encodeTypeMap.put( "DeutschePostIdentcode",EncodeTypes.DEUTSCHE_POST_IDENTCODE );
	encodeTypeMap.put( "DeutschePostLeitcode",EncodeTypes.DEUTSCHE_POST_LEITCODE );
	encodeTypeMap.put( "EAN13",EncodeTypes.EAN_13 );
	encodeTypeMap.put( "EAN14",EncodeTypes.EAN_14 );
	encodeTypeMap.put( "EAN8",EncodeTypes.EAN_8 );
	/*encodeTypeMap.put( "GS1DataBarExpandedStacked",EncodeTypes.G );
	encodeTypeMap.put( "GS1DataBarExpanded",EncodeTypes.DatabarExpanded );
	encodeTypeMap.put( "GS1DataBarOmnidirectional",EncodeTypes.DatabarOmniDirectional );
	encodeTypeMap.put( "GS1DataBarStackedOmnidirectional",EncodeTypes.DatabarStackedOmniDirectional );
	encodeTypeMap.put( "GS1DataBarStacked",EncodeTypes.DatabarStacked );
	encodeTypeMap.put( "GS1DataBarTruncated",EncodeTypes.DatabarTruncated );*/
	encodeTypeMap.put( "IATA2of5",EncodeTypes.IATA_2_OF_5 );
	encodeTypeMap.put( "ISBN",EncodeTypes.ISBN );
	encodeTypeMap.put( "ISMN",EncodeTypes.ISMN );
	encodeTypeMap.put( "ISSN",EncodeTypes.ISSN );
	encodeTypeMap.put( "ITF14",EncodeTypes.ITF_14 );
	encodeTypeMap.put( "ITF6",EncodeTypes.ITF_6 );
	encodeTypeMap.put( "Interleaved2of5",EncodeTypes.INTERLEAVED_2_OF_5 );
	encodeTypeMap.put( "Matrix2of5",EncodeTypes.MATRIX_2_OF_5 );
	encodeTypeMap.put( "MsiPlessey",EncodeTypes.MSI );
	encodeTypeMap.put( "OPC",EncodeTypes.OPC );
	encodeTypeMap.put( "Pharmacode",EncodeTypes.PHARMACODE );
	encodeTypeMap.put( "SSCC18",EncodeTypes.SSCC_18 );
	encodeTypeMap.put( "UPCA",EncodeTypes.UPCA );
	encodeTypeMap.put( "UPCE",EncodeTypes.UPCE );
	encodeTypeMap.put( "UpcaGs1Code128Coupon",EncodeTypes.UPCA_GS_1_CODE_128_COUPON );
	encodeTypeMap.put( "UpcaGs1DatabarCoupon",EncodeTypes.UPCA_GS_1_DATABAR_COUPON );
	encodeTypeMap.put( "UspsPlanet", EncodeTypes.PLANET );
	//encodeTypeMap.put( "UspsPostnet",EncodeTypes.U );Not supported in Jave
	encodeTypeMap.put( "AurstraliaPosteParcel",EncodeTypes.AUSTRALIAN_POSTE_PARCEL );
	//encodeTypeMap.put( "BarCodeSupplement",EncodeTypes. );//not in Prasanna's list
	//encodeTypeMap.put( "BooklandEAN",EncodeTypes. );//not in Prasanna's list
	encodeTypeMap.put( "GS1CodablockF",EncodeTypes.GS_1_CODABLOCK_F );
	encodeTypeMap.put( "ItalianPost25",EncodeTypes.ITALIAN_POST_25 );
	//encodeTypeMap.put( "KIXcode",EncodeTypes.K );//not in Prasanna's list
	encodeTypeMap.put( "PatchCode",EncodeTypes.PATCH_CODE );
	encodeTypeMap.put( "Postnet",EncodeTypes.POSTNET );
	encodeTypeMap.put( "SSCC18", EncodeTypes.SSCC_18 );
	encodeTypeMap.put( "SingaporePost",EncodeTypes.SINGAPORE_POST );
	encodeTypeMap.put( "Standard2of5",EncodeTypes.STANDARD_2_OF_5 );
	encodeTypeMap.put( "SwissPostParcel",EncodeTypes.SWISS_POST_PARCEL );
	//encodeTypeMap.put( "UspsOneCode",EncodeTypes.u );Not supported in Java
	
}

public  void generateBarcode(String encodeFormat, String code,String pdfFile , String svgFile) throws Exception
{
	// TODO Auto-generated method stub

		
	try {
		
		com.aspose.pdf.License pdfLicense = new com.aspose.pdf.License();
		 pdfLicense.setLicense("Aspose.Total.Java.lic");
		 
		 Object barcodeLicense = new com.aspose.barcode.License();
		 ((License) barcodeLicense).setLicense("Aspose.Total.Java.lic");
		loadEncodeTypes();
		BaseEncodeType type= null;
		type = encodeTypeMap.get(encodeFormat);
		if (type == null)
			type = EncodeTypes.EAN_13;

	BarcodeGenerator generator = new BarcodeGenerator(type,code);
	
	
	generator.save(svgFile, BarCodeImageFormat.SVG);
			
	SvgLoadOptions options=new SvgLoadOptions();
	SvgSaveOptions options1 = new  SvgSaveOptions();
	Document pdf=new Document(svgFile,options);
			//(svgFile,options);
	pdf.save(pdfFile);
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	
	// ExEnd: GenerateBarcodeWithoutRestrictedBarcodeSize

@jancirani.c,

I reproduced the issue as you mentioned. I found Aspose.BarCode fails to generate barcodes for the following types:
• UPC-A
• UPC-A GS1 Code 128 Coupon
• UPC-A GS1 Databar Coupon
• Aurstralia Poste Parcel.

I got errors, something like:

Wrong format of Coupon input string. See symbology description, please.
Parameter is invalid
Barcode length is incorrect

This shows that the issue might be due to wrong input string format or its length, or else. Anyways, we need to investigate your issue in details.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): BARCODEJAVA-1640

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

UPC-A GS1 Code 128 Coupon

UPC-A

@jancirani.c,
to reproduce issue we should be aware about certain input data that lead to error. But based on error messages you just enter incorrect code for certain encode type. Please refer to the links mentioned above by @alexander.gavriluk.