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:
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}"
}
}
{
"type": "SALES_INVOICE",
"id": "123e4567-e89b-12d3-a456-426614174000",
"pdfPreview": "JVBERi0xLjcKJYGBgYEKCjQgMCBvYmoKPDwKL1R5cGUgL1hPYmplY3QKL1N1YnR5cGUg..."
}
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);
});
}