-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGenerateGet.php
More file actions
52 lines (39 loc) · 1.4 KB
/
GenerateGet.php
File metadata and controls
52 lines (39 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?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();