- Home
- Forum
- JavaScript - EJ 2
- Server side code to handle SystemClipboard
Server side code to handle SystemClipboard
Hi, I am using the JS Document Editor and want to activate/allow Copy & Paste of text from a client running program into the Syncfusion Document Editor. I found that I need an ASHX to realize this. I have such ASHX already. I added below code (CoPilot) for this but Visual Studio reports errors on the lines with remark #1423. All errors are that method or property doesn't exist.
(Sorry, its Visual Basic, I am already somewhat older.)
Can anyone supply the correct lines?
````
Imports Newtonsoft.Json
Imports Syncfusion.EJ2.DocumentEditor
````
````
Case "SystemClipboard"
' new paste-action
Dim htmlContent As String = context.Request.Form("content")
' HTML to DOCX fragment
Dim document As New WordDocument()
document.XHTMLValidateOption = XHTMLValidationType.None '#1423
document.InsertXHTML(htmlContent) '#1423
' Important: DocumentEditor expects JSON, not DOCX-file
Dim json As String = Newtonsoft.Json.JsonConvert.SerializeObject(document)
document.Close() '#1423
context.Response.ContentType = "application/json"
context.Response.Write(json)
````
Hi Adrianus ,
Based on the provided details, we suspect that the DocIo imports are not referred properly. Refr to the below Github Examples and import the DocIo and Document Editor references properly.
System Clipboard: https://github.com/SyncfusionExamples/EJ2-Document-Editor-Web-Services/blob/master/ASP.NET%20Core/src/Controllers/DocumentEditorController.cs
Refer to the below link to implement the SystemClipboard web service method for pasting
Github Examples: https://github.com/SyncfusionExamples/EJ2-Document-Editor-Web-Services/tree/master/ASP.NET%20Core
Documentation:
Web services in Document Editor
How
to create web service project
Copy and Paste in JavaScript DocumentEditor
Please try with the provided details and revert with the sample project in which you are using and more details about the issue. These will be helpful for us to investigate more on your issue and assist you with prompt solution.
Regards,
Akshaya
Good info
It was solved with this code in our DocumentHandler.ashx.vb (selective lines only):
Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
Dim Response = context.Response
' Handle action
Select context.Request.HttpMethod
Case WebRequestMethods.Http.Post :
Dim action As String = context.Request.Form("action")
Select Case action
Case "SystemClipboard"
' 1. Read the body and pick up its bytes (JSON or raw)
Dim BYTS As Byte() = funExtractBytesFromRequest()
' 2. Determine format automatically (DOCX/RTF/HTML/TXT)
Dim FORMAT As FormatType = funDetectedFormat(BYTS)
' 3. Load document in a safe manner
Dim myDOC As Syncfusion.EJ2.DocumentEditor.WordDocument = funLoadDocumentSafe(BYTS, FORMAT)
' 4. Convert into SFDT‑JSON
Dim SFDT As String = JsonConvert.SerializeObject(myDOC)
context.Response.ContentType = "application/json"
context.Response.Write(SFDT)
myDOC.Dispose
Exit Sub
End Select
End Select
End sub
Hi Adrianus ,
Thank you for your update. We are glad to know that the reported issue is resolved. Please reach out if need any further assistance.
Regards,
Akshaya
- 4 Replies
- 3 Participants
-
AP Adrianus PJM Van Geel at TwoAgree
- Nov 18, 2025 10:25 AM UTC
- Jan 27, 2026 09:02 AM UTC