Print Comments Help

161 views
Skip to first unread message

Jack Brown

unread,
Nov 13, 2014, 2:23:21 PM11/13/14
to pdfnet-w...@googlegroups.com
I am having trouble trying to print documents with annotations on them. I am currently using the PDFTron cloud service to host documents. I click the print button on a document on my site and nothing prints at all but the highlights where the annotations are. How do I get the annotations to print too? How will they print exactly on paper? On the side? And how can I modify the URL that is displayed as well to say just my domain name instead of what it does by default --> www.example.com/hmtl5/ReaderControl.php etc etc. <--- It gives a long and ugly URL which I don't like and doesn't look good.

Matt Parizeau

unread,
Nov 14, 2014, 1:11:10 PM11/14/14
to pdfnet-w...@googlegroups.com
Are you referring to printing the annotation popup notes? The annotations themselves should be printing (try testing on https://www.pdftron.com/webviewer/showcase/) however popup notes will not be printed. If you want to print a summary of the notes refer to this example https://groups.google.com/forum/#!msg/pdfnet-webviewer/Hnw7-Wh1Tc4/JR1E8lhcvPsJ. Chrome's print preview will give you a good preview of what it will look like on paper.

If you want to change what the URL looks like you could try using window.history.replaceState. For example:
window.history.replaceState({}, window.document.title, '/my-new-path')
This should be on the outer page where you create new PDFTron.WebViewer not in the config file.

Matt Parizeau
Software Developer
PDFTron Systems Inc.

Jack Brown

unread,
Nov 14, 2014, 3:29:50 PM11/14/14
to
Amazing Matt it all worked! And one last question, how can I get the annotation summaries to also show the dates and a numbering pagination of sorts like (annotation 1, 2, etc.) what is the code to add to the current working code like you did here? --> https://groups.google.com/forum/#!msg/pdfnet-webviewer/Hnw7-Wh1Tc4/JR1E8lhcvPsJ
And how can I space out each annotation in the summaries?

And in chrome it prints my site's URL immediately correct without me using this --->
window.history.replaceState({}, window.document.title, '/my-new-path')

But for some reason in Firefox it still prints the ugly URL. Am I putting it in the wrong space? Here's my code below

<script type='text/javascript'> sv1(function() { var viewerElement = document.getElementById('viewer'); var myWebViewer = new PDFTron.WebViewer({ type: 'html5', mobileRedirect: false, path: '/lib', config: '/lib/config.js', serverUrl: '/lib/html5/annotationHandler.php', enableAnnotations: true, annotationUser: 'by: guest', streaming: false, showToolbarControl: true, }, viewerElement); $(viewerElement).bind('documentLoaded', function(event){ myWebViewer.setZoomLevel(1); }); }); window.history.replaceState({}, window.document.title, '/my-new-path') </script>

And I've been wanting to ask one last thing for a while, it's pretty simple. How do I get the Webviewer to "automatically" display at a certain percentage? Like 80%?

Matt Parizeau

unread,
Nov 17, 2014, 1:26:52 PM11/17/14
to pdfnet-w...@googlegroups.com
From that sample code each page is followed by the list of annotations on the page so it is already paginated in that sense. If you want numbers beside each annotation then you could just use the second parameter of forEach that is the index. For example 
pageNotes.forEach(function(annot, index) {
    noteTextContainer
.append('<div>' + (index + 1) + '. ' + annot.Subject + ' (' + annot.Author + '): ' + annot.getContents() + '</div>');
});

To show dates you can just add in the annot.DateCreated property. To add more spacing between entries just add styles for the margin to the divs since they're just normal DOM elements.

I'm not sure why it wouldn't be working in FireFox for you. As a test I added that code to the webviewer-controls sample included in the WebViewer download package and it worked fine in the latest Chrome, FireFox and IE.

This post shows how to set the zoom level: https://groups.google.com/d/msg/pdfnet-webviewer/EEcbtIPtLgA/8k23as-muf8J

Matt Parizeau
Software Developer
PDFTron Systems Inc.


On Friday, November 14, 2014 12:29:50 PM UTC-8, Jack Brown wrote:
Amazing Matt it all worked! And one last question, how can I get the annotation summaries to also show the dates and a numbering pagination of sorts like (annotation 1, 2, etc.) what is the code to add to the current working code like you did here? --> https://groups.google.com/forum/#!msg/pdfnet-webviewer/Hnw7-Wh1Tc4/JR1E8lhcvPsJ
And how can I space out each annotation in the summaries?

And in chrome it prints my site's URL immediately correct without me using this --->
window.history.replaceState({}, window.document.title, '/my-new-path')

But for some reason in Firefox it still prints the ugly URL. Am I putting it in the wrong space? Here's my code below

<script type='text/javascript'> sv1(function() { var viewerElement = document.getElementById('viewer'); var myWebViewer = new PDFTron.WebViewer({ type: 'html5', mobileRedirect: false, path: '/lib', config: '/lib/config.js', serverUrl: '/lib/html5/annotationHandler.php', enableAnnotations: true, annotationUser: 'by: guest', streaming: false, showToolbarControl: true, }, viewerElement); $(viewerElement).bind('documentLoaded', function(event){ myWebViewer.setZoomLevel(1); }); }); window.history.replaceState({}, window.document.title, '/my-new-path') </script>

And I've been wanting to ask one last thing for a while, it's pretty simple. How do I get the Webviewer to "automatically" display at a certain percentage? Like 80%?

On Friday, November 14, 2014 12:11:10 PM UTC-6, Matt Parizeau wrote:

Jack Brown

unread,
Nov 18, 2014, 12:12:44 AM11/18/14
to pdfnet-w...@googlegroups.com
Once again Matt you continue to amaze me. Thank you for your help. Also have you guys deprecated hidePrint? I tried adding hidePrint: true in my code below and it didn't work. I want to have it working in the code below because it is crucial for my application.


<script type='text/javascript'> sv1(function() { var viewerElement = document.getElementById('
viewer'); var myWebViewer = new PDFTron.WebViewer({ type: 'html5', mobileRedirect: false, path: '/lib', config: '/lib/config.js', serverUrl: '/lib/html5/annotationHandler.php', enableAnnotations: true, annotationUser: 'by: guest', streaming: false, showToolbarControl: true, }, viewerElement); $(viewerElement).bind('documentLoaded', function(event){ myWebViewer.setZoomLevel(1); }); });  </script>

Matt Parizeau

unread,
Nov 18, 2014, 1:09:14 PM11/18/14
to pdfnet-w...@googlegroups.com
I don't see anywhere where you've tried to use hidePrint in the code you pasted, however the place to do this is in ReaderControlConfig.js. Find that file and you'll see ReaderControl.config.ui where you can set hidePrint: true.

Matt Parizeau
Software Developer
PDFTron Systems Inc.

Jack Brown

unread,
Nov 18, 2014, 1:40:20 PM11/18/14
to pdfnet-w...@googlegroups.com
Can I only use hidePrint in ReaderControlConfig.js or will it work if I use it in my code like...


<script type='text/javascript'> sv1(function() { var viewerElement = document.getElementById('
viewer'); var myWebViewer = new PDFTron.WebViewer({ type: 'html5', mobileRedirect: false, path: '/lib', config: '/lib/config.js', serverUrl: '/lib/html5/annotationHandler.php', enableAnnotations: true, annotationUser: 'by: guest', streaming: false, showToolbarControl: true, hidePrint: true }, viewerElement); $(viewerElement).bind('documentLoaded', function(event){  }); });  </script>

Matt Parizeau

unread,
Nov 18, 2014, 8:11:48 PM11/18/14
to pdfnet-w...@googlegroups.com
It can't be passed through the WebViewer constructor, you need to use it from ReaderControlConfig.js.
Reply all
Reply to author
Forward
0 new messages