You are viewing limited content. For full access, please sign in.

Question

Question

Is it possible to embed a certain page range to the weblink URL?

asked on February 12, 2016 Show version history

I am looking to embed the page range option into the weblink URL, so that users are able to directly download a set range when working with large files.

 

0 0

Replies

replied on February 16, 2016

Hi Tommy, 

 

To define a default page range in the WebLink Document Viewer, you can add the following JavaScript at the end of the DocViewer.aspx and change the ranges variable. This file is located under C:\Program Files\Laserfiche\WebLink\Web Files


var ranges = '1,3,5-12';
$('#PdfDialog_PdfDownloadLink').click();
$('#PdfDialog_PageRangeBox').val(ranges);

 

Hope that helps!

0 0
replied on February 19, 2016


While Min-lun's response will allow you to set the default ranges for all users it doesn't allow you to embed the range in a URL so that you can customize the range for each document using the URL.
 Building upon Ming-lun's response:

 

1. Open DocView.aspx and add the following above the closing body tag "</body>"

        <script type="text/javascript">
            function getParameterByName(p) {
                var url = window.location.href;
                p = p.replace(/[\[\]]/g, "\\$&");
                var regex = new RegExp("[?&]" + p + "(=([^&#]*)|&|#|$)"), results = regex.exec(url);
                if (!results) return null;
                if (!results[2]) return '';
                return decodeURIComponent(results[2].replace(/\+/g, " "));
            }

            var ranges = getParameterByName('pr');
            $('#PdfDialog_PdfDownloadLink').click();
            $('#PdfDialog_PageRangeBox').val(ranges);
        </script>

2. Save and close.

Now if you supply a URL without the "pr" query string parameter (page range) it will default to the "1-1" page range value. However, by providing the "pr" query string parameter such as :

http://myserver/weblink/0/doc/183289/Page1.aspx?pr=1,3,4-8

will result in setting the ranges variable with 1,3,4-8.

 

Credit for inspiration (http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript/901144#901144 )

 

Wes

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.