Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Possible to get pdf page count?
#4
There is also itextsharp-lgpl. This will get the number of pages for you and the creation date. Sorry, no error checking, just bare bones.

 
Code:
Copy      Help
/*/ nuget PDF\iTextSharp-LGPL; /*/

using iTextSharp.text;
using iTextSharp.text.pdf;

string inpath = @"C:\Users\Your_User\Documents\LibreAutomate\Documents\Your_Test_Dummy.pdf";
FileInfo file = new FileInfo(inpath);
// string name = file.Name.Substring(0, file.Name.LastIndexOf("."));

PdfReader reader = new PdfReader(inpath);

var info = reader.Info;
DateTime creationDate = PdfDate.Decode(info["CreationDate"].ToString());
// print.it(info); // for reference
// print.it(info["CreationDate"]); // for reference

print.it("Pdf created: " + creationDate);
print.it("Number of pages: " + reader.NumberOfPages);

reader = null;


Messages In This Thread
Possible to get pdf page count? - by birdywen - 11-02-2023, 01:51 PM
RE: Possible to get pdf page count? - by Gintaras - 11-02-2023, 02:27 PM
RE: Possible to get pdf page count? - by birdywen - 11-02-2023, 02:54 PM
RE: Possible to get pdf page count? - by burque505 - 11-03-2023, 11:28 AM
RE: Possible to get pdf page count? - by birdywen - 11-04-2023, 01:46 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)