Use the following statement to import all asynchronous request functions:
from pdfdeal.Doc2X.Convert import *
Get access token access_token by personal key.
Parameter | Type | Description |
---|
key | str | Personal Key |
Exception | Description |
---|
Exception | Failed to validate key |
Type | Description |
---|
str | Access Token |
- This function uses the
@async_retry()
decorator, which automatically backs out and retries twice on failure.
Asynchronously uploads a PDF file to the server and returns the UUID of the file.
Parameter | Type | Default | Description |
---|
apikey | str | Required | API key |
pdffile | str | Required | PDF file path |
ocr | bool | True | Whether to do OCR processing |
translate | bool | False | Whether or not to translate |
language | str | “zh” | The language of the file, valid only if translate is True |
model | str | “deepseek” | Translation model, valid only when translate is True |
Exception | Description |
---|
FileError | Input file size too large |
FileError | Open File Error |
RateLimit | Request Rate Limit Exceeded |
Exception | Upload file error |
Type | Description |
---|
str | The UUID of the file |
- This function uses the
@async_retry()
decorator, which automatically backs out and retries twice on failure. - The
language
and model
arguments are valid when translate
is True
.
Caution
Please note that the above translate
translation interface was implemented by a packet grabber to obtain the delivery method, it is not officially supported and its availability is not guaranteed.
Asynchronously uploads an image file to the server and returns the UUID of the file.
Parameter | Type | Default | Description |
---|
apikey | str | Required | API key |
imgfile | str | Required | Image file path |
formula | bool | False | Whether to be in formula-only mode |
img_correction | bool | False | Whether or not to perform image correction |
Exceptions | Description |
---|
FileError | Image file size too large |
FileError | Open File Error |
RateLimit | Request Rate Limit Exceeded |
Exception | Upload file error |
Type | Description |
---|
str | UUID of the file |
- This function uses the
@async_retry()
decorator, which automatically backs out and retries twice on failure.
Asynchronous function to get the status of the document, both for PDF and image UUID.
Parameter | Type | Default | Description |
---|
apikey | str | mandatory | API key |
uuid | str | Required | UUID of the file |
convert | bool | False | Whether or not to convert |
translate | bool | False | Whether to use the translation interface |
Returns a tuple (progress, status, texts)
with three elements:
progress
(int
): progress percentagestatus
(str
): Description of the status.texts
(list
): list of texts, recognized plain text results
RuntimeError
: Page Limit ExceededRuntimeError
: unknown stateException
: Error getting state
- This function uses the
@async_retry()
decorator, which automatically backs out and retries twice on failure.
Caution
Please note that the above translate
translation interface was implemented by a packet grabber to obtain the delivery method, it is not officially supported and its availability is not guaranteed.
Gets the file by UUID and saves it in the specified format.
Warning
Please poll for the file status first and call this function after the final processing is successful.
Parameters | Type | Default Value | Description |
---|
apikey | str | Mandatory | API key |
uuid | str | Required | UUID of the file |
output_format | Literal[“md”, “md_dollar”, “latex”, “docx”] | Required | Output format |
output_path | str | ". /Output" | Output path |
Exceptions | Description |
---|
Exception | Input path is not a directory |
RateLimit | Rate limit exceeded |
Exception | Download File Error |
Type | Description |
---|
str | Path to file |
- This function uses the
@async_retry()
decorator, which automatically backs out and retries twice on failure.
Asynchronous function to get the remaining amount of the API key.
Parameter | Type | Description |
---|
apikey | str | API key |
Exceptions | Description |
---|
RuntimeError | Thrown when key is invalid |
Type | Description |
---|
int | Remaining amount of API key |
- This function uses the
@async_retry()
decorator, which automatically backs out and retries twice on failure.