Merging Multiple pdfs--Page Count of Each Merged pdf

This Forum is for the use of End Users requiring help and assistance for Tracker Software's PDF-Tools.

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Sean - Tracker, Chris - Tracker Supp, Tracker Supp-Stefan

Post Reply
bqxmprij
User
Posts: 105
Joined: Tue Dec 18, 2012 3:51 am

Merging Multiple pdfs--Page Count of Each Merged pdf

Post by bqxmprij » Mon Dec 30, 2019 8:16 pm

I need to upload 100+ pdfs for something. I can merge them into a single pdf and upload the single merged pdf. But, if merged, I need to identify the page numbers of each document within the merged document. As an example, for a 100 page pdf created by merging 5 documents, I need to identify pp. 1-14 as document 1, pp. 15-27 as document 2, pp. 28-31 as document 3, pp. 32-60 as document 4, and pp. 61-100 as document 5.

Is there a way to merge 100+ pdfs with an output that identifies the pages of each individual merged pdf? By output, I mean something like a .txt file that I can easily copy and paste from.

Also, sometimes you guys are really, really nice and helpful and create a tool in pdf-tools. If you do that here, the merged pdf cannot be greater than 25MB and it would be helpful if the output incorporates the file name of each merged pdf.

Thanks and Happy New Year!

User avatar
TrackerSupp-Daniel
Site Admin
Posts: 2882
Joined: Wed Jan 03, 2018 6:52 pm

Re: Merging Multiple pdfs--Page Count of Each Merged pdf

Post by TrackerSupp-Daniel » Mon Dec 30, 2019 9:42 pm

Hello Ken,

My suggestion for this would be to enable the "add root bookmark with filename" function in the merge action, then add the "export bookmarks to text file" action just after that:
image.png
By default, this would get you a list showing all bookmarks in the document, and their relevant page number, including the "root bookmarks" that were just created after merging the document. While it does not include the full page range of the document, this method will show you quickly and easily which page each document starts at.

Does that help?
Daniel McIntyre
Support Technician
Tracker Software Products (Canada) LTD

Sales: +1 (250) 324-1621
Fax: +1 (250) 324-1623

User avatar
Vasyl-Tracker Dev Team
Site Admin
Posts: 1957
Joined: Thu Jun 30, 2005 4:11 pm
Location: Canada

Re: Merging Multiple pdfs--Page Count of Each Merged pdf

Post by Vasyl-Tracker Dev Team » Mon Dec 30, 2019 10:46 pm

Hi bqxmprij.

To identify each input file inside the result pdf you may use the 'Add Root Bookmark with filename' option that exists for 'Split/Merge PDFs' action. It will create an individual bookmark for each input file you have merged to the single one. Each bookmark will contain the name of the corresponding input pdf and if you click it - it will navigate to the first page inserted from that pdf. Then, to get a simple report about the result pdf:
1. open PDFXEditor (or Acrobat)
2. press Ctrl+J shortcut to show JavaScript console and paste the script:

Code: Select all

this.layout = "SinglePage";

var root = this.bookmarkRoot;
var res = "";
if (root.children != null)
{
	var len = root.children.length;
	var s = "";
	for (var i = 0; i < len; i++)
	{
		var child = root.children[i];
		child.execute();
		if (s != "")
		{
			s += this.pageNum;
			res += s + "\n";
			s = "";
		}

		s = child.name;
		s += ": ";
		s += (this.pageNum + 1) + "-";
	}

	if (s != "")
	{
		s += this.numPages;
		res += s + "\n";
	}
}

var rep = new Report();
rep.writeText(res);
var destPath = this.path;
destPath = destPath.replace(".pdf", ".Report.pdf");
rep.save(destPath);
and run it. It will create a new pdf file near the result pdf-file with the text like:

C:\SrcFile1.pdf: 1-10
C:\SrcFile2.pdf: 11-20
C:\SrcFile3.pdf: 21-30
...

And to reduce the size of the result pdf-file you may use the 'Optimize PDFs' action (put it before the 'Save Documents' action in your custom tool).

HTH.
Vasyl Yaremyn
Tracker Software Products
Project Developer

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.

bqxmprij
User
Posts: 105
Joined: Tue Dec 18, 2012 3:51 am

Re: Merging Multiple pdfs--Page Count of Each Merged pdf

Post by bqxmprij » Mon Dec 30, 2019 11:14 pm

Thank you very much for the quick reply. Happy New Year!

User avatar
TrackerSupp-Daniel
Site Admin
Posts: 2882
Joined: Wed Jan 03, 2018 6:52 pm

Re: Merging Multiple pdfs--Page Count of Each Merged pdf

Post by TrackerSupp-Daniel » Mon Dec 30, 2019 11:22 pm

Happy New year! :D
Daniel McIntyre
Support Technician
Tracker Software Products (Canada) LTD

Sales: +1 (250) 324-1621
Fax: +1 (250) 324-1623

Post Reply