Several Questions

158 views
Skip to first unread message

Scott Griswold

unread,
Aug 18, 2015, 12:41:48 PM8/18/15
to PDFTron WebViewer
I have a couple of questions regarding the Webviewer product:

1. I am rendering in the WewViewer the GettingStarted.xod file as a stream using Microsoft Wep API based on a sample project I found from a support forum question. When I run the project (a basic web project in Visual Studio) the page appears to render correctly. I then created a config.js file as per instructions in the documentation and put in the following code (from one of your samples)

try {
$(document).on('documentLoaded', function () {

var annotManager = readerControl.docViewer.getAnnotationManager();

var stampAnnot = new Annotations.StampAnnotation();
stampAnnot.PageNumber = 1;
stampAnnot.X = 100;
stampAnnot.Y = 250;
stampAnnot.Width = 275;
stampAnnot.Height = 40;
stampAnnot.Author = annotManager.getCurrentUser();
stampAnnot.ImageData = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAARMAAAAoCAMAAADqve5QAAAABGdBTUEAALGPC/xhBQAAAwBQTFRFAAAABgoCFyIJdNp+et17ft95fd56Fp7ZGZ/ZGJ/aGqDaHKDZHqDaH6LaH6LbLqzCLKzDIKLaIaPbJqTbLKbcMK3CMq7CNK/CNKrdOq3fPK7fNbDCNbDDOLDCOLHDOrLDPLPEQLTDQrbDTLrDUbzEY86PZc+OYs6QZ9COZdCPadGNaNCOatKNbNKMbNONbtSMctaKcNWMdNeKdtiJedqHfNuHftyGeNmIeNmJetqIccrFj+hvg+J2huN1hOJ2h+R0guF4ieVzi+ZyiOV0jOZyjuV/juhwkOlvkupvluxrlexsmO1qmu9ome5pkOZ+kOZ/lul7l+p6lOh8ne12n+51nu52mOp6mux4nOx4m/Bnn/JjnvFlnPBmnPBnr/9Ho/Vfp/dap/dbpPVepvZcpfZdp/haq/tTqflWqflXq/pUqvpVrPtRrPtSrPtTqPhYqPhZqPhaoe90oO91ofNioPJjo/RgovRho/FyovBzgN2Ggt6Egd6FgN6GhN+Eh+GCheCDhOCEiOGCiOGDi+OAieKBiOKCjOOBjeSAjOSBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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f4/i63C0n6LE52Vb5jfF0SEtqmc/5dvq2MyX2uXd5jBPdqsNyevFSq0sTTmJJydOTY3ciWNsK3OzJG5wvxHz+BMGxa5wT/aD4QA+O1Qnrx6fdv+DE48qA1uI54QvhSRWCTqLjnASOLhUMf445RidsWOy5FU07eQVlQSeC3wq5lLc8SiecT2etG14nNULH9rFO+KJ+L0jcYQqPc+LajiQ84vf/XblCnX5ScAlBh3IyhdvyOameVkVyhQxTnf19xE3RaerctrCkog3ucL60b85b6SQ06EQsU0XSwrLj+PuIIOBk5VeJbbesQFAQ+Xb0gaBVZJNBsH+juBYtClALDNvPKtoQvgO0EO6loHb9+tP92bLxJwg4aSFpOYniOWn9j18Q73/8WgRpa/sH7XudZrSTXU0AAAAASUVORK5CYII=';

annotManager.addAnnotation(stampAnnot);
annotManager.drawAnnotations(stampAnnot.PageNumber);
});
}
catch (err) {
console.log(err.message);
}

The code appears to render the custom stamp correctly. I then attempted to hide the control bar using sample code I found:

ReaderControl.config.ui.hideControlBar = true;

When I ran the project the file was rendered, but blurred. The custom stamp did not appear to render. What might I be doing wrong?

2. In your documentation a save button is mentioned. Is this shown by default when a document is rendered? If so, can you direct me to where it is?
3. When you create a signature using the signature annotation tool you can save that signature annotation as default and it will show in the menu as My signature. How would you save this signature and have it return the next time that users views a document. Can the menu item be changed?

4. After loading a document and putting a custom button on the menu bar I tried to run code using the myWebViewer variable I created to initialize the viewer. That variable is not available in the click event of the button. I thought it might be because the sample config.js file is a self-invoked anonymous function, but changing that did not have any effect. What might I be doing wrong

Scott

Matt Bojey

unread,
Aug 18, 2015, 2:12:53 PM8/18/15
to PDFTron WebViewer
  1. Unfortunately we are not able to reproduce this issue, where did you put the  
    ReaderControl.config.ui.hideControlBar = true;
     code? Are you able to reproduce the issue on a version of WebViewer without any other customizations?
  2. The save button is in the right panel in the dropdown menu from the caret in the top right corner, see attached.
  3. To do this you can catch the signature when it is made the default, write it to your server, and reload it as the default when the user returns to the viewer.  This post may be helpful with sending and retrieving the annotation to and from your server.  This can be done in the config.js file like this,
$(document).on('documentLoaded', function () {

   
var signatureTool = readerControl.toolModeMap['AnnotationCreateSignature'];
   
//This will catch the signature when it is added as the default
    $
(signatureTool ).on('saveDefault', function(event, paths){
        yourFunctionToSaveToServer
(paths);
   
});
   
var signatureFromServer = yourFunctionToRetrieveFromServer();
    signatureTool.initDefaultSignature(signatureFromServer);
});
    4.  For this the customization sample should be helpful, it can be found in the samples folder of your WebViewer download under customization.
SaveButton.png
Reply all
Reply to author
Forward
0 new messages