pdf-lib
pdf-lib copied to clipboard
drawText Does not support text style like text decoration
What were you trying to do?
Hello @hop, I want to draw text with the styling of text like line of text but unable to draw this type of style here is an option to add fonts but fonts does not support underlining so there is no way to add underline along with text,
How did you attempt to do it?
I am trying to create functionality for editing PDFs with drawText and image the I found this big issue.
What actually happened?
TextDraw does not support the styling textdraw only support limited params
What did you expect to happen?
textDraw should support the custom styling like every editor support
How can we reproduce the issue?
I am trying to draw text on pdf with some styling like bold, italic, underline but bold, italic is in the font but cant able to do this with underline so I need to do this feature.
Version
1.17.1
What environment are you running pdf-lib in?
Browser
Checklist
- [X] My report includes a Short, Self Contained, Correct (Compilable) Example.
- [X] I have attached all PDFs, images, and other files needed to run my SSCCE.
Additional Notes
I am trying to draw text on pdf with some styling like bold, italic, and underline but bold, italic is in the font but cant able to do this with underline so I need to do this feature.
there is no such thing as font with underline styles (unless very custom designed with lines ALWAYS included), those are manually added by the word processor as a line drawn under the letters, so in a PDF they are separate objects draw the line and write text above or write the text and draw a line through / underneath. Overstrike or underline annotations are simply that , additions floating over or under a text block.
Duplication of https://github.com/Hopding/pdf-lib/issues/752 ?
However, it would still be nice to have the ability to toggle those basic font styles: bold, italic, underlined.
There's no recent updates on this lib, though :( @Hopding is this project dead? The weekly downloads have reached more than 500k, and it's constantly growing, it would be a shame to let this project die
@Hopding I'm also curious to know if the project is dead? We have a current need for a PDF library, and just wondering if we should consider another one.
Thanks!
I would add my vote to this request for the ability to enable Bold, Italic, etc for the desired words in a DrawText string (or a workaround to achieve this). Am I missing a simple solution to build a text block such as this: Hello World, the following is Bold, and this is also an Italicized word.
Thanks @Hopding for your great work on this library!
@ryangriggs this question is about using fonts that do not exist in a standard PDF (the only fonts with underline are specialist and very rare) thus you need to source a custom font that includes strike through or underline. The@pdf-lib/fontkit module must be installed to embed custom fonts. demo of a plain font embedding https://jsfiddle.net/Hopding/rgu6ca59/2/
the standard fonts include Bold or Italic/Oblique and Bold-Oblique/Italic Inherent fonts in a PDF are assigned to your choice of variable
const blah1 = await pdfDoc.blah embedFont(StandardFonts.Helvetica) font: blah1
Where Helvetica can be one of 14 Adobe named styles
Courier = 'Courier', CourierBold = 'Courier-Bold', CourierOblique = 'Courier-Oblique', CourierBoldOblique = 'Courier-BoldOblique', Helvetica = 'Helvetica', HelveticaBold = 'Helvetica-Bold', HelveticaOblique = 'Helvetica-Oblique', HelveticaBoldOblique = 'Helvetica-BoldOblique', TimesRoman = 'Times-Roman', TimesRomanBold = 'Times-Bold', TimesRomanItalic = 'Times-Italic', TimesRomanBoldItalic = 'Times-BoldItalic', Symbol = 'Symbol', ZapfDingbats = 'ZapfDingbats',
I really hope it's not dead!