Free Support Forum -

How to canvert Aspose.Words.Fields.BarcodeParameters.BarcodeType to spose.BarCode.Generation.SymbologyEncodeType

I would like to know if there is a way to dynamically convert
Aspose.Words.Fields.BarcodeParameters.BarcodeType to spose.BarCode.Generation.SymbologyEncodeType
As we can see in the following documentation
we convert the parameters.BarcodeType to SymbologyEncodeType manually : switch (type)
case “QR”:
encodeType = EncodeTypes.QR;
case “CODE128”:
encodeType = EncodeTypes.Code128;…
Is it possible to do it more dynamically ? Because sometimes we can’t know in avance what is configurated in the doc template, and as there are 66 SymbologyEncodeType in the EncodeTypes class, if we want use all these types, there will be more than 66 cases in the switch (type). I don’t find a function to convert a string to SymbologyEncodeType.
Another question is : Is it possible to get a customer barcode image with displaybarcode field with any barcode type defined in Aspose.BarCode.Generation.SymbologyEncodeType ?
Thanks you in advance

Finally I found a solution to my question in my previous message by using
BaseEncodeType encodeTypeGetted = BaseEncodeType.Parse(parameters.BarcodeType);
BarcodeGenerator generator = new BarcodeGenerator(encodeTypeGetted);
In this way, we don’t need to convert the BarcodeParameters.BarcodeType manually to EncodeTypes
so no need switch(type), the code is simplified.



It looks like you have sorted it out now. In the event of further queries regarding Aspose.BarCode API, feel free to write us back, we will be happy to assist you soon.