Posts: 97
Threads: 27
Joined: May 2023
11-02-2023, 01:51 PM
(This post was last modified: 11-02-2023, 02:14 PM by birdywen.)
Hi, LA is so powerful, and I would like to ask if it is possible to pull the pdf information without opening it? say page count and creating time (huge number of pdfs). Thanks
Any response is appreciated.
Posts: 12,095
Threads: 142
Joined: Dec 2002
1. Go to
NuGet and search for pdf.
2. Click for example PDFsharp and copy the PM text. Also look at Frameworks (must support .NET 6), License (MIT means it's free), Source repository (isn't it abandoned etc).
3. In LA open the NuGet tool, paste, click Install. Wait, click Add /*/. Close the tool.
4. Now you can use the library in current script. Press Ctrl+Space and you'll find PdfSharp.
If need examples and other info, in the NuGet page click link "Project website" or "Source repository". Also google.
// script ""
/*/ nuget -\PDFsharp; /*/
using PdfSharp.Pdf.IO;
var doc = PdfReader.Open(@"C:\Downloads\p.pdf");
print.it(doc.PageCount, doc.Info.CreationDate);
Posts: 97
Threads: 27
Joined: May 2023
11-02-2023, 02:54 PM
This is fantastic. Thank you so much for the detailed information and the code.
Posts: 54
Threads: 24
Joined: Jun 2023
11-03-2023, 11:28 AM
(This post was last modified: 11-03-2023, 01:41 PM by burque505.)
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.
/*/ 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;
Posts: 97
Threads: 27
Joined: May 2023
Wonderful. Thanks and it worked.