samar da barcode

Ƙirƙirar Barcode a cikin Launuka na Musamman tare da API .NET REST.

A cikin duniyar da barcodes suke a ko’ina kuma suna taka muhimmiyar rawa a aikace-aikace daban-daban, buƙatar canza kamanninsu, musamman launukansu, ba ta taɓa fitowa fili ba. Barcodes ba kawai masu amfani ba ne; sun rikide zuwa wakilcin gani na alama ko samfur. Don haka, canza launukan barcode ba wani zaɓi bane, amma larura ce. Don haka, ko game da kiyaye daidaiton alama, haɓaka ƙwarewar mai amfani, ko haɗawa kawai tare da ƙira, ikon keɓance launukan barcode abu ne mai mahimmanci.

Wannan labarin yana bayyana mahimmanci da fa’idodi masu yawa na wannan keɓancewa ta amfani da .NET REST API.

NET Cloud SDK don Ƙimar Barcode

Buɗe yuwuwar daidaita lambar lambar ba ta da wahala tare da Aspose.BarCode Cloud SDK don NET. Wannan kayan aiki mai ƙarfi yana ba ku damar haɗa ikon keɓance launuka na barcode a cikin aikace-aikacenku. Tare da wannan SDK, gyare-gyaren ya wuce launuka, kuma kuna iya keɓance bangarori daban-daban na lambar lambobin, gami da alamar su, girmansu, ƙuduri, da ƙari. Hakanan, da fatan za a lura cewa SDK yana tabbatar da daidaitaccen ƙirƙirar lambar lambar sirri, yana bin ƙa’idodin masana’antu.

Yanzu, don amfani da SDK, da farko muna buƙatar bincika ‘Aspose.BarCode-Cloud’ a cikin manajan fakitin NuGet kuma danna maɓallin ‘Ƙara Kunshin’. Na biyu, muna buƙatar ziyartar dashboard ɗin girgije, don samun keɓaɓɓen shaidar abokin ciniki.

Keɓance Barcode a cikin C# .NET

Yawancin lokaci, hotunan barcode suna da tsarin launi na baki da fari. Koyaya, wannan API ɗin REST yana ba da damar daidaita launukan RGB na tsarin don abubuwan maɓalli na maɓalli, gami da:

  • Bars
  • Fage
  • Iyakoki
  • Alamar rubutu
  • Bayanan sama da kasa

Saita Launin Sanduna

Domin saita launi don Bars, muna buƙatar saita ƙimar kayan ‘BarColor’ na aji na GetBarcodeGenerateRequest. Tsohuwar ƙimar Black.

// Don ƙarin samfurori, da fatan za a ziyarci https://github.com/aspose-barcode-cloud/aspose-barcode-cloud-dotnet
// Samu bayanan abokin ciniki daga https://dashboard.aspose.cloud/
string clientSecret = "c71cfe618cc6c0944f8f96bdef9813ac";
string clientID = "163c02a1-fcaa-4f79-be54-33012487e783";

// Misali na tsari inda muka ƙididdige bayanan abokin ciniki don amfani
Configuration configuration = new Configuration()
{
    ClientId = clientID,
    ClientSecret = clientSecret
};

// ƙirƙirar misali na BarCodeAPI
BarcodeApi barcodeApi = new BarcodeApi(configuration);

// saka nau'in da abun ciki don Barcode
string type = "Code39Standard";
string text = "Hello World...!";

// Barcode tare da rubutu azaman tsakiyar layi kuma a ƙasan lambar barcode
var request = new GetBarcodeGenerateRequest(type, text)
{
    TextAlignment = "center",
    TextLocation = "Below",
    format = "JPG",
    // bayanin launi don Bars a cikin hoton Barcode
    BarColor = "Gold"
};

// haifar da Barcode kuma ajiye fitarwa zuwa ma'ajiyar gida
using (Stream response = barcodeApi.GetBarcodeGenerate(request))
{
    // tabbatar da tsawon amsa ya fi 0
    Assert.IsTrue(response.Length > 0);
    
    // ajiye hoton barcode akan tuƙi na gida
    using (FileStream stream = File.Create("BarcodeGenerated.jpg"))
    {
        response.CopyTo(stream);
    }
}
barcode bar launi

Duban launi na al’ada don Barcode.

Kalar Baya

Za a iya canza launin bangon lamba ta amfani da kayan ‘BackColor’ a cikin aji na GetBarcodeGenerateRequest. Tsohuwar ƙimar launi ta baya ita ce Fari.

