Hi Dinesh Kumar,
We have prepared the sample based on your requirements. In the provided sample, we have used a custom toolbar item for the Download functionality by removing the default download button using the API. On clicking the custom toolbar item, using the API, we use the EJ2 PDF Library to add a header with an image and text to every page of the PDF document before saving it.
We have also attached a video for your reference. Please check whether it meets your requirements and feel free to reach out if you have any queries.
Code snippet:
//define custom toolbar item
public save: CustomToolbarItemModel = {
prefixIcon: 'e-icons e-save',
id: 'save',
tooltipText: 'Add header and save',
align: 'right',
};
//add required toolbar items with custom toolbaritem
public toolbarSettings = {
showTooltip: true,
toolbarItems: [
'OpenOption',
'PageNavigationTool',
'MagnificationTool',
'PanTool',
'SelectionTool',
'SearchOption',
'PrintOption',
// 'DownloadOption',
'UndoRedoTool',
'AnnotationEditTool',
'FormDesignerEditTool',
'CommentTool',
'SubmitForm',
this.save,
],
};
//toolbar click event
public toolbarClick(args): void {
if (args.item.id === 'save') {
this.pdfviewerControl.saveAsBlob().then((value) => {
const reader = new FileReader();
reader.readAsDataURL(value);
reader.onload = () => {
const base64data = reader.result as string;
const pureBase64 = base64data.replace(
/^data:application\/pdf;base64,/,
''
);
let updated = this.drawHeaderTemplate(pureBase64);
//console.log(base64data);
// Load the document from base64 string
//this.pdfviewerControl.load(updated, null);
};
});
}
}
Demo for add header on every pages before save
Regards,
Venkada Subramanian Durai