Skip to content

Commit

Permalink
Merge pull request #152 from shaehn/docinfo
Browse files Browse the repository at this point in the history
Fix for missing text in annotation #113
  • Loading branch information
chunyenHuang authored Nov 12, 2019
2 parents 58f4416 + b9022c7 commit 97c1591
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
6 changes: 3 additions & 3 deletions lib/annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ exports._annot = function _annot(subtype, args = {}, pageNumber) {
.writeKey('Rect')
.writeRectangleValue(position)
.writeKey('Subj')
.writeLiteralStringValue(this.writer.createPDFTextString(params.subject).toBytesArray())
.writeLiteralStringValue(params.subject)
.writeKey('T')
.writeLiteralStringValue(params.title || '')
.writeKey('M')
Expand All @@ -123,13 +123,13 @@ exports._annot = function _annot(subtype, args = {}, pageNumber) {
*/
if (text && options.richText) {
const richText = (text.substring(0, 4) !== '<?xml') ? contentToRC(text) : text;
const richTextContent = this.writer.createPDFTextString(richText).toBytesArray();
const richTextContent = richText;
this.dictionaryContext
.writeKey('RC')
.writeLiteralStringValue(richTextContent);
} else
if (text) {
const textContent = this.writer.createPDFTextString(text).toBytesArray();
const textContent = text;
this.dictionaryContext
.writeKey('Contents')
.writeLiteralStringValue(textContent);
Expand Down
13 changes: 9 additions & 4 deletions tests/annotation-comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@ describe('Annotation: Comment', () => {
recipe
// 1st Page
.createPage('letter-size')
.text('Click\nbelow', 298, 60)
.text('Except for the background rectangle exposing it, the annotation above would normally be invisible because no color option was given to it.',
175, 150, {textBox: {width: 280, textAlign:'center'}})
.rectangle(290, 90, 50, 50, {fill:'red', opacity:.2})
.comment('Feel free to open issues to help us!', 'center', 100, {
title: 'First Comment',
flag: 'locked'
subject: 'Not Really Visible',
// flag: 'locked'
})
.endPage()
.endPDF(done);
Expand Down Expand Up @@ -68,11 +73,11 @@ describe('Annotation: Comment', () => {
recipe
// 1st Page
.createPage('letter-size')
.text('Trace-based Just-in-Time Type Specialization for Dynamic Languages', 'center', 'center')
.annot('center', 'center', 'Highlight', {
.text('Trace-based Just-in-Time Type Specialization for Dynamic Languages', 100, 'center')
.annot(100, 'center', 'Highlight', {
text: 'Oh~la',
width: 200,
height: 50
height: 14
})
.endPage()
.endPDF(done);
Expand Down

0 comments on commit 97c1591

Please sign in to comment.