How to cut a PDF into two parts?

Forum for the PDF-XChange Editor - Free and Licensed Versions

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Paul - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

User avatar
Peter2
User
Posts: 966
Joined: Mon Sep 13, 2010 10:09 am

How to cut a PDF into two parts?

Post by Peter2 »

I know that the basic feature for this is "extract pages", but ...

- I have many PDFs with many pages
- I have to browse every page and to check if a special content changes.
- If the content changes (e.g. the content is "A" from first page to page 6, on page 7 I see that the content is now "B".)
- Now I want "extract from page 1 to page 6 to a new file, continue with new page 1.

Is there a more simple way (automatically?) than the "extract-dialogue" to get this?

Peter
PDF-X-Change Pro German
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19961
Joined: Mon Jan 12, 2009 8:07 am

Re: How to cut a PDF into two parts?

Post by Stefan - PDF-XChange »

Hi Peter,

Is the content that changes always the same or do you actually need to review each file and then decide which pages to extract?
It is possible to write a JavaScript that will do the extraction process, and you can code some logic there.

Or if you need to review each page - using the thumbnails pane and clicking to select the pages you want to extract should help you to later select Extract pages - > Selected pages as an option to speed up the process.

Regards,
Stefan
User avatar
Peter2
User
Posts: 966
Joined: Mon Sep 13, 2010 10:09 am

Re: How to cut a PDF into two parts?

Post by Peter2 »

Tracker Supp-Stefan wrote:...It is possible to write a JavaScript that will do the extraction process, and you can code some logic there....
Is there somewhere a documentation for "JavaScript on Editor / Viewer"?


The basic of the PDFs are bunches of scanned paper, where different "sections" are scanned to one file. The papers have notes on the upper corner (a number), and the result is for example:

#123, from page 1-6
#124, from page 7-17
#212, from page 18-19

You see: different handwritten numbers, different count of relating pages. So in detail I have:

- to open PDF on first page
- see: the number is "123"
- browse every page
- on page 7 I see: new number is "124". Extract the previous pages (1-6) to file "123" and continue to browse

Peter
PDF-X-Change Pro German
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19961
Joined: Mon Jan 12, 2009 8:07 am

Re: How to cut a PDF into two parts?

Post by Stefan - PDF-XChange »

Hi Peter,

You can use pretty much anything that is not 3D related from here:
http://www.adobe.com/content/dam/Adobe/ ... erence.pdf

So if your pages are scanned text with only this one number being an annotation on each page - it should be pretty straight forward to code it. You will need to read the annotation's contents to obtain the number, remember it, scroll through each page reading the same, and when you see a different number - extract all the previous pages to a new file, remember the new number and continue repeating the previous steps until the end of the document.

Regards,
Stefan
User avatar
Peter2
User
Posts: 966
Joined: Mon Sep 13, 2010 10:09 am

Re: How to cut a PDF into two parts?

Post by Peter2 »

So I don't need a SDK, only Viewer or Editor (plus 769 pages of manual :oops: )?

Peter
PDF-X-Change Pro German
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19961
Joined: Mon Jan 12, 2009 8:07 am

Re: How to cut a PDF into two parts?

Post by Stefan - PDF-XChange »

Hi Peter,

Yes indeed JS code (Ctrl-J to open the console) can be executed in the end user products as well - so no SDK is needed.

Regards,
Stefan
Seeker45
User
Posts: 162
Joined: Wed Dec 18, 2013 2:32 pm

Re: How to cut a PDF into two parts?

Post by Seeker45 »

Hi Stefan,

that sounds interesting. Do you know a webpage where some basic tools of the API as explained, e.g. an example for deleting pages, splitting/merging documents, etc.? Perhaps "PDF-JavaScript API for Dummies"? :lol:

Thank you.

Cheers
Ralf
User avatar
Will - Tracker Supp
Site Admin
Posts: 6815
Joined: Mon Oct 15, 2012 9:21 pm

Re: How to cut a PDF into two parts?

Post by Will - Tracker Supp »

Hi Ralf,

The best thing to use is Adobe's JavaScript reference manual:
http://www.adobe.com/content/dam/Adobe/ ... erence.pdf

The documentation here is extremely thorough. Though as with all reference manuals, a knowledge of the fundamentals is required.

Cheers,
If posting files to this forum, you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded.
Thank you.

Best regards

Will Travaglini
Tracker Support (Europe)
Tracker Software Products Ltd.
http://www.tracker-software.com
User avatar
Peter2
User
Posts: 966
Joined: Mon Sep 13, 2010 10:09 am

Re: How to cut a PDF into two parts?

Post by Peter2 »

This topic brings me back to one of my old proposals: You could provide a download (and upload?) area or a special part of the forum, where the authors and the users could discuss / develop / provide additional configurations / mini-tools / settings to your products. The file name rules are the best idea to start, maybe some JS-snippets will be there ...

Peter
PDF-X-Change Pro German
Seeker45
User
Posts: 162
Joined: Wed Dec 18, 2013 2:32 pm

Re: How to cut a PDF into two parts?

Post by Seeker45 »

Hi Will,

well, reading that Reference Guide is like reading a dictionary in the hope to learn a language :o So that's not going to work. I do a lot of AutoIt programming, and for more complex functions, 99% of the time, I look into what others have created ("snippets" like Peter put it), because there is no need to invent the wheel twice. Even if such snippet is only a 50% fit, it still saves 50% of my time.

But I understand that you are not aware of any better material for starters. Thank you.

Cheers
Ralf
User avatar
Peter2
User
Posts: 966
Joined: Mon Sep 13, 2010 10:09 am

Re: How to cut a PDF into two parts?

Post by Peter2 »

Seeker45 wrote:...well, reading that Reference Guide is like reading a dictionary in the hope to learn a language :o ...
Yes - it's a reference and not a tutorial :?
Seeker45 wrote:...But I understand that you are not aware of any better material for starters....
I still have the hope that the guys consider my suggestion.

Peter
PDF-X-Change Pro German
User avatar
Will - Tracker Supp
Site Admin
Posts: 6815
Joined: Mon Oct 15, 2012 9:21 pm

Re: How to cut a PDF into two parts?

Post by Will - Tracker Supp »

Hi guys,

Ralf - I understand and would have to agree. While thorough, it's definitely more of a JS 'dictionary' than anything and definitely requires that you're a familiar with the language.

Peter - I'll have a word with John and will see if that's something we can do. Just to make sure that I understand, this would be a forum specifically for users to share JS snippets, tips/tricks for various tools, that kind of thing?

Cheers,
If posting files to this forum, you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded.
Thank you.

Best regards

Will Travaglini
Tracker Support (Europe)
Tracker Software Products Ltd.
http://www.tracker-software.com
User avatar
Peter2
User
Posts: 966
Joined: Mon Sep 13, 2010 10:09 am

Re: How to cut a PDF into two parts?

Post by Peter2 »

Will - Tracker Supp wrote:...Peter - I'll have a word with John and will see if that's something we can do. Just to make sure that I understand, this would be a forum specifically for users to share JS snippets, tips/tricks for various tools, that kind of thing?...
Yes - partially. I'm not a JS-programmer (only Autolisp), but I see that many successful programs have a community which develop and shares (commercial or not) additional features, tool, plugins which works with the software or inside the software: TotalCommander (Plugins), Autocad (Apps..), Firefox, Ultraedit (Scripts, settings, macros, ..)

I don't know all APIs which are offered by PDF-XChange-products (outside of SDK), but if you offer a small place to discuss, to present and to download JS, AutoIT, AHK, LSP, .... - maybe it will develop.

Peter
PDF-X-Change Pro German
Seeker45
User
Posts: 162
Joined: Wed Dec 18, 2013 2:32 pm

Re: How to cut a PDF into two parts?

Post by Seeker45 »

Here is what I was referring to in the AutoIt forum: http://www.autoitscript.com/forum/forum ... e-scripts/

Of course, since AutoIt is at least 10 times more complex than the PDF-API, the "snippets" can be really complex.

Cheers
Ralf
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19961
Joined: Mon Jan 12, 2009 8:07 am

Re: How to cut a PDF into two parts?

Post by Stefan - PDF-XChange »

Hi Ralf,

Thanks for the suggestion.

As for Peter - Please take a look at this:
https://forum.pdf-xchange.com/ ... 823#p45823
While not exactly what you want to do - it should give you an idea of how to write your own script that will check the annotations for the given string you are after, and extract the pages as needed.

Regards,
Stefan
User avatar
Peter2
User
Posts: 966
Joined: Mon Sep 13, 2010 10:09 am

Re: How to cut a PDF into two parts?

Post by Peter2 »

Thanks Stefan

I will look for a JS-guy under my friends. And I will watch I there will be a tool-page :D

Peter
PDF-X-Change Pro German
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19961
Joined: Mon Jan 12, 2009 8:07 am

Re: How to cut a PDF into two parts?

Post by Stefan - PDF-XChange »

:)