|
5 | 5 | [](https://pypi.org/project/aspose-barcode-cloud/) |
6 | 6 |
|
7 | 7 | - API version: 3.0 |
8 | | -- Package version: 24.6.0 |
| 8 | +- Package version: 24.7.0 |
9 | 9 |
|
10 | 10 | ## Demo applications |
11 | 11 |
|
@@ -54,38 +54,36 @@ import aspose_barcode_cloud |
54 | 54 | The examples below show how you can generate and recognize Code128 barcode and save it into local file using aspose-barcode-cloud: |
55 | 55 |
|
56 | 56 | ```python |
57 | | -from __future__ import division, print_function |
58 | | - |
| 57 | +import os |
59 | 58 | from pprint import pprint |
60 | 59 |
|
61 | | -import aspose_barcode_cloud |
62 | | -from aspose_barcode_cloud.rest import ApiException |
| 60 | +from aspose_barcode_cloud import ( |
| 61 | + BarcodeApi, |
| 62 | + ApiClient, |
| 63 | + Configuration, |
| 64 | + EncodeBarcodeType, |
| 65 | + CodeLocation, |
| 66 | + DecodeBarcodeType, |
| 67 | +) |
63 | 68 |
|
64 | | -# Configure OAuth2 access token for authorization: JWT |
65 | | -configuration = aspose_barcode_cloud.Configuration( |
| 69 | +config = Configuration( |
66 | 70 | client_id="Client Id from https://dashboard.aspose.cloud/applications", |
67 | 71 | client_secret="Client Secret from https://dashboard.aspose.cloud/applications", |
| 72 | + access_token=os.environ.get("TEST_CONFIGURATION_ACCESS_TOKEN"), # Only for testing in CI, remove this line |
68 | 73 | ) |
69 | 74 |
|
70 | | -# create an instance of the API class |
71 | | -api = aspose_barcode_cloud.BarcodeApi(aspose_barcode_cloud.ApiClient(configuration)) |
72 | | -type = aspose_barcode_cloud.EncodeBarcodeType.CODE128 # str | Type of barcode to generate. |
73 | | -text = 'text_example' # str | Text to encode. |
74 | | - |
75 | | -try: |
76 | | - # Generate barcode. |
77 | | - response = api.get_barcode_generate(type, text) |
78 | | - with open("example.png", "wb") as f: |
79 | | - f.write(response.data) |
80 | | - print("Barcode saved to file 'example.png'") |
81 | | -except ApiException as e: |
82 | | - print("Exception when calling BarcodeApi->get_barcode_generate: %s\n" % e) |
| 75 | +api = BarcodeApi(ApiClient(config)) |
83 | 76 |
|
| 77 | +# Generate barcode |
| 78 | +response = api.get_barcode_generate(EncodeBarcodeType.QR, "Example", text_location=CodeLocation.NONE) |
| 79 | +with open("example.png", "wb") as f: |
| 80 | + f.write(response.data) |
| 81 | +print("Barcode saved to file 'example.png'") |
84 | 82 |
|
85 | 83 | # Recognize barcode |
86 | | -response = api.post_barcode_recognize_from_url_or_content(image="example.png", |
87 | | - preset=aspose_barcode_cloud.PresetType.HIGHPERFORMANCE) |
| 84 | +response = api.scan_barcode("example.png", decode_types=[DecodeBarcodeType.QR]) |
88 | 85 | pprint(response) |
| 86 | + |
89 | 87 | ``` |
90 | 88 |
|
91 | 89 | ## Requirements |
@@ -216,3 +214,4 @@ Class | Method | HTTP request | Description |
216 | 214 | - [TextAlignment](docs/TextAlignment.md) |
217 | 215 | - [FileVersion](docs/FileVersion.md) |
218 | 216 |
|
| 217 | + |
0 commit comments