Articles in this section

How to customize header and footer in Vue Diagram printing?

This article explains how to customize the header and footer in Vue Diagram printing. Headers and footers, located in the top and bottom margins of each page, respectively, are essential elements in document formatting. When the header and footer option is enabled in the print dialog box, these sections become visible.

The Vue Diagram offers the capability to export its content, with the client-side method exportDiagram facilitating this process.

Customizing the header and footer involves adding personalized content, including elements like time, date, or even adjusting the position of the content within the header and footer. This customization occurs in the print window. Refer to the code snippet below to understand how to achieve custom printing while exporting the diagram using exportDiagram.

Note:
To use Print and Export, you need to inject PrintAndExport into the diagram.

function toolbarClick(args: ClickEventArgs): void {
if (args.item.text === 'Print') {
var image;
var options: IExportOptions = {};
options.mode = 'Data';
options.region = 'Content';
options.pageOrientation = 'Portrait';
options.multiplePage = false;
image = diagram.exportDiagram(options);
printImages(image, options);
   }
}


function printImages(url: any, options: any) {
var _this: any = diagram.printandExportModule;
var attr = {
id: diagram.element.id + '_printImage',
src: url
   };
options.margin = { top: 0, bottom: 0, right: 0, left: 0 };
var img = createHtmlElement('img', attr);
img.onload = function() {
var div = _this.getMultipleImage(img, options);
var printWind = window.open('');
if (printWind != null) {
if (div instanceof HTMLElement) {
printWind.document.write(
'
// Customised header
<div class="upper">Syncfusion Diagram control</div>
// Customised Footer
<div class="absolute">Page No: 1</div>'
         );
printWind.document.write(
''
         );
printWind.document.write('<center>' + div.innerHTML + '</center>');
printWind.document.close();
       }
     }
   };
 }
​

The default date and page number can be prevented by adding the following content in CSS or in Style

<style>

@page { size: auto;  margin: 0mm; }

</style>

Refer to the working sample for additional details and implementation: sample

Conclusion

We hope you enjoyed learning about how to customize the header and footer in Vue Diagram printing.

You can refer to our Vue Diagram feature tour page to learn about its other groundbreaking feature representations and documentation, and how to quickly get started with configuration specifications. You can also explore our Vue Diagram example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, BoldDesk Support, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied