From a02ae98737efbf3fe7d6ae9314caede6ed71db3e Mon Sep 17 00:00:00 2001 From: Libor M Date: Sun, 24 Mar 2019 13:37:26 +0100 Subject: [PATCH] add simple docs --- docs/annotations.md | 4 ++++ docs/getting_started.md | 24 ++++++++++++++++++++++++ docs/images.md | 3 +++ docs/text.md | 2 ++ 4 files changed, 33 insertions(+) diff --git a/docs/annotations.md b/docs/annotations.md index e4ddc94..5443d0d 100644 --- a/docs/annotations.md +++ b/docs/annotations.md @@ -8,6 +8,7 @@ and some other properties. Here is a list of the available annotation methods: * `note(x, y, width, height, contents, options)` * `link(x, y, width, height, url, options)` +* `goTo(x, y, w, h, name, options)` * `highlight(x, y, width, height, options)` * `underline(x, y, width, height, options)` * `strike(x, y, width, height, options)` @@ -61,6 +62,9 @@ Here is an example that uses a few of the annotation types. .strike(20, doc.y, doc.widthOfString('STRIKE!'), height) .text('STRIKE!'); + // Adding go to as annotation + doc.goTo(x, y, w, h, 'LINK', options); + The output of this example looks like this. ![0](images/annotations.png) diff --git a/docs/getting_started.md b/docs/getting_started.md index f808ca0..58c9f2d 100644 --- a/docs/getting_started.md +++ b/docs/getting_started.md @@ -194,6 +194,30 @@ capitalized. - `CreationDate` - the date the document was created (added automatically by PDFKit) - `ModDate` - the date the document was last modified +## Destination + +Anchor may specify a destination by `addNamedDestination(name, ...args)`, which consists of a page, the location of the display window on that page, and the zoom factor to use when displaying that page. + +Examples: + + // Insert anchor for current page + doc.addNamedDestination('LINK'); + + // Insert anchor for current page with only horizontal magnified to fit where vertical top is 100 + doc.addNamedDestination('LINK', 'FitH', 100); + + // Insert anchor to display a portion of the current page, 1/2 inch in from the top and left and zoomed 50% + doc.addNamedDestination('LINK', 'XYZ', 36, 36, 50); + + // Insert anchor for this text + doc.text('End of paragraph', { destination: 'ENDP' }); + + // Go to annotation + doc.text('Another goto', 20, 0, { + goTo: 'ENDP', + underline: true + }); + ## Encryption and Access Privileges PDF specification allow you to encrypt the PDF file and require a password when opening the file, diff --git a/docs/images.md b/docs/images.md index 977cdb1..d95676b 100644 --- a/docs/images.md +++ b/docs/images.md @@ -14,6 +14,9 @@ be scaled according to the following options. * `scale` factor provided - image is scaled proportionally by the provided scale factor * `fit` array provided - image is scaled proportionally to fit within the passed width and height * `cover` array provided - image is scaled proportionally to completely cover the rectangle defined by the passed width and height +* `link` - a URL to link this image to (shortcut to create an annotation) +* `goTo` - go to anchor (shortcut to create an annotation) +* `destination` - create anchor to this image When a `fit` or `cover` array is provided, PDFKit accepts these additional options: diff --git a/docs/text.md b/docs/text.md index da93555..134c702 100644 --- a/docs/text.md +++ b/docs/text.md @@ -97,6 +97,8 @@ below. * `fill` - whether to fill the text (`true` by default) * `stroke` - whether to stroke the text * `link` - a URL to link this text to (shortcut to create an annotation) +* `goTo` - go to anchor (shortcut to create an annotation) +* `destination` - create anchor to this text * `underline` - whether to underline the text * `strike` - whether to strike out the text * `oblique` - whether to slant the text (angle in degrees or `true`)