Method GetPageCount
GetPageCount(string, string)
Returns the number of pages in the PDF.
public static int GetPageCount(string inputPath, string password = "")
Parameters
inputPathstringPath to the source PDF.
passwordstringPassword for encrypted PDFs. Empty for unprotected documents.
Returns
Examples
using LMKit.Document.Pdf;
int pages = PdfRenderer.GetPageCount("report.pdf");
Console.WriteLine($"Document has {pages} page(s).");
// Encrypted file
int securedPages = PdfRenderer.GetPageCount("locked.pdf", password: "s3cret!");
GetPageCount(Stream, string, bool)
Returns the number of pages in the PDF.
public static int GetPageCount(Stream input, string password = "", bool leaveOpen = true)
Parameters
inputStreamReadable stream containing the PDF.
passwordstringPassword for encrypted PDFs.
leaveOpenboolWhen true (default), the caller keeps ownership of the stream.
Returns
Examples
using System.IO;
using LMKit.Document.Pdf;
using FileStream fs = File.OpenRead("report.pdf");
int pages = PdfRenderer.GetPageCount(fs);
Console.WriteLine($"Stream contains {pages} page(s).");
GetPageCount(byte[], string)
Returns the number of pages in the PDF.
public static int GetPageCount(byte[] data, string password = "")
Parameters
Returns
Examples
using System.IO;
using LMKit.Document.Pdf;
byte[] bytes = File.ReadAllBytes("report.pdf");
int pages = PdfRenderer.GetPageCount(bytes);
Console.WriteLine($"In-memory PDF has {pages} page(s).");