1. Home
  2. Foxit PDF SDK for Web
  3. How to Show the First Third of a PDF with Foxit PDF SDK for Web

How to Show the First Third of a PDF with Foxit PDF SDK for Web


Often times you need to show just certain parts of a PDF. This is often due to a particular PDF template that a company follows with the same kinds of information in the same location. For example, a 6 page invoice where you just want to show the first 2 pages that contains the key information you’re after.

The following example will show you how to produce a PDF that shows only the first third of pages of a document in our Web-based JavaScript PDF viewer.

Code Snippet:

customs: {
 closeDocBefore: function () {
 returnconfirm('Close the current document?');
 PageCustomRender: (function () {
 function CustomPageCustomRender (eCustom, pdfPageRender) {
 this.eCustom = eCustom;
 this.pdfPageRender = pdfPageRender;
 CustomPageCustomRender.prototype.render = function () {
 var self = this;
 returnself.pdfPageRender.getPDFPage().then(function (page) {
 if(page.getIndex() > 3) {
 self.eCustom.innerHTML = 'You are not authorized to view this page.';
 CustomPageCustomRender.prototype.destroy = function () {
 this.eCustom.innerHTML = '';


When you’re done, it should look something like this:


Updated on August 25, 2020

Was this article helpful?

Related Articles

Ready to try Foxit PDF SDK?
Click the link below to download your trial
Free Trial