I need to determine the number of pages in a specified PDF file using C# code (.NET 2.0). The PDF file will be read from the file system, and not from an URL. Does anyone have any idea on how this could be done? Note: Adobe Acrobat Reader is installed on the PC where this check will be carried out.
In Adobe Acrobat Pro, go to file > create PDF > merge files into a single PDF. Then add files and select the files you want. Click combine, and see how many pages are in the final PDF.
The R package pdftools and the function pdf_info() provides information on the number of pages in a pdf.
If you go file>open recent. A list containing your last 9 files will display and you can choose from there the one you want to open, or you can also click "history" and search files you opened today, yesterday 14 days ago, etc. Hope this helps.
Right-click on your PDFs in Windows File Explorer and select the menu option 'Make Secure PDF' to invoke Safeguard Secure PDF Writer. In Safeguard Enterprise Secure PDF Writer, go to the Printing & Viewing tab: To track PDF opens, check the box 'log document views'
You'll need a PDF API for C#. iTextSharp is one possible API, though better ones might exist.
iTextSharp Example
You must install iTextSharp.dll as a reference. Download iTextsharp from SourceForge.net This is a complete working program using a console application.
using System; using System.Collections.Generic; using System.Linq; using System.Text; using iTextSharp.text.pdf; using iTextSharp.text.xml; namespace GetPages_PDF { class Program { static void Main(string[] args) { // Right side of equation is location of YOUR pdf file string ppath = "C:\\aworking\\Hawkins.pdf"; PdfReader pdfReader = new PdfReader(ppath); int numberOfPages = pdfReader.NumberOfPages; Console.WriteLine(numberOfPages); Console.ReadLine(); } } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With