-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
+++ | ||
title = "Attachments embedding" | ||
description = "" | ||
weight = 298 | ||
alwaysopen = true | ||
+++ | ||
|
||
pdfmake supports attaching files as annotations as well as embedded files. | ||
Embedded files are added in the "files" dictionary and will show up in supported pdf viewers in their respective attachment panels. | ||
File attachments are annotations which link to a file. | ||
Any attachment or embedded file must provide at least a "src", providing a filename through "name" is highly recommended. | ||
The "src" of any attachment can be provided in dataURL format (like the following attachment, taken from http://www.clipartbest.com/clipart-dT7zx5rT9), but local files are allowed as well. | ||
|
||
```js | ||
var dd = { | ||
content: [ | ||
'Any attachment or embedded file must provide at least a "src", providing a filename through "name" is highly recommended.', | ||
'The "src" of any attachment can be provided in dataURL format (like the following attachment, taken from http://www.clipartbest.com/clipart-dT7zx5rT9), but local files are allowed as well.', | ||
{ | ||
attachment: { | ||
src: 'data:image/png;base64,iVBOR....', | ||
name: 'testImage.png' | ||
} | ||
}, | ||
'You can also define an attachment in the "attachments" dictionary and reference it by name.', | ||
{ | ||
attachment: 'sampleImage' | ||
}, | ||
'And there are three different standard icons for attachments, "GraphPush", "Paperclip", and "Push" (the default value). Set them with the "icon" option.', | ||
{ | ||
attachment: 'sampleImage', | ||
icon: 'GraphPush' | ||
}, | ||
{ | ||
attachment: 'sampleImage', | ||
icon: 'Paperclip' | ||
}, | ||
{ | ||
attachment: 'sampleImage', | ||
icon: 'Push' | ||
}, | ||
'For better customization, add an image and attach a file to it with linkToFile:', | ||
{ | ||
image: 'fonts/sampleImage.jpg', | ||
width: 150, | ||
linkToFile: 'sampleImage' | ||
}, | ||
"You can add a description, which will show in your pdf viewer's attachments panel and as a tooltip when hovering over the attachment.", | ||
{ | ||
attachment: { | ||
src: 'data:image/png;base64,iVBOR....', | ||
name: 'withDescription.png', | ||
description: 'file description' | ||
} | ||
}, | ||
'You can also define the "src" of an attachment or embedded file in the "attachments" and "files" dictionary via URL address.', | ||
], | ||
attachments: { | ||
sampleImage: { | ||
src: 'fonts/sampleImage.jpg', | ||
name: 'sampleImage.png' | ||
} | ||
}, | ||
files: { | ||
README: { | ||
src: 'https://raw.githubusercontent.com/bpampuch/pdfmake/master/README.md', | ||
name: 'pdfmake README.md' | ||
} | ||
} | ||
}; | ||
``` |