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 11, 2021

Was this article helpful?
Thanks for your feedback. If you have a comment on how to improve the article, you can write it here: