i want my download button of menu bar to be paced in toolbar group or ribbon element placed on top
The following code will add a button and save the document
instance.setHeaderItems(header => {
header.push({
type: 'actionButton',
img: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M0 0h24v24H0z" fill="none"/><path d="M17 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V7l-4-4zm-5 16c-1.66 0-3-1.34-3-3s1.34-3 3-3 3 1.34 3 3-1.34 3-3 3zm3-10H5V5h10v4z"/></svg>',
onClick: async () => {
// save the annotations
const doc = await PDFNet.PDFDoc.createFromURL(filename); // replace filename
// save the document to a memory buffer
const buf = await doc.saveMemoryBuffer(PDFNet.SDFDoc.SaveOptions.e_linearized);
//optionally save the blob to a file or upload to a server
const blob = new Blob([buf], { type: 'application/pdf' });
// we use https://www.npmjs.com/package/file-saver to download the file
// but at this point it is up to you
}
});
});
For more detail, please refer to here:
To remove the download button from the menu:
You can use
instance.disableElements(['downloadButton'])
Oscar
1 Like