hand-dot / labelmake

labelmake has moved and now available at pdfme / https://github.com/pdfme/pdfme

Home Page:https://labelmake.jp/javascript-pdf-generator-library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[2.0.19] Feature Request: Chaining fields

lanterieur opened this issue · comments

Description:

  • Add the ability to 'chain' fields so that vertical overflow can flow to the next in the chain

Use case:
There are many direct applications possible with this feature (similar to how text flows in Adobe Indesign), the main obvious one is to create columns.

  • Create columns by defining a chain across multiple parallel field boxes

Request:

  • Add a field to Schemas to declare chained text fields
const schemas = {
  imageField,
  titleField,
  leftColumnTextField,
  centerColumnTextField,
  rightColumnTextField,
  chainedTextFields: [
    {
      chainName: "main-columns",
      fields: [
        leftColumnTextField,
        centerColumnTextField,
        rightColumnTextField
      ]
    }
  ]
}
  • Implementation could happen in series:
  • 1 For the first field, create text with regular methods
  • 2 Determine if there is vertical overflow (can be simplified to lineheight × fontheight ×lineBreakcount > height)
  • 3 If no overflow, next fields in chain are created with empty text
  • 4 if there is overflow, split text at the line break before overflow, use that text for the next field in the chain