Copy link to clipboard
Copied
I have a PDF with about 1500 pages and 1000 bookmarks (it's an auto-generated report from a tool we use).
I tried splitting the file basing it on the bookmarks, however, all of them have special characters, which I later found out to be the reason I always receive the error "The file may be read-only, or another user may have it open. Please save the document with a different name or in a different folder" when trying to split it (just to be clear, I'm not using any cloud services, and I have full permissions to read/write in any folder in my drive).
Does someone know of any way to automaticaly rename all the chapters? All of them have follow this pattern:
[BCC-0000] Name ~ With_Special > Characters ~
[BCC-0001] Name ~ With_Special > Characters ~
[BCC-0003] Name ~ With_Special > Characters ~ and so on.
I believe the best approach would be keeping only the first characters of the name, removing the "[ ]" if possible, or just use regex, but I have no idea on how to achieve this.
Thanks!
Run this code from the JS Console:
for (var i=0; i<this.bookmarkRoot.children.length; i++) {
var bkm = this.bookmarkRoot.children[i];
bkm.name = bkm.name.replace(/[\]\[\\\/\:\*\?\"\<\>\|!\^\n\r\v\t]/g,"");
}
Copy link to clipboard
Copied
Do all the bookmarks appear at the top-most level of the tree? In other words, are there any child bookmarks?
Copy link to clipboard
Copied
Thankfully, yes, all of them are at the top-most level.
Copy link to clipboard
Copied
Run this code from the JS Console:
for (var i=0; i<this.bookmarkRoot.children.length; i++) {
var bkm = this.bookmarkRoot.children[i];
bkm.name = bkm.name.replace(/[\]\[\\\/\:\*\?\"\<\>\|!\^\n\r\v\t]/g,"");
}
Copy link to clipboard
Copied
Thanks!! That's exactly what I was asking for, and I got to learn a bit about using JS/Regex on Acrobat.
However, there's something really odd happening, although I think this has no relation to the renaming proccess...
The "full file" has 90mb. When I split the pdf based on the bookmarks, Acrobat is creating files with 80mb, although all of them actually have only 2 or 3 pages... Do you have any idea about what could be happening?
Anyway, at least I successfully renamed the bookmarks, so once again, thanks!
Copy link to clipboard
Copied
P.S.: All the pages are A4, and the first page of each boomark have 1 really tiny image that doesn't take 0.5% of the page. The rest is all text. I'm positive each file should have no more than 500kb (since, when I export an individual part of the report, it always generates a file with ~150kb).