search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Text missing on export time headers.

Asked by Pete
1 year ago.

When exporting, the text from the time headers disappears. My code on the export is below, with screenshot and export attached as files.

        function exportFile() {
            var exportAs = $('input[name="radioExportAs"]:checked').val();
            var exportArea = $('input[name="radioExport"]:checked').val();

            switch (exportAs) {
                case 'png':
                    exportPNG(exportArea)
                case 'pdf':
                    exportPDF(exportArea)
            }
        }

        function exportPNG(exportArea) {
            dps.exportAs("png", { area: exportArea }).download();
        }

        function exportPDF(exportArea) {

            let options = [{ year: 'numeric' }, { month: 'numeric' }, { day: 'numeric' }];
            let joined = join(new Date, options, '-');

            var doc = new jsPDF("landscape", "mm", "a3");
            doc.setFont('Verdana','normal','normal')
            doc.setFontSize(20);
            doc.text(5, 10, "KHM Ops Scheduler");

            var image = dps.exportAs("jpeg", {
                area: exportArea,
                scale: 2,
                quality: 0.95
            });
            var dimensions = image.dimensions();
            var ratio = dimensions.width / dimensions.height;
            var width = 410;
            var height = width / ratio;
            doc.addImage(image.toDataUri(), 'JPEG', 5, 15, width, height);

            DayPilot.Util.downloadBlob(doc.output("blob"), joined + "-KHMOPS_scheduler_export.pdf");
        }
Comment posted by Pete
1 year ago.

On version 2023.2.3832

Answer posted by Dan Letecky [DayPilot]
1 year ago.

If you use onBeforeTimeHeaderRender to customize the headers, the Scheduler will use the value of args.header.html in the live instance in the browser and args.header.text during the export.

Also, it tries to detect the actual CSS styles but it may not be successful in all cases.

Either way, you can tune the appearance of the exported headers using the onBeforeTimeHeaderExport event.

  • To set the header text, use args.text.

  • To set the font color, use args.fontColor.

See also the Client-Side Export page in the documentation.

Please let me know if it doesn’t help.

Comment posted by Pete
1 year ago.

Thanks for that, although I am surprised this isn’t done by default.

Comment posted by Dan Letecky [DayPilot]
1 year ago.

There turned out to be an problem with setting args.header.text in onBeforeTimeHeaderRender. This value was incorrectly ignored during export.

It should be fixed now in the latest sandbox build (2023.2.5601):

https://release.daypilot.org/changes/js/

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.