We're sorry AsposeCloud doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.cloud

How to Count PDF Pages in Node.js using Aspose.PDF REST API?

First your customer support is appreciated.

But disappointed because of aspose cloud api documentation. I’m not able to call any services by directly using aspose pdf api.

for example: 1st I try to upload the document using pdf split api in doc line no 31, now I’m trying to get the pdf page count using pdfApi.GetPages() as I am not getting any ‘GetPages()’

For code reference please see by previous code pasted in the forum.

It would be great If you try to update your api code document with the latest as I’m working on one project & I updraded my account but unhappy yo use your api due to bad documentation

@skp1992

We are truly sorry for the inconvenience. Please find below a sample code to count PDF pages in Node.js.

About the documentation issue, we have recently upgraded your API and we are in process of updating the documentation with high priority. Meanwhile, you may check unit tests for reference. And feel free to contact us for any assistance.

How to Count PDF Pages in Node.js

const { PdfApi } = require("asposepdfcloud");

// Initialize Aspose.PDF Cloud API
pdfApi = new PdfApi("xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx", "xxxxxxxxxxxxxxxxxxx");

const name = "02_pages.pdf";
const remoteTempFolder = "Temp";

// Count PDF pages
pdfApi.getPages(name, null, remoteTempFolder).then((result) => {    
    console.log("Pages Count :", result.body.pages.list.length);    			    
}).catch(function(err) {
    // Deal with an error
    console.log(err);
});

Hi I used your code but not getting page count

See my below code snippet

const dir_path = “C:/Users/Sushilkumar/Documents/Projects/react/upload/uploads/2022-02-08T11-09-53.984Z-2.1 SEO Victory.pdf”
const rest = “C:/Users/Sushilkumar/Documents/Projects/react/upload/uploads/”
const last = “2022-02-08T11-09-53.984Z-2.1 SEO Victory.pdf”

const localFile = last;
const remoteFile= last;
const localDataFolder = rest;
const remoteFolder = “Temp/Temp/”;
const format = “pdf”;

// Count PDF pages
pdfApi.getPages(remoteFile, null, remoteFolder).then((result) => {
console.log(“Pages Count :”, result.body.pages.list.length);
}).catch(function(err) {
// Deal with an error
console.log(err);
});

@skp1992

The sample code is working fine at my end. Can you please share some more details/error details? We will look into it and will guide you accordingly.