Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
This documentation explains how to customize the appearance of barcodes using the Aspose.BarCode Cloud SDK for Go. It provides details on the available methods, customization options, and examples of usage.
When generating a barcode, you can customize various aspects of its appearance using the properties of the request classes.
Key Properties:
QR, Aztec, Pdf417, Code39, etc).Png, Jpeg, Svg).AliceBlue or #FF000000).Below, Above, None).Pixel, Inch, Millimeter).In addition to the common appearance settings above, the API exposes advanced parameters that apply only to specific barcode types. They are ignored when a different barcode type is generated.
Auto, Extended, Binary, ECI).LevelL, LevelM, LevelQ, LevelH).Auto, Version01–Version40). Auto selects the smallest version that fits the data.UTF8, ISO_8859_1).0 to 1.Auto, M1–M4). Used when the barcode type is MicroQR.Auto, R7x43–R17x139). Used when the barcode type is RectMicroQR.Auto, CodeA, CodeB, CodeAB, CodeC, CodeAC, CodeBC).Auto, Binary, ECI, Extended).Level0–Level8).1–30, or 0 for auto).3–90, or 0 for automatic).2–5 for MicroPDF417; 3–5 for PDF417 and MacroPDF417).None, Macro05, Macro06).package main
import (
"context"
"fmt"
"os"
"path/filepath"
"github.com/antihax/optional"
"github.com/aspose-barcode-cloud/aspose-barcode-cloud-go/v4/barcode"
"github.com/aspose-barcode-cloud/aspose-barcode-cloud-go/v4/barcode/jwt"
)
func makeConfiguration() (*barcode.APIClient, context.Context, error) {
jwtToken := os.Getenv("TEST_JWT_ACCESS_TOKEN")
if jwtToken != "" {
config := barcode.NewConfiguration()
config.AddDefaultHeader("Authorization", "Bearer "+jwtToken)
client := barcode.NewAPIClient(config)
authCtx := context.Background()
return client, authCtx, nil
}
jwtConf := jwt.NewConfig(
"Client Id from https://dashboard.aspose.cloud/applications",
"Client Secret from https://dashboard.aspose.cloud/applications",
)
authCtx := context.WithValue(context.Background(),
barcode.ContextJWT,
jwtConf.TokenSource(context.Background()))
client := barcode.NewAPIClient(barcode.NewConfiguration())
return client, authCtx, nil
}
func Generate(client *barcode.APIClient, authCtx context.Context) error {
fileName, err := filepath.Abs(filepath.Join("testdata", "qr.png"))
opts := &barcode.GenerateAPIGenerateOpts{
BarcodeImageParams: optional.NewInterface(barcode.BarcodeImageParams{
ImageFormat: barcode.BarcodeImageFormatPng,
ForegroundColor: "Black",
BackgroundColor: "White",
TextLocation: barcode.CodeLocationBelow,
ImageHeight: 200,
ImageWidth: 200,
Resolution: 300,
}),
QrParams: optional.NewInterface(barcode.QrParams{
QrEncodeMode: barcode.QREncodeModeAuto,
QrErrorLevel: barcode.QRErrorLevelLevelM,
QrVersion: barcode.QRVersionAuto,
QrAspectRatio: 1.0,
}),
}
fileBytes, _, err := client.GenerateAPI.Generate(authCtx, barcode.EncodeBarcodeTypeQR, "Aspose.BarCode.Cloud", opts)
if err != nil {
return fmt.Errorf("error generating barcode: %v", err)
}
err = os.WriteFile(fileName, fileBytes, 0644)
if err != nil {
return fmt.Errorf("error saving barcode to file: %v", err)
}
fmt.Printf("File '%s' generated.\n", fileName)
return nil
}
func main() {
client, authCtx, err := makeConfiguration()
if err != nil {
fmt.Printf("Error setting up configuration: %v\n", err)
return
}
err = Generate(client, authCtx)
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
}
Result Image is: 
package main
import (
"context"
"fmt"
"os"
"path/filepath"
"github.com/aspose-barcode-cloud/aspose-barcode-cloud-go/v4/barcode"
"github.com/aspose-barcode-cloud/aspose-barcode-cloud-go/v4/barcode/jwt"
)
func makeConfiguration() (*barcode.APIClient, context.Context, error) {
jwtToken := os.Getenv("TEST_JWT_ACCESS_TOKEN")
if jwtToken != "" {
config := barcode.NewConfiguration()
config.AddDefaultHeader("Authorization", "Bearer "+jwtToken)
client := barcode.NewAPIClient(config)
authCtx := context.Background()
return client, authCtx, nil
}
jwtConf := jwt.NewConfig(
"Client Id from https://dashboard.aspose.cloud/applications",
"Client Secret from https://dashboard.aspose.cloud/applications",
)
authCtx := context.WithValue(context.Background(),
barcode.ContextJWT,
jwtConf.TokenSource(context.Background()))
client := barcode.NewAPIClient(barcode.NewConfiguration())
return client, authCtx, nil
}
func main() {
client, authCtx, err := makeConfiguration()
if err != nil {
fmt.Printf("Error setting up configuration: %v\n", err)
return
}
fileName, err := filepath.Abs(filepath.Join("testdata", "QrCustom.jpeg"))
imageParams := barcode.BarcodeImageParams{
ForegroundColor: "#FF0000",
BackgroundColor: "#FFFF00",
ImageFormat: barcode.BarcodeImageFormatJpeg,
RotationAngle: 90,
}
encodeData := barcode.EncodeData{
Data: "Aspose",
DataType: barcode.EncodeDataTypeStringData,
}
generateParams := barcode.GenerateParams{
BarcodeType: barcode.EncodeBarcodeTypeQR,
EncodeData: encodeData,
BarcodeImageParams: imageParams,
QrParams: barcode.QrParams{
QrEncodeMode: barcode.QREncodeModeAuto,
QrErrorLevel: barcode.QRErrorLevelLevelM,
QrVersion: barcode.QRVersionAuto,
QrAspectRatio: 0.75,
},
}
fileBytes, _, err := client.GenerateAPI.GenerateBody(authCtx, generateParams)
if err != nil {
fmt.Printf("Error generating barcode: %v\n", err)
return
}
err = os.WriteFile(fileName, fileBytes, 0644)
if err != nil {
fmt.Printf("Error saving barcode to file: %v\n", err)
return
}
fmt.Printf("File '%s' generated.\n", fileName)
}
Result Image is: 
package main
import (
"context"
"fmt"
"os"
"path/filepath"
"github.com/antihax/optional"
"github.com/aspose-barcode-cloud/aspose-barcode-cloud-go/v4/barcode"
"github.com/aspose-barcode-cloud/aspose-barcode-cloud-go/v4/barcode/jwt"
)
func makeConfiguration() (*barcode.APIClient, context.Context, error) {
jwtToken := os.Getenv("TEST_JWT_ACCESS_TOKEN")
if jwtToken != "" {
config := barcode.NewConfiguration()
config.AddDefaultHeader("Authorization", "Bearer "+jwtToken)
client := barcode.NewAPIClient(config)
authCtx := context.Background()
return client, authCtx, nil
}
jwtConf := jwt.NewConfig(
"Client Id from https://dashboard.aspose.cloud/applications",
"Client Secret from https://dashboard.aspose.cloud/applications",
)
authCtx := context.WithValue(context.Background(),
barcode.ContextJWT,
jwtConf.TokenSource(context.Background()))
client := barcode.NewAPIClient(barcode.NewConfiguration())
return client, authCtx, nil
}
func main() {
client, authCtx, err := makeConfiguration()
if err != nil {
fmt.Printf("Error setting up configuration: %v\n", err)
return
}
fileName, err := filepath.Abs(filepath.Join("testdata", "Pdf417.svg"))
fileBytes, _, err := client.GenerateAPI.GenerateMultipart(authCtx, barcode.EncodeBarcodeTypePdf417, "Aspose.BarCode.Cloud", &barcode.GenerateAPIGenerateMultipartOpts{
BarcodeImageParams: optional.NewInterface(barcode.BarcodeImageParams{
TextLocation: barcode.CodeLocationAbove,
ImageFormat: barcode.BarcodeImageFormatSvg,
}),
Pdf417Params: optional.NewInterface(barcode.Pdf417Params{
Pdf417EncodeMode: barcode.Pdf417EncodeModeAuto,
Pdf417ErrorLevel: barcode.Pdf417ErrorLevelLevel2,
Pdf417AspectRatio: 2.0,
}),
})
if err != nil {
fmt.Printf("Error generating barcode: %v\n", err)
return
}
err = os.WriteFile(fileName, fileBytes, 0644)
if err != nil {
fmt.Printf("Error saving barcode to file: %v\n", err)
return
}
fmt.Printf("File '%s' generated.\n", fileName)
}
Result Image is:
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.