Skip to content

Conversation

@newpheeraphatflowaccount

This pull request introduces several enhancements and fixes across the PDF generation pipeline, focusing on improved table and layer handling, more robust document preprocessing and measurement, better browser compatibility, and support for advanced footer rendering options.

Major improvements and fixes:

1. Enhanced Table and Layer Handling

  • Added support for a new layers property in document nodes, including preprocessing and measurement logic to handle layered content. (src/docPreprocessor.js, src/docMeasure.js) [1] [2] [3] [4]
  • Improved table handling by adding checks for malformed or missing table rows, throwing descriptive errors, and ensuring the measurement logic gracefully handles empty or incomplete tables. (src/docMeasure.js, src/docPreprocessor.js) [1] [2]

2. Document Preprocessing and Measurement Robustness

  • Changed tocs and nodeReferences from arrays to objects for more efficient lookups and manipulation. (src/docPreprocessor.js)
  • Improved handling of Table of Contents (TOC) item processing and node references, making the code more robust and readable. (src/docPreprocessor.js) [1] [2]
  • Added default initialization for svgMeasure and tableLayouts to prevent undefined errors. (src/docMeasure.js)

3. Improved Browser Compatibility

  • Introduced a browser shim for @flowaccount/node-icu-tokenizer to ensure the library works in browser environments without Node.js native bindings, providing a fallback tokenization strategy. (src/browser-extensions/tokenizer-shim.js)

4. Footer Rendering and Context Enhancements

  • Added support for advanced footer gap rendering, including drawing vertical guide lines in footers based on column specifications, and propagating footer options through the document context and element writer. (src/documentContext.js, src/elementWriter.js) [1] [2] [3] [4]
  • Updated context management logic to handle footer-specific options and ensure correct positioning and sizing of footers. (src/documentContext.js, src/elementWriter.js) [1] [2]

5. Miscellaneous Fixes and Improvements

  • Improved image URL resolution logic to only resolve remote images and handle both remote and local images correctly. (src/browser-extensions/pdfMake.js)
  • Defensive coding improvements such as handling empty snapshots and contexts, and minor code cleanups for clarity and maintainability. (src/documentContext.js) [1] [2]

These changes collectively improve the flexibility, reliability, and browser compatibility of the PDF generation process.

Introduces 'layers' as a new node type with measurement, preprocessing, and layout support. Adds footer gap rendering with column guides and options, and implements vertical alignment for table cells and layers. Refactors header/footer height handling, improves image buffer support, and enhances error handling and testability. Also adds browser tokenizer shim and new customized tests.
Introduces a new test file 'pageElementWriter_footer_vlines.spec.js' to improve coverage of vertical line rendering in pageElementWriter footers. Also includes updates to related source and test files for enhanced functionality and test accuracy.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant