Copy link to clipboard
Copied
Hello everyone, I have about 400 page pdfs. I need to delete (20, 21, 100, 150, 300.... pages) some random pages. Page numbers to be deleted are listed in excel. Can I delete those pages with one shot using any script. Or can I delete those pages using bookmark which is one character lengthier than the others. i.e the page need to be deleted having bookmark one additional character comparing to pages which need to retain. Using the bkm length or using the list in excel... any way it is good to me.
1 Correct answer
Oh, really, important tip. Run the commands in REVERSE ORDER of page number.
Why? Example. I have to delete page 2 and page 8.
So I delete page 2. Then I delete page 8. Unfortunately, once page 2 was deleted, the eighth page was the original page 9. So you've deleted, in fact, page 2 and page 9.
Doesn't happen if you first delete page 8, then page 2.
Copy link to clipboard
Copied
One way: you can generate a doc.DeletePages call for each page to delete (that is, automate writing code).
Then run the code e.g. by pasting into the JavaScript console.
Yes, you can use the bookmarks to decide what to do but that's much more advanced and difficult.
Copy link to clipboard
Copied
Oh, really, important tip. Run the commands in REVERSE ORDER of page number.
Why? Example. I have to delete page 2 and page 8.
So I delete page 2. Then I delete page 8. Unfortunately, once page 2 was deleted, the eighth page was the original page 9. So you've deleted, in fact, page 2 and page 9.
Doesn't happen if you first delete page 8, then page 2.
Copy link to clipboard
Copied
I couldn't get this
Copy link to clipboard
Copied
Please suggest me why this line is not working
var p = [10, 6, 2]; var l = p.length; for (var i =0; i < l; i++) {var s = p; this.deletePages(s)}
where
var p = [10, 6, 2]; var l = p.length; for (var i =0; i < l; i++) {var s = p; console.println(s)} is working.
I tried to delete 11th 7th and 3rd pages from pdf.
Copy link to clipboard
Copied
Sorry it worked. And thanks. If you didn't suggest me REVERSE DELETION, I might take more days to find it.
Copy link to clipboard
Copied
That's a pity. What bit can't you get? If you aren't already a programmer, you have a lot to learn.
Copy link to clipboard
Copied
Yea I am not a programmer. But I have coded my need with some own trail and errors. I could not get REVERSE ORDER at first. By reading it again I got it. I am sure if I do some study on this.deletePages and doc.deletePages then I will get my need.

