-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix getBoundingBoxByChildren function Do not use dummy (all 0) bounding box when search bonding box for all children. Otherwise minimal values always will be 0. Also take into account transformation attributes of child node - it may differ from child to child. Apply scale and translation, but not rotation yet * Provide bounding box for plain text - without tspan While `a` element typically used together with text, one need to have estimation of bounding box for text. To avoid reimplementation of complete text rendering logic just remember text position and sizes as bounding box. Implemented only for plain text, any usage of tspan will not work properly * Introduce Anchor class It derives from Group class and uses same rendering. Plus if `href` attribute specified - adds link with bounding box. Requires usage of scale and page height values - otherwise created link area does not match drawn text * Add test for the anchor element This test also can be used to demonstrate missing support of dominant-baseline attribute of the text * Update some other refs Changes because of new implementation of bounding box
- Loading branch information
Showing
12 changed files
with
73 additions
and
3 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,19 @@ | ||
import { Group } from './group' | ||
import { Context } from '../context/context' | ||
import { getAttribute } from '../utils/node' | ||
|
||
export class Anchor extends Group { | ||
protected async renderCore(context: Context): Promise<void> { | ||
await super.renderCore(context) | ||
|
||
const href = getAttribute(this.element, context.styleSheets, 'href') | ||
if (href) { | ||
const box = this.getBoundingBox(context) | ||
const scale = context.pdf.internal.scaleFactor | ||
const ph = context.pdf.internal.pageSize.getHeight() | ||
|
||
context.pdf.link(scale*(box[0] * context.transform.sx + context.transform.tx), | ||
ph - scale*(box[1] * context.transform.sy + context.transform.ty), scale*box[2], scale*box[3], { url: href }) | ||
} | ||
} | ||
} |
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
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
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
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
window.tests = [ | ||
'anchor', | ||
'attribute-style-precedence', | ||
'clippath', | ||
'clippath-empty', | ||
|
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.