Skip to content

Commit bbe4ab9

Browse files
committed
Add Name property for set custom icon for note() #1319
1 parent cf5a774 commit bbe4ab9

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- Add support for spot colors
88
- Add support to scale text horizontally
99
- Add an option to keep the indentation after a new line starts and allow to indent a whole paragraph/text element
10+
- Add `Name` property for set custom icon for `note()`
1011
- Fix sets tab order to "Structure" when a document is tagged
1112
- Fix font cache collision for fonts with missing postscript name or bad TTF metadata or identical metadata for different fonts
1213
- Fix for embedding fonts into PDF (font name must not contain spaces)

docs/annotations.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ Many of the annotations have a `color` option that you can specify. You can
2222
use an array of RGB values, a hex color, a named CSS color value, or a named
2323
spot color value for that option.
2424

25+
A custom icon can be set using option `Name` property. Possible values are:
26+
`'Comment'`, `'Key'`, `'Note'`, `'Help'`, `'NewParagraph'`, `'Paragraph'`
27+
and `'Insert'`.
28+
2529
If you are adding an annotation to a piece of text, such as a link or
2630
underline, you will need to know the width and height of the text in order to
2731
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.
6973
.strike(20, doc.y, doc.widthOfString('STRIKE!'), height)
7074
.text('STRIKE!');
7175

76+
// Create note
77+
doc.note(10, 30, 30, 30, "Text of note");
78+
79+
// Create note with custom options
80+
doc.note(10, 80, 30, 30, "Text of custom note", {Name: 'Key', color: 'red'});
81+
7282
// Adding go to as annotation
7383
doc.goTo(20, doc.y, 10, 20, 'LINK', {});
7484

lib/mixins/annotations.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ export default {
3434
note(x, y, w, h, contents, options = {}) {
3535
options.Subtype = 'Text';
3636
options.Contents = new String(contents);
37-
options.Name = 'Comment';
37+
if (options.Name == null) {
38+
options.Name = 'Comment';
39+
}
3840
if (options.color == null) {
3941
options.color = [243, 223, 92];
4042
}

0 commit comments

Comments
 (0)