mirror of
https://github.com/foliojs/pdfkit.git
synced 2025-12-08 20:15:54 +00:00
Merge pull request #1013 from HughePaul/patch-1
Allow removing link annotation in continued text
This commit is contained in:
commit
4a64e94c3a
@ -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
|
||||
|
||||
|
||||
BIN
docs/guide.pdf
BIN
docs/guide.pdf
Binary file not shown.
23
docs/text.md
23
docs/text.md
@ -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:
|
||||
|
||||

|
||||

|
||||
|
||||
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
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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`
|
||||
]);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user