mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-19 22:58:07 +02:00
Merge pull request #18972 from calixteman/refactor_highlight
[Editor] Refactor the free highlight stuff in order to be able to use the code for more general drawing
This commit is contained in:
commit
f142fb8c28
7 changed files with 633 additions and 476 deletions
|
@ -25,7 +25,7 @@ const {
|
|||
TextLayer,
|
||||
XfaLayer,
|
||||
} = pdfjsLib;
|
||||
const { Outliner } = pdfjsTestingUtils;
|
||||
const { HighlightOutliner } = pdfjsTestingUtils;
|
||||
const { GenericL10n, parseQueryString, SimpleLinkService } = pdfjsViewer;
|
||||
|
||||
const WAITING_TIME = 100; // ms
|
||||
|
@ -370,19 +370,19 @@ class Rasterize {
|
|||
}
|
||||
// We set the borderWidth to 0.001 to slighly increase the size of the
|
||||
// boxes so that they can be merged together.
|
||||
const outliner = new Outliner(boxes, /* borderWidth = */ 0.001);
|
||||
const outliner = new HighlightOutliner(boxes, /* borderWidth = */ 0.001);
|
||||
// We set the borderWidth to 0.0025 in order to have an outline which is
|
||||
// slightly bigger than the highlight itself.
|
||||
// We must add an inner margin to avoid to have a partial outline.
|
||||
const outlinerForOutline = new Outliner(
|
||||
const outlinerForOutline = new HighlightOutliner(
|
||||
boxes,
|
||||
/* borderWidth = */ 0.0025,
|
||||
/* innerMargin = */ 0.001
|
||||
);
|
||||
const drawLayer = new DrawLayer({ pageIndex: 0 });
|
||||
drawLayer.setParent(div);
|
||||
drawLayer.highlight(outliner.getOutlines(), "orange", 0.4);
|
||||
drawLayer.highlightOutline(outlinerForOutline.getOutlines());
|
||||
drawLayer.draw(outliner.getOutlines(), "orange", 0.4);
|
||||
drawLayer.drawOutline(outlinerForOutline.getOutlines());
|
||||
|
||||
svg.append(foreignObject);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue