PdfPig icon indicating copy to clipboard operation
PdfPig copied to clipboard

Issue drawing checkmark ("✔") character

Open tfrizzell opened this issue 4 years ago • 1 comments

I've been trying to figure this one out. I've got the need to write a checkmark ("✔") into an existing PDF document. I'm loading the PDF using PdfDocument.Open and added each page into a new PdfDocumentBuilder using builder.AddPage. I've confirmed that this is character - \u2713 - exists in the ZapfDingbats glyph list, but when I try to add it I get The font does not contain a character: ✔. I can't, for the life of me, figure out why it's not working so I'm hoping that somebody can provide some direction.

I've also tried drawing it using the character "4" since that seems to be related to it in Adobe's character set but get The font does not contain a character: 4..

I'm using the latest nuget version, v0.1.5.

tfrizzell avatar Oct 08 '21 12:10 tfrizzell

I'll let anyone correct me if I say anything wrong here, but I seem to remember that fonts in pdf (especially non-default ones) don't necessary come with every characters. Some may come with characters only present in the document. In this scenario, it is impossible to write any other character using the fonts from the document.

I suggest you try writing something else using characters from the document, such as "OK" ?

Poltuu avatar Oct 12 '21 09:10 Poltuu

Possibly related to #514 looking for contributors to help since document builder isn't my area of development in the very little time I have to develop this library

EliotJones avatar Dec 11 '22 20:12 EliotJones

@tfrizzell and @EliotJones, interestingly just worked on this this afternoon as extension of #514. Have added support for mapping Unicode characters (eg Dingbat block 0x2700 to 0x27bf) to Type1StandardFont code so AddText works seamlessly. Bit more natural in C# to store Unicode strings than native pdf codes. Also Unicode mappings for characters like Euro symbol, Delta etc. Have working code. Just building out map and finishing test cases.

fnatzke avatar Dec 13 '22 11:12 fnatzke

@EliotJones, @tfrizzell and @rwest500.

Final phase of testing.

Added support for AddText to accept strings in either font specific (eg octal values from spec so 063 or "3" for tick in ZapfDingbats) or unicode ("\u2713" or "✓") [Note thicker tick is '4' or "\u2714" '✔']. [Glyph names 'a19' and 'a20']

Attached are tables for all the 14 standard fonts. Octal codes in black. Unicode in blue. Red if character only available using a Unicode (for values that also appear in the font specific pdf code table).

Also updated text extraction to support all 14 standard fonts incluiding ZapfDingbats. Letters extracted have value which are only unicodes values.

Test cases rebuilds the attached PDFs.

ZapfDingbatsFontAddText.pdf StandardFontsAddText.pdf SymbolFontAddText.pdf

fnatzke avatar Dec 17 '22 07:12 fnatzke