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

Combining center align with multiple parts of text (continued:true) #1206

Open
EpitechGuo opened this issue Jan 7, 2021 · 1 comment
Open

Comments

@EpitechGuo
Copy link

EpitechGuo commented Jan 7, 2021

Combining center align with multiple parts of text (continued:true)

I wanted to have one line of text centered but with different fontStyle and color on each part of text

Code sample

 doc
    .font(font.OpenSansLight).text('ENTRÉE : ', 0, 250, { width: doc.page.width, align: 'center' , continued:true})
    .font(font.OpenSansSemiBold).fillColor(data.promoter.color).text('600 €').moveDown(0.2)

and here's output on the pdf :
image
it's centered , but not correctly, the second text are not following at the end of the first text

Your environment

  • pdfkit version: 0.9.0
  • Node version: 15.4.0
  • Browser version (if applicable):
  • Operating System: windows/linux
@EpitechGuo
Copy link
Author

so , after multiple trying , I found out how we can solve it , but it should be update globally in the module
code after fix (github purge all useless space , so I can only show it on picture):
image

so basically what happening here : the first text doesn't counting the second text length when I applying the 'center' option

output after adding space on the first text (ofc we can create a variable it take the second text length and add it dynamically )
image

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

1 participant