Merge pull request #1013 from HughePaul/patch-1

Allow removing link annotation in continued text
This commit is contained in:
Luiz Américo 2019-09-02 19:15:49 -03:00 committed by GitHub
commit 4a64e94c3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 88 additions and 2 deletions

View File

@ -2,6 +2,7 @@
### Unreleased
- Fix infinite loop when text is positioned after page right margin
- Allow links in continued text to be stopped by setting link to null
### [v0.10.0] - 2019-06-06

Binary file not shown.

View File

@ -166,6 +166,27 @@ Here is the output:
![4]()
To cancel a link in rich text set the `link` option to `null`.
doc.fillColor('red')
.text(lorem.slice(0, 199), {
width: 465,
continued: true
})
.fillColor('blue')
.text(lorem.slice(199, 282), {
link: 'http://www.example.com',
continued: true
})
.fillColor('green')
.text(lorem.slice(182, 400), {
link: null
});
Here is the output:
![5]()
## Fonts
The PDF format defines 14 standard fonts that can be used in PDF documents. PDFKit supports each of them out of the box.
@ -219,7 +240,7 @@ Here is an example showing how to set the font in each case.
The output of this example looks like this:
![5](images/fonts.png)
![6](images/fonts.png)
Another nice feature of the PDFKit font support, is the ability to register a
font file under a name for use later rather than entering the path to the font

View File

@ -200,7 +200,7 @@ export default {
for (let key in this._textOptions) {
const val = this._textOptions[key];
if (key !== 'continued') {
if (result[key] == null) {
if (result[key] === undefined) {
result[key] = val;
}
}

View File

@ -32,5 +32,69 @@ describe('Annotations', () => {
>>`
]);
});
test('using url', () => {
document.addPage();
const docData = logData(document);
document.text('Go to url', { link: 'http://www.example.com' });
expect(docData).toContainChunk([
`11 0 obj`,
`<<
/S /URI
/URI (http://www.example.com)
>>`
]);
});
test('using url on continue', () => {
document.addPage();
const docData = logData(document);
document.text('Go to url', { link: 'http://www.example.com', continued: true });
document.text('continued link');
expect(docData).toContainChunk([
`11 0 obj`,
`<<
/S /URI
/URI (http://www.example.com)
>>`
]);
expect(docData).toContainChunk([
`14 0 obj`,
`<<
/S /URI
/URI (http://www.example.com)
>>`
]);
});
test('using url on continue', () => {
document.addPage();
const docData = logData(document);
document.text('Go to url', { link: 'http://www.example.com', continued: true });
document.text('no continued link', { link: null });
// console.log(docData);
expect(docData).toContainChunk([
`11 0 obj`,
`<<
/S /URI
/URI (http://www.example.com)
>>`
]);
expect(docData).not.toContainChunk([
`14 0 obj`
]);
});
});
});