Hi.
We try to execute following api call to get a barcode, only showing the barcode and no numbers.
Please provide the correct parameters.
I have as you see in link tried codeLocation=None but i do not work.
image.png (36.2 KB)
Br Jesper
Hi.
We try to execute following api call to get a barcode, only showing the barcode and no numbers.
Please provide the correct parameters.
I have as you see in link tried codeLocation=None but i do not work.
image.png (36.2 KB)
Br Jesper
Hello @Itlicensemagasin !
Unfortunately, the 1.1 version you are using is no longer being developed. In version 1.1 there is no possibility to disable text under the barcode. Please switch to version v3.0 Aspose.Barcode Cloud - API References which allows you to generate a code without text. For ease of use we have SDK for different programming languages REST Barcode Generator & Reader API (1D, 2D & Postal Barcodes).
Feel free to ask any questions you have about version 3.0.
@itlicensemagasin
We recommend upgrading to Aspose Cloud API v3.0 to access new features and improvements, such as the ability to hide barcode text on the image. Our support team is ready to assist you with the transition.
You can generate a barcode without numbers using Aspose Cloud API version 3.0 by following these steps.
Before making API requests, obtain an access token (a JWT token with a limited lifetime).
Request Details:
POST
https://api.aspose.cloud/connect/token
Content-Type: application/x-www-form-urlencoded
grant_type=client_credentials
client_id=YOUR_CLIENT_ID
client_secret=YOUR_CLIENT_SECRET
Example Using JavaScript Fetch:
Replace 'YOUR_CLIENT_ID'
and 'YOUR_CLIENT_SECRET'
with your actual Aspose Cloud credentials.
Note: If you are using Node.js v18 or higher, the
fetch
API is available globally, and you can remove therequire('node-fetch')
line.
const fetch = require('node-fetch'); // Remove this line if using Node.js v18 or higher
(async () => {
try {
const CLIENT_ID = 'YOUR_CLIENT_ID';
const CLIENT_SECRET = 'YOUR_CLIENT_SECRET';
// Obtain Access Token
const response = await fetch('https://api.aspose.cloud/connect/token', {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: new URLSearchParams({
grant_type: 'client_credentials',
client_id: CLIENT_ID,
client_secret: CLIENT_SECRET,
}),
});
if (!response.ok) {
throw new Error(`Token request failed: ${response.status} ${response.statusText}`);
}
const data = await response.json();
const ACCESS_TOKEN = data.access_token;
console.log('Access Token:', ACCESS_TOKEN);
console.warn('Access Token expires in', data.expires_in / 3600, 'hours');
// Proceed to Step 2 with ACCESS_TOKEN
} catch (error) {
console.error('Error obtaining access token:', error);
}
})();
Use the access token to request the barcode image.
Request Details:
GET
https://api.aspose.cloud/v3.0/barcode/generate
Authorization: Bearer ACCESS_TOKEN
type=Code128
text=3616531385416
format=jpg
DimensionX=4
BarHeight=120
TextLocation=None
Example Using JavaScript Fetch:
Replace 'YOUR_ACCESS_TOKEN'
with the access token you obtained in Step 1.
const fs = require('fs');
const fetch = require('node-fetch'); // Remove this line if using Node.js v18 or higher
(async () => {
try {
const ACCESS_TOKEN = 'YOUR_ACCESS_TOKEN'; // Obtain this from Step 1
// Prepare Query Parameters
const params = new URLSearchParams({
type: 'Code128',
text: '3616531385416',
format: 'jpg',
DimensionX: '4',
BarHeight: '120',
TextLocation: 'None',
});
// Generate Barcode
const response = await fetch(`https://api.aspose.cloud/v3.0/barcode/generate?${params}`, {
method: 'GET',
headers: {
Authorization: `Bearer ${ACCESS_TOKEN}`,
},
});
if (!response.ok) {
throw new Error(`Barcode generation failed: ${response.status} ${response.statusText}`);
}
// Save the Image
const arrayBuffer = await response.arrayBuffer();
fs.writeFileSync('barcode.jpg', Buffer.from(arrayBuffer));
console.log('Barcode image saved as barcode.jpg');
} catch (error) {
console.error('Error generating barcode:', error);
}
})();
Access Token Usage:
Authorization
header with your ACCESS_TOKEN
in all API requests.Barcode Types:
code39
is not a valid barcode type name. To generate Code39 barcodes, use either Code39Standard
or Code39Extended
. For a complete list of barcode types supported by version 1.1, refer to the V1.1 Swagger Specification.Here’s the full API endpoint with parameters to generate Code39Standard barcode without numbers:
https://api.aspose.cloud/v3.0/barcode/generate?type=Code39Standard&text=3616531385416&format=jpg&DimensionX=4&BarHeight=120&TextLocation=None
By following these steps, you can generate a barcode image without the numbers displayed, using the Aspose Cloud API version 3.0. Please feel free to reach out to our support team if you have any questions or need assistance with the upgrade process.