This service generates a binary representation of the PDF.
This binary data, often referred to as a blob can easily be displayed in a PDF viewer embedded within a browser tab.
HTTP | Operation | Type | Object | DTO Why-DTOs? |
---|---|---|---|---|
(Query) | documentPdfPreview |
DocumentPdfPreviewGLDtoInput |
This service generates a binary representation of the PDF.
This binary data, often referred to as a blob can easily be displayed in a PDF viewer embedded within a browser tab.
To utilize this service, you need to provide the following input parameters:
type: Type of the document for which the preview is requested.
id: The unique identifier of the document for which the preview is being generated.
The service returns a DocumentPdfPreviewOutputGLDto
object containing the following fields:
Key | Value |
---|---|
Authorization |
Bearer Current access Token How to find? |
X-TenantId |
Current tenant id How to find? |
X-OrganizationId |
Current organization Id How to find? |
x-api-key |
Primary or secondary subscription key of your app How to find? |
query($input: DocumentPdfPreviewGLDtoInput!) {
documentPdfPreview(input: $input) {
type
id
pdfPreview
}
}
{
"input": {
"type": "SALES_INVOICE",
"id": "{invoiceId}"
}
}
{
"data": {
"documentPdfPreview": {
"type": "SALES_INVOICE",
"id": "0e1987c3-e712-4906-8b26-42e4a4c36079",
"pdfPreview": "JVBERi0xLjcKJYGBgYEKCjEwIDAgb2JqCjw8Ci9GaWx0ZXIgL0ZsY..."
}
}
}
Fields | Type | Description | Length |
---|---|---|---|
type |
|
Type of the document (e.g., SALES_INVOICE) | |
id | UUID | Unique identifier of the document |
Fields | Type | Description | Length |
---|---|---|---|
type |
|
Type of the document previewed | |
id | UUID | Unique identifier of the document | |
pdfPreview | String | Binary representation of the PDF (Base64 encoded string) |
To display the PDF in a browser, you can use the provided JavaScript function pdfPreviewInBrowser
with the PdfPreview
string.
function pdfPreviewInBrowser(base64String){
const base64Pdf = `data:application/pdf;base64,${base64String}`;
let pdfBlob = fetch(base64Pdf).then(res => res.blob());
pdfBlob.then(blob => {
const pdfUrl = URL.createObjectURL(blob);
window.open(pdfUrl);
});
}