// Don ƙarin samfurori, da fatan za a ziyarci https://github.com/aspose-barcode-cloud/aspose-barcode-cloud-dotnet
// Samu bayanan abokin ciniki daga https://dashboard.aspose.cloud/
string clientSecret = "c71cfe618cc6c0944f8f96bdef9813ac";
string clientID = "163c02a1-fcaa-4f79-be54-33012487e783";

// Misali na tsari inda muka ƙididdige bayanan abokin ciniki don amfani
Configuration configuration = new Configuration()
{
    ClientId = clientID,
    ClientSecret = clientSecret
};

// ƙirƙirar misali na BarCodeAPI
BarcodeApi barcodeApi = new BarcodeApi(configuration);

// saka nau'in da abun ciki don Barcode
string type = "Code39Standard";
string text = "Hello World...!";

// Barcode tare da rubutu azaman tsakiyar layi kuma a ƙasan lambar barcode
var request = new GetBarcodeGenerateRequest(type, text)
{
    TextAlignment = "center",
    TextLocation = "Below",
    // fitarwa format ga barcode image
    format = "JPG",
    BackColor =  "Yellow"
};

// haifar da Barcode kuma ajiye fitarwa zuwa ma'ajiyar gida
using (Stream response = barcodeApi.GetBarcodeGenerate(request))
{
    // tabbatar da tsawon amsa ya fi 0
    Assert.IsTrue(response.Length > 0);
    
    // ajiye hoton barcode akan tuƙi na gida
    using (FileStream stream = File.Create("BarcodeGenerated.jpg"))
    {
        response.CopyTo(stream);
    }
}
lambar bangon waya

Preview na Barcode mai launi na bango.

Kan iyaka da Launi

Hakanan muna da sassauci don saita salon iyaka na al’ada da kuma bayanan launi na al’ada don kan iyaka.

// Don ƙarin samfurori, da fatan za a ziyarci https://github.com/aspose-barcode-cloud/aspose-barcode-cloud-dotnet
// Samu bayanan abokin ciniki daga https://dashboard.aspose.cloud/
string clientSecret = "c71cfe618cc6c0944f8f96bdef9813ac";
string clientID = "163c02a1-fcaa-4f79-be54-33012487e783";

// Misali na tsari inda muka ƙididdige bayanan abokin ciniki don amfani
Configuration configuration = new Configuration()
{
    ClientId = clientID,
    ClientSecret = clientSecret
};

// ƙirƙirar misali na BarCodeAPI
BarcodeApi barcodeApi = new BarcodeApi(configuration);

// saka nau'in da abun ciki don Barcode
string type = "Code39Standard";
string text = "Hello World...!";

// Barcode tare da rubutu azaman tsakiyar layi kuma a ƙasan lambar barcode
var request = new GetBarcodeGenerateRequest(type, text)
{
    TextAlignment = "center",
    TextLocation = "Below",
    format = "PNG",
    BorderVisible = true,
    BorderWidth = 5,
    BorderColor = "Navy",
    
    // bayanin tsarin iyaka
    BorderDashStyle  = "DashDotDot"
};

// haifar da Barcode kuma ajiye fitarwa zuwa ma'ajiyar gida
using (Stream response = barcodeApi.GetBarcodeGenerate(request))
{
    // tabbatar da tsawon amsa ya fi 0
    Assert.IsTrue(response.Length > 0);
    
    // ajiye hoton barcode akan tuƙi na gida
    using (FileStream stream = File.Create("BarcodeGenerated.jpg"))
    {
        response.CopyTo(stream);
    }
}
  • Matsaloli masu yiwuwa don salon kan iyaka sune Solid, Dash, Dot, DashDot, DashDotDot.
iyakar barcode

Duban iyakar al’ada don Barcode.

Tsara Label Rubutun Barcode

Muna kuma da ikon sarrafa launi da sanya alamar barcode. A cikin snippet ɗin lambar da ke ƙasa, mun saita alamar barcode/matsayin rubutu azaman Sama da Dama, tare da bayanin launi azaman Zinariya. Don ingantacciyar gabatarwa, mun kuma saita launin bango azaman Navy.

// Don ƙarin samfurori, da fatan za a ziyarci https://github.com/aspose-barcode-cloud/aspose-barcode-cloud-dotnet
// Samu bayanan abokin ciniki daga https://dashboard.aspose.cloud/
string clientSecret = "c71cfe618cc6c0944f8f96bdef9813ac";
string clientID = "163c02a1-fcaa-4f79-be54-33012487e783";

// Misali na tsari inda muka ƙididdige bayanan abokin ciniki don amfani
Configuration configuration = new Configuration()
{
    ClientId = clientID,
    ClientSecret = clientSecret
};

// ƙirƙirar misali na BarCodeAPI
BarcodeApi barcodeApi = new BarcodeApi(configuration);

// saka nau'in da abun ciki don Barcode
string type = "Code39Standard";
string text = "Hello World...!";

// Barcode tare da rubutu azaman tsakiyar layi kuma a ƙasan lambar barcode
var request = new GetBarcodeGenerateRequest(type, text)
{
    TextAlignment = "Right",
    TextLocation = "Above",
    TextColor = "Gold",
    format = "PNG",
    BackColor = "Navy",
    BarColor = "Yellow"
};

// haifar da Barcode kuma ajiye fitarwa zuwa ma'ajiyar gida
using (Stream response = barcodeApi.GetBarcodeGenerate(request))
{
    // tabbatar da tsawon amsa ya fi 0
    Assert.IsTrue(response.Length > 0);
    
    // ajiye hoton barcode akan tuƙi na gida
    using (FileStream stream = File.Create("TextColor.png"))
    {
        response.CopyTo(stream);
    }
}
saita launi rubutu na barcode

Preview na Barcode tare da launi rubutu na al’ada.

Ƙirƙirar Barcode na Musamman ta amfani da Umarnin CURL

Customizing Barcode launuka da leveraging da damar na Aspose.Barcode Cloud ta amfani da cURL dokokin ne a sumul da ingantaccen tsari. Tare da wannan API, zaku iya sauƙin canza launukan barcode don dacewa da takamaiman buƙatunku da abubuwan ƙira. Bugu da ƙari, ta yin amfani da umarnin cURL, kuna iya ƙirƙira da tsara lambobin sirri ba tare da wahala ba ta hanyar daidaita sigogi daban-daban kamar alamar alama, girma, ƙuduri, da ƙari.

Don haka, mataki na farko shine aiwatar da umarni mai zuwa don samar da alamar shiga JWT:

curl -v "https://api.aspose.cloud/connect/token" \
 -X POST \
 -d "grant_type=client_credentials&client_id=163c02a1-fcaa-4f79-be54-33012487e783&client_secret=c71cfe618cc6c0944f8f96bdef9813ac" \
 -H "Content-Type: application/x-www-form-urlencoded" \
 -H "Accept: application/json"

Da zarar muna da alamar JWT, da fatan za a aiwatar da umarni mai zuwa don samar da lambar barcode mai ɗauke da launi na al’ada, launi na kan iyaka, ƙirar iyaka, launi daban-daban da juyawa a kusurwar 45 Degree.

curl -v "https://api.aspose.cloud/v3.0/barcode/generate?Type=Code93Standard&Text=Hello%20World...%20!&TextLocation=Below&TextAlignment=Center&TextColor=Gold&FontSizeMode=Auto&Resolution=100&RotationAngle=-45&BarColor=Navy&BorderColor=Maroon&BorderWidth=5&BorderDashStyle=DashDot&BorderVisible=true&FilledBars=true&UseAntiAlias=true&format=PNG" \
-X GET \
-H "accept: image/png" \
-H "authorization: Bearer {accessToken}"
-o "resultantBarcode.png"

Sauya ‘accessToken’ tare da alamar samun damar JWT da aka samar a sama.

bar code tsara

Preview na musamman Barcode.

Kammalawa

A ƙarshe, da ikon siffanta barcode launuka da kuma amfani da m capabilities na Aspose.Barcode, ko ta hanyar sadaukar .NET REST API ko ta hanyar cURL umarni tare da Aspose.Barcode Cloud, tsaye a matsayin shaida ga ci gaba wuri mai faɗi na Barcode hadewa da kuma management. . API ɗin sadaukarwar .NET REST yana ba da ƙwarewa mara kyau da abokantaka mai haɓakawa, yana ba da ɗimbin zaɓuɓɓukan gyare-gyare fiye da launuka, tabbatar da madaidaicin iko akan fannoni daban-daban na ƙirar lambar lamba. A gefe guda, haɗin Aspose.Barcode Cloud ta hanyar umarnin cURL yana ba da hanya mai sauƙi da sauƙi, yana ba da damar jama’a da yawa da kuma ƙarfafa ingantaccen gyare-gyaren lambar sirri.

Hanyoyin haɗi masu amfani

Labarai masu alaka

Muna ba da shawarar ziyartar shafukan yanar gizo masu zuwa: