Unable to get export working for the diagram control
Hi all,
We are currently using Syncfusion's diagram control on a Nuxt web app. We have been able to get most of the features we want working so far except for the ability to export the diagram as an image. In our methods section of the script part of the page, we have the following method:
exportPDF() {
let diagramObj = document.getElementById('diagram')
let diagramInstance = diagramObj.ej2_instances[0]
let exportOptions = {}
exportOptions.mode = 'Download'
exportOptions.format = 'PDF'
exportOptions.region = 'PageSettings'
exportOptions.fileName = 'Export'
exportOptions.pageHeight = 400
exportOptions.pageWidth = 400
diagramInstance.exportDiagram(exportOptions)
},
This is called by a button. Nothing seems to happen when this method is called though. Is there something we are doing wrong in our code?
Thank you
SIGN IN To post a reply.
3 Replies
SG
Shyam G
Syncfusion Team
October 14, 2019 05:38 AM UTC
Hi Daniel,
To use Print and Export, you need to inject PrintAndExport module in the diagram. Please refer to a code example below.
Code example:
|
import {
PrintAndExport,
} from "@syncfusion/ej2-vue-diagrams";
//inject diagram printandexport
Diagram.Inject(PrintAndExport);
|
You have set an incorrect value for the format in your code example. We should set image format as jpg, png, bmp to export diagram to image. We modified your code example and included a sample for your reference.
Code example:
|
methods: {
exportDiagram: function (event) {
let exportOptions = {}
exportOptions.mode = 'Download'
exportOptions.format = 'jpg'
exportOptions.region = 'PageSettings'
exportOptions.fileName = 'Export'
exportOptions.pageHeight = 400
exportOptions.pageWidth = 400
diagramInstance.exportDiagram(exportOptions)
}
}
|
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/printandexportsample-1760668611
Help documentation: https://ej2.syncfusion.com/vue/documentation/diagram/export/?no-cache=1
Regards,
Shyam G
DA
Daniel
October 15, 2019 02:06 AM UTC
Hi Shyam,
Thank for your reply, I was able to get it working with your help.
Regards,
Daniel
SG
Shyam G
Syncfusion Team
October 15, 2019 06:17 AM UTC
Hi Daniel,
Thanks for your update.
Regards,
Shyam G
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
DA Daniel
- Oct 12, 2019 06:54 AM UTC
- Oct 15, 2019 06:17 AM UTC