This content has been marked as final.
Show 2 replies
-
1. Re: How to Count the total number of pages in PDF attachment ?
radzmar Oct 22, 2014 11:55 AM (in response to Harshit_Pandey)Hi,
you have to open each attachment to determine its page count.
Here's a script you can use in a button event.
var that = event.target, pageCount = 0, isPDF = 0, attmt = that.dataObjects, attmtPath = "", attmtDoc; if (attmt !== null) { for (var i = 0, j = attmt.length; i < j; i += 1) { if (attmt[i].MIMEType === "application/pdf") { isPDF += 1; attmtDoc = that.openDataObject(attmt[i].name); pageCount += attmtDoc.numPages; attmtDoc.closeDoc(); } } if (isPDF === 0) { xfa.host.messageBox("There are file attached to this file, but none is a PDF.", "No PDF found", 0, 0); } else { xfa.host.messageBox("There " + (isPDF === 1 ? "is ":"are ") + isPDF.toString() + (isPDF === 1 ? " PDF file ":" PDF files ") + "attached to this file.\nThe total page count is: " + pageCount + " pages.", "Page Count of attached PDFs", 0, 0); } } else { xfa.host.messageBox("No files attached to this file.", "No attachments found", 0, 0); } -
2. Re: How to Count the total number of pages in PDF attachment ?
Harshit_Pandey Nov 5, 2014 8:53 PM (in response to radzmar)Thanks Radzmar,
The code is working fine. we are able to get the total number of pages through this code.
But, the pdf is getting crashed because of closeDoc() function.
Please help.
Thanks in advance

