Our pure JavaScript Scheduler component


Post by Exigo »

Hello

I've found a bug in small windows when exporting.

When changing the size of the window and exporting we can get an error:

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'top')
    at MultiPageExporter.buildPage (schedulerpro.module.js:43:12521)
    at MultiPageExporter.pagesExtractor (schedulerpro.module.js:43:15428)
    at pagesExtractor.next (<anonymous>)
    at MultiPageExporter.getPages (schedulerpro.module.js:43:5546)
    at async MultiPageExporter.export (schedulerpro.module.js:43:5268)
    at async PdfExport.export (schedulerpro.module.js:43:34389)

How to reproduce:

Go to the example:
https://bryntum.com/examples/examples-scheduler/milestonelayout/

Set the code to the one in the txt example

Set the viewport to the size in the image below

error_print.png
error_print.png (110.53 KiB) Viewed 241 times

Press the print button and the error will come.

The issues seems to be that it calculates the vertical pages using totalheight in MultiPageExporter.js preparecomponent function.

totalHeight = exportMeta.totalHeight + client.height - client.bodyHeight + client.scrollable.scrollHeight;
...
verticalPages = Math.ceil(totalHeight / contentHeight);

I've fixed it in our own code by counting the rows and rows height so it calculates the correct vertical pages:

export class MyMultiPageVerticalExporter extends MultiPageVerticalExporter {
  private exportMeta: any;

  static get $name() {
    return 'MyMultiPageVerticalExporter';
  }

  static get type() {
    return 'mymultipagevertical';
  }

  async prepareComponent(config) {
    //@ts-ignore
    await super.prepareComponent(config);
    const { exportMeta } = this;
    const { client } = config;
    // Fix for issues with high schedules
    const printHeight = exportMeta.totalRows * client.rowManager.rowOffsetHeight + client.headerHeight;
    exportMeta.verticalPages = Math.ceil(printHeight / exportMeta.contentHeight);
    exportMeta.totalPages = exportMeta.horizontalPages * exportMeta.verticalPages;
  }
}

Cheers
Andreas @ Exigo

Attachments
code_print_bug_example.txt
(3.65 KiB) Downloaded 26 times

Post by tasnim »

Thanks for reporting.
We'll investigate it. Here is the ticket: https://github.com/bryntum/support/issues/4867


Post by Exigo »

It also happens in Multipage exporter, since they both use this logic :)


Post Reply