questions on signature and callback on fonctions (PDF Viewer)

Hey,

I try to integrate the PDF Viewer on my website, but i have some questions please :


- Can we only show the Draw tab and hide the Type and Upload tabs on the handwritten signature popup ? (Or custom the function that shows the popup to dynamically remove these)

- we do some treatments on server site at download but can we use this download to get and load the result on the pdf viewer in callback ?

- more generally, can we override the functions on client side (download, print...etc)


Thanks you


1 Reply

SK Shamini Kiruba Sobers Syncfusion Team February 9, 2022 01:32 PM UTC

Hi LAURENT, 

Query 
Response 
Can we only show the Draw tab and hide the Type and Upload tabs on the handwritten signature popup ? (Or custom the function that shows the popup to dynamically remove these) 
Kindly refer to the below documentation on “How to configure the required signature options in PDF Viewer?” and let us know if it helps. 
we do some treatments on server site at download but can we use this download to get and load the result on the pdf viewer in callback ? 
Yes, you can. Please refer to the below sample and code snippet. 


Code snippet for client-side: 

<button onclick="saveDocument()">Save Document</button> 
<button onclick="loadDocument()">Load Document</button> 
 
<script> 
    function saveDocument() { 
        var viewer = document.getElementById('pdfviewer1').ej2_instances[0]; 
        viewer.serverActionSettings.download = "SaveDocument"; 
        viewer.download(); 
        viewer.serverActionSettings.download = "Download"; 
    } 
    function loadDocument() { 
        var viewer = document.getElementById('pdfviewer1').ej2_instances[0]; 
        viewer.load("output.pdf", null) 
    } 
</script> 

Code snippet for server-side: 

[AcceptVerbs("Post")] 
[HttpPost] 
[Route("api/[controller]/SaveDocument")] 
public ActionResult SaveDocument([FromBody] Dictionary<string, string> jsonObject) 
{ 
    PdfRenderer pdfviewer = new PdfRenderer(_cache); 
    string documentBase = pdfviewer.GetDocumentAsBase64(jsonObject); 
    string base64String = documentBase.Split(new string[] { "data:application/pdf;base64," }, StringSplitOptions.None)[1]; 
    if (base64String != null || base64String != string.Empty) 
    { 
        byte[] byteArray = Convert.FromBase64String(base64String); 
 
        MemoryStream ms = new MemoryStream(byteArray); 
        var path = _hostingEnvironment.WebRootPath + @"/Data/"; 
        System.IO.File.WriteAllBytes(path + "/output.pdf", byteArray); 
    } 
    return Content(string.Empty); 
} 



more generally, can we override the functions on client side (download, print...etc) 
We are unable to understand your query. Kindly let us know if you want to override the server actions Download, Print,..etc., to perform a different action on clicking on those options in the Viewer. 

Regards, 
Shamini 


Loader.
Up arrow icon