You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
header:'<style>... custom css classes here ...</style>'
416
+
header:'<style>... custom css classes here ...</style>'
417
417
});
418
418
~~~
419
419
@@ -432,27 +432,30 @@ For more examples, check the [How to add resource chart or custom styles in the
432
432
433
433
### Collecting all styles for the export function
434
434
435
-
Sometimes styles are specified in different files unavailable for public access, and it is unhandy to include styles from each of them separately. There is a way to collect all styles together for export.
435
+
Sometimes styles are specified in different files unavailable for public access, and it is unhandy to include styles from each of them separately. There is a way to collect all styles together for export.
436
436
437
437
All styles are stored in the **document.styleSheets** object on an HTML page. If the *style* or *link* element included from the same site is used, you can collect all of them and then specify in the **header**. Check the example below:
438
438
439
439
~~~js
440
-
conststyles= []
441
-
for (el indocument.styleSheets) {
440
+
conststyles= [];
441
+
442
+
for (conststyleSheetofdocument.styleSheets) {
442
443
try {
443
-
construles= (document.styleSheets[el]).cssRules;
444
-
for (rule in rules) {
445
-
styles.push(rules[rule].cssText)
444
+
construles=styleSheet.cssRules;
445
+
446
+
for (construleof rules) {
447
+
styles.push(rule.cssText);
446
448
}
449
+
} catch (error) {
450
+
// Ignore stylesheets that cannot be read
447
451
}
448
-
catch (e) { }
449
452
}
450
453
451
454
gantt.exportToPDF({
452
455
raw:true,
453
456
header:"<style>"+styles.join("") +"</style>"
454
457
});
455
-
~~~
458
+
~~~
456
459
457
460
**Related sample**: [Export Gantt with custom icons to PDF](https://snippet.dhtmlx.com/osbscj62)
458
461
@@ -462,7 +465,7 @@ gantt.exportToPDF({
462
465
## Exporting custom markup and styles {#exportingcustommarkupandstyles}
463
466
464
467
By default the Gantt chart is exported based on the specified configuration and loaded data, while [custom elements](guides/baselines.md) and some templates are not exported.
465
-
To export the whole gantt markup as it is, with all custom elements, you can set the **raw:true** property in the parameter of the [exportToPDF/exportToPNG](guides/export.md#parameters-of-the-export-methods) methods.
468
+
To export the whole gantt markup as it is, with all custom elements, you can set the **raw:true** property in the parameter of the [exportToPDF/exportToPNG](guides/export.md#parameters-of-the-export-methods) methods.
466
469
467
470
~~~js
468
471
gantt.exportToPDF({
@@ -473,14 +476,14 @@ gantt.exportToPDF({
473
476
Note that custom elements will require providing [custom styles](guides/export.md#customstylefortheoutputfile) in order to be displayed correctly.
474
477
475
478
Pay attention that the use of this mode increases the size of the API request. Large charts can exceed limit of the online export of 10MB and may not be exported that way.
476
-
In such a case you need to have an [export service](https://dhtmlx.com/docs/products/dhtmlxGantt/export.shtml) installed locally and increase the request size.
479
+
In such a case you need to have an [export service](https://dhtmlx.com/docs/products/dhtmlxGantt/export.shtml) installed locally and increase the request size.
477
480
478
481
479
482
Check [system requirements](guides/export-requirements.md) to install export services locally.
480
483
481
484
## Exporting HTML elements
482
485
483
-
While exporting the Gantt chart to the PNG and PDF formats, you should note that export of HTML elements is limited due to their possible insecurity.
486
+
While exporting the Gantt chart to the PNG and PDF formats, you should note that export of HTML elements is limited due to their possible insecurity.
484
487
485
488
There are HTML elements which are not entirely allowed for export, such as `<canvas>`, `<svg>`, `<script>` and images with the *src* attribute that contains a Base64 image. However, there are safe ways of exporting images in the SVG and Base64 formats:
486
489
@@ -504,4 +507,3 @@ There are HTML elements which are not entirely allowed for export, such as `<can
504
507
**Related sample**: [Exporting safe and insecure HTML elements to PDF](https://snippet.dhtmlx.com/hj6w4dk3?text="gantt")
505
508
506
509
If you have an export module and you need to export HTML elements that are not supported by our online export server, you can submit a support request to get instructions on the changes you need to make in your module to remove restrictions. However, you should take into account that your server will be vulnerable to XSS-attacks.
0 commit comments