Add Name property for set custom icon for note() #1319

This commit is contained in:
Libor M. 2024-12-28 16:00:38 +01:00
parent cf5a77469f
commit bbe4ab9305
3 changed files with 14 additions and 1 deletions

View File

@ -7,6 +7,7 @@
- Add support for spot colors
- Add support to scale text horizontally
- Add an option to keep the indentation after a new line starts and allow to indent a whole paragraph/text element
- Add `Name` property for set custom icon for `note()`
- Fix sets tab order to "Structure" when a document is tagged
- Fix font cache collision for fonts with missing postscript name or bad TTF metadata or identical metadata for different fonts
- Fix for embedding fonts into PDF (font name must not contain spaces)

View File

@ -22,6 +22,10 @@ Many of the annotations have a `color` option that you can specify. You can
use an array of RGB values, a hex color, a named CSS color value, or a named
spot color value for that option.
A custom icon can be set using option `Name` property. Possible values are:
`'Comment'`, `'Key'`, `'Note'`, `'Help'`, `'NewParagraph'`, `'Paragraph'`
and `'Insert'`.
If you are adding an annotation to a piece of text, such as a link or
underline, you will need to know the width and height of the text in order to
create the required rectangle for the annotation. There are two methods that
@ -69,6 +73,12 @@ Here is an example that uses a few of the annotation types.
.strike(20, doc.y, doc.widthOfString('STRIKE!'), height)
.text('STRIKE!');
// Create note
doc.note(10, 30, 30, 30, "Text of note");
// Create note with custom options
doc.note(10, 80, 30, 30, "Text of custom note", {Name: 'Key', color: 'red'});
// Adding go to as annotation
doc.goTo(20, doc.y, 10, 20, 'LINK', {});

View File

@ -34,7 +34,9 @@ export default {
note(x, y, w, h, contents, options = {}) {
options.Subtype = 'Text';
options.Contents = new String(contents);
options.Name = 'Comment';
if (options.Name == null) {
options.Name = 'Comment';
}
if (options.color == null) {
options.color = [243, 223, 92];
}