MarvinKlein1508 / SignaturePad

A simple to use blazor component to draw custom signatures.
MIT License
72 stars 12 forks source link

Printing Signatures - addEventListener Error #32

Closed Rachel-Phillips closed 4 days ago

Rachel-Phillips commented 4 days ago

Good morning,

I've been using signature pad to allow users to sign and save their signature and I'm now trying to let them print the signature or save it to a PDF. After the printing popup they can press save but then it throws the following error

Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost[111] Unhandled exception in circuit 'XWub88RAP4m_7-y_G1_SSeCgBN7CGThqCLdRmSaJ_Ic'. Microsoft.JSInterop.JSException: can't access property "addEventListener", element is null setup@https://localhost:5001/_content/Blazor.SignaturePad/sigpad.interop.js:9:5 beginInvokeJSFromDotNet/i<@https://localhost:5001/_framework/blazor.server.js:1:3506 beginInvokeJSFromDotNet@https://localhost:5001/_framework/blazor.server.js:1:3480 _invokeClientMethod@https://localhost:5001/_framework/blazor.server.js:1:75072 _processIncomingData@https://localhost:5001/_framework/blazor.server.js:1:72696 Ft/this.connection.onreceive@https://localhost:5001/_framework/blazor.server.js:1:67009 connect/</i.onmessage@https://localhost:5001/_framework/blazor.server.js:1:51322 at Microsoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64 targetInstanceId, String identifier, Object[] args) at Microsoft.JSInterop.JSObjectReferenceExtensions.InvokeVoidAsync(IJSObjectReference jsObjectReference, String identifier, Object[] args) at SignaturePad.SignaturePad.Setup() at SignaturePad.SignaturePad.OnAfterRenderAsync(Boolean firstRender) at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)

I'm not sure if printing/saving to PDF is an option with these signature pads and I'm approaching it wrong or if the functionality isn't there yet? I'm using
await JS.InvokeVoidAsync("window.print"); to print/save the page.

MarvinKlein1508 commented 4 days ago

Hi @Rachel-Phillips

Printing works fine for me. Can you maybe share a minimal repository and steps to repeat the situation?

Thanks! :)

Rachel-Phillips commented 4 days ago

@MarvinKlein1508 closing the issue, i found my issue and it was with the rendering of the page and trying to print before everything was rendered, thank you for the quick response and willingness to help though!