diff --git a/demo/attachment.js b/demo/attachment.js index c017e15..5d45a4d 100644 --- a/demo/attachment.js +++ b/demo/attachment.js @@ -29,12 +29,12 @@ const file = { creationDate: new Date(2020, 3, 1) }; // then, add the annotation -doc.fileAttachmentAnnotation(100, 150, 10, doc.currentLineHeight(), file); +doc.fileAnnotation(100, 150, 10, doc.currentLineHeight(), file); // declared files can be reused, but they will show up separately in the PDF Viewer's attachments panel // we're going to use the paperclip icon for this one together with a short description // be aware that some PDF Viewers may not render the icon correctly — or not at all -doc.fileAttachmentAnnotation(150, 150, 10, doc.currentLineHeight(), file, { +doc.fileAnnotation(150, 150, 10, doc.currentLineHeight(), file, { Name: 'Paperclip', Contents: 'Paperclip attachment' }); diff --git a/demo/attachment.pdf b/demo/attachment.pdf index 557cb2b..6e879b2 100644 Binary files a/demo/attachment.pdf and b/demo/attachment.pdf differ diff --git a/docs/annotations.md b/docs/annotations.md index cd0906c..16c1841 100644 --- a/docs/annotations.md +++ b/docs/annotations.md @@ -16,7 +16,7 @@ and some other properties. Here is a list of the available annotation methods: * `rectAnnotation(x, y, width, height, options)` * `ellipseAnnotation(x, y, width, height, options)` * `textAnnotation(x, y, width, height, text, options)` -* `fileAttachmentAnnotation(x, y, width, height, file, options)` +* `fileAnnotation(x, y, width, height, file, options)` Many of the annotations have a `color` option that you can specify. You can use an array of RGB values, a hex color, or a named CSS color value for that diff --git a/docs/attachments.md b/docs/attachments.md index d265684..e4bb12f 100644 --- a/docs/attachments.md +++ b/docs/attachments.md @@ -28,18 +28,18 @@ There are a few other options for `doc.file`: If you are attaching a file from your file system, creationDate and modifiedDate will be set to the source file's creationDate and modifiedDate. Setting the `hidden` option prevents this file from showing up in the pdf viewer's attachment panel. -While this may not be very useful for embedded files, it is absolutely necessary for the file attachment annotations, to prevent them from showing up twice in the attachment panel. +While this may not be very useful for embedded files, it is absolutely necessary for file annotations, to prevent them from showing up twice in the attachment panel. -## File Attachment Annotations +## File Annotations -A file attachment annotation contains a reference to an embedded file that can be placed anywhere in the document. -File attachment annotations show up in your reader's annotation panel as well as the attachment panel. +A file annotation contains a reference to an embedded file that can be placed anywhere in the document. +File annotations show up in your reader's annotation panel as well as the attachment panel. -In order to add a file attachment annotation, you should first read the chapter on annotations. +In order to add a file annotation, you should first read the chapter on annotations. Like other annotations, you specify position and size with `x`, `y`, `width` and `height`, unlike other annotations you must also specify a file object. The file object may contain the same options as `doc.file` in the previous section with the addition of the source file or buffered data in `src`. -Here is an example of adding a file attachment annotation: +Here is an example of adding a file annotation: const file = { src: path.join(__dirname, 'example.txt'), @@ -48,6 +48,6 @@ Here is an example of adding a file attachment annotation: } const options = { Name: 'Paperclip' } - doc.fileAttachmentAnnotation(100, 100, 100, 100, file, options) + doc.fileAnnotation(100, 100, 100, 100, file, options) The annotation's appearance may be changed by setting the `Name` option to one of the three predefined icons `GraphPush`, `Paperclip` or `Push` (default value). diff --git a/docs/guide.pdf b/docs/guide.pdf index 913026d..3c1a28d 100644 Binary files a/docs/guide.pdf and b/docs/guide.pdf differ diff --git a/lib/mixins/annotations.js b/lib/mixins/annotations.js index 615b14d..4b3d9eb 100644 --- a/lib/mixins/annotations.js +++ b/lib/mixins/annotations.js @@ -129,7 +129,7 @@ export default { return this.annotate(x, y, w, h, options); }, - fileAttachmentAnnotation(x, y, w, h, file = {}, options = {}) { + fileAnnotation(x, y, w, h, file = {}, options = {}) { // create hidden file const filespec = this.file( file.src, diff --git a/tests/unit/annotations.spec.js b/tests/unit/annotations.spec.js index 598ea40..9e1bda2 100644 --- a/tests/unit/annotations.spec.js +++ b/tests/unit/annotations.spec.js @@ -101,11 +101,11 @@ describe('Annotations', () => { }); }); - describe('fileAttachmentAnnotation', () => { - test('creating a fileAttachmentAnnotation', () => { + describe('fileAnnotation', () => { + test('creating a fileAnnotation', () => { const docData = logData(document); - document.fileAttachmentAnnotation(100, 100, 20, 20, { + document.fileAnnotation(100, 100, 20, 20, { src: Buffer.from('example text'), name: 'file.txt' }); @@ -126,7 +126,7 @@ describe('Annotations', () => { test("using the file's description", () => { const docData = logData(document); - document.fileAttachmentAnnotation(100, 100, 20, 20, { + document.fileAnnotation(100, 100, 20, 20, { src: Buffer.from('example text'), name: 'file.txt', description: 'file description' @@ -149,7 +149,7 @@ describe('Annotations', () => { test("overriding the file's description", () => { const docData = logData(document); - document.fileAttachmentAnnotation( + document.fileAnnotation( 100, 100, 20,