mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-19 14:48:08 +02:00
[Editor] (WIP) Add a new tool in order to add an handwritten signature to a pdf (bug 1942343)
This patch is adding some code in order to extract a drawing as curves from an image. The algorithm is basically the following: - reduce the dimensions - make it gray - apply a bilateral filter in order to add some blurryness while keeping the edges - compute the histogram - guess what's the background color which should contain a large majority of the pixels - make a binary image - extract the contours in using the Suzuki algorithm - apply the Douglas-Peucker algorithm in order to reduce the number of points The algorithm is improvable but it should work pretty well if there's a clear difference between the background and the drawing. In a v2 we could use a ML model in order to improve the extraction. There's few changes related to the UI in order to make the tool usable, but they're very basic for the moment.
This commit is contained in:
parent
711bf2bd12
commit
2f828c7bf4
18 changed files with 839 additions and 9 deletions
|
@ -537,6 +537,10 @@ const PDFViewerApplication = {
|
|||
typeof AbortSignal.any === "function") &&
|
||||
annotationEditorMode !== AnnotationEditorType.DISABLE
|
||||
) {
|
||||
const editorSignatureButton = appConfig.toolbar?.editorSignatureButton;
|
||||
if (editorSignatureButton && AppOptions.get("enableSignatureEditor")) {
|
||||
editorSignatureButton.parentElement.hidden = false;
|
||||
}
|
||||
this.annotationEditorParams = new AnnotationEditorParams(
|
||||
appConfig.annotationEditorParams,
|
||||
eventBus
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue