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 PHP. 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
).<?php
declare(strict_types=1);
require 'vendor/autoload.php';
use Aspose\BarCode\Configuration;
use Aspose\BarCode\GenerateApi;
use Aspose\BarCode\Model\{BarcodeImageFormat, CodeLocation, EncodeBarcodeType};
use Aspose\BarCode\Requests\GenerateRequestWrapper;
function makeConfiguration(): Configuration
{
$config = new Configuration();
$envToken = getenv("TEST_CONFIGURATION_ACCESS_TOKEN");
if (empty($envToken)) {
$config->setClientId("Client Id from https://dashboard.aspose.cloud/applications");
$config->setClientSecret("Client Secret from https://dashboard.aspose.cloud/applications");
} else {
$config->setAccessToken($envToken);
}
return $config;
}
function main(): void
{
$fileName = __DIR__ . "/../testdata/Qr.png";
$generateApi = new GenerateApi(null, makeConfiguration());
$request = new GenerateRequestWrapper(
EncodeBarcodeType::QR,
'Aspose.BarCode.Cloud');
$request->image_format = BarcodeImageFormat::Png;
$request->foreground_color = 'Black';
$request->background_color = 'White';
$request->text_location = CodeLocation::Below;
$request->resolution = 300;
$request->image_height = 200;
$request->image_width = 200;
$generated = $generateApi->generate($request);
file_put_contents($fileName, $generated->fread($generated->getSize()));
echo "File '{$fileName}' generated.\n";
}
main();
Result Image is:
<?php
declare(strict_types=1);
require 'vendor/autoload.php';
use Aspose\BarCode\Configuration;
use Aspose\BarCode\GenerateApi;
use Aspose\BarCode\Model\{GenerateParams, EncodeBarcodeType, EncodeData, EncodeDataType, BarcodeImageParams, BarcodeImageFormat};
use Aspose\BarCode\Requests\GenerateBodyRequestWrapper;
function makeConfiguration(): Configuration
{
$config = new Configuration();
$envToken = getenv("TEST_CONFIGURATION_ACCESS_TOKEN");
if (empty($envToken)) {
$config->setClientId("Client Id from https://dashboard.aspose.cloud/applications");
$config->setClientSecret("Client Secret from https://dashboard.aspose.cloud/applications");
} else {
$config->setAccessToken($envToken);
}
return $config;
}
function main(): void
{
$fileName = __DIR__ . "/../testdata/Code39.jpeg";
$generateApi = new GenerateApi(null, makeConfiguration());
$generateParams = new GenerateParams([
'barcode_type' => EncodeBarcodeType::Code39,
'encode_data' => new EncodeData([
'data' => 'Aspose',
'data_type' => EncodeDataType::StringData
]),
'barcode_image_params' => new BarcodeImageParams([
'foreground_color' => '#FF0000',
'background_color' => '#FFFF00',
'image_format' => BarcodeImageFormat::Jpeg,
'rotation_angle' => 90
])
]);
$request = new GenerateBodyRequestWrapper($generateParams);
$generated = $generateApi->generateBody($request);
file_put_contents($fileName, $generated->fread($generated->getSize()));
echo "File '{$fileName}' generated.\n";
}
main();
Result Image is:
<?php
declare(strict_types=1);
require 'vendor/autoload.php';
use Aspose\BarCode\Configuration;
use Aspose\BarCode\GenerateApi;
use Aspose\BarCode\Model\{BarcodeImageFormat};
use Aspose\BarCode\Requests\GenerateMultipartRequestWrapper;
use Aspose\BarCode\Model\EncodeBarcodeType;
function makeConfiguration(): Configuration
{
$config = new Configuration();
$envToken = getenv("TEST_CONFIGURATION_ACCESS_TOKEN");
if (empty($envToken)) {
$config->setClientId("Client Id from https://dashboard.aspose.cloud/applications");
$config->setClientSecret("Client Secret from https://dashboard.aspose.cloud/applications");
} else {
$config->setAccessToken($envToken);
}
return $config;
}
function main(): void
{
$fileName = __DIR__ . '/../testdata/Pdf417.svg';
$generateApi = new GenerateApi(null, makeConfiguration());
$request = new GenerateMultipartRequestWrapper(
EncodeBarcodeType::Pdf417,
"Aspose.BarCode.Cloud"
);
$request->text_location = "Above";
$request->image_format = BarcodeImageFormat::Svg;
$barcodeStream = $generateApi->generateMultipart($request);
file_put_contents($fileName, $barcodeStream->fread($barcodeStream->getSize()));
echo "File '{$fileName}' generated.\n";
}
main();
Result Image is:
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.