Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A single line of text, that has various styling is split across multiple lines. #225

Closed
bejhan-rxnt opened this issue Oct 24, 2024 · 2 comments

Comments

@bejhan-rxnt
Copy link

bejhan-rxnt commented Oct 24, 2024

Provide the HTML code
<strong>Some bold text</strong> and <i>some italicized text</i>

Describe the bug
In HTML, all of the text would be the same line:
image

However, because html-to-pdfmake generates separate entries for each tag, pdfmake puts them on different lines.
image

var dd = {
  "content": [
    {
      "text": "Some bold text",
      "nodeName": "STRONG",
      "bold": true,
      "style": [
        "html-strong"
      ]
    },
    {
      "text": " and "
    },
    {
      "text": "some italicized text",
      "nodeName": "I",
      "italics": true,
      "style": [
        "html-i"
      ]
    }
  ],
  "styles": {
    "green": {
      "color": "green"
    }
  }
}

I believe, if they were nested within a text entry, then pdfmake would keep them together.

var dd = {
  "content": [
    { "text": [
        {
          "text": "Some bold text",
          "nodeName": "STRONG",
          "bold": true,
          "style": [
            "html-strong"
          ]
        },
        {
          "text": " and "
        },
        {
          "text": "some italicized text",
          "nodeName": "I",
          "italics": true,
          "style": [
            "html-i"
          ]
        }
      ]
    }
  ],
  "styles": {
    "green": {
      "color": "green"
    }
  }
}
@Aymkdn
Copy link
Owner

Aymkdn commented Oct 24, 2024

If you put them inside a <div> it should fix it.

@Aymkdn Aymkdn added the waiting-for-requestor Waiting for the requestor to provide more info label Oct 24, 2024
@bejhan-rxnt
Copy link
Author

Amazing! Thank you!

@github-actions github-actions bot removed the waiting-for-requestor Waiting for the requestor to provide more info label Oct 24, 2024
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

No branches or pull requests

2 participants