Topic Options
#56748 - 02/08/19 11:34 AM Alambic script for ExtractTo
leftee Offline
OL Newbie

Registered: 03/09/15
Posts: 21
Hi - I am trying to extract the last 8 pages of a PDF and having trouble withe the syntax for the Alambic ExtractTo script. I haven't used this type of scripting before. I figured out how to delete a page but need help with extracting.

Thank You

Top
#56750 - 02/11/19 09:07 AM Re: Alambic script for ExtractTo [Re: leftee]
Philippe F. Offline
OL Expert

Registered: 09/06/00
Posts: 1934
Loc: Objectif Lune, Montreal, Qc
Try this:
Code:
var myPDF = Watch.GetPDFEditObject();
myPDF.Open(Watch.GetJobFileName(),false);
myPDF.Pages().ExtractTo("C:\\Test\\Extract.pdf",myPDF.Pages().Count()-8,8,false);
myPDF.Close()
_________________________
Technical Product Manager
I don't want to achieve immortality through my work; I want to achieve immortality through not dying - Woody Allen

Top
#56753 - 02/11/19 01:45 PM Re: Alambic script for ExtractTo [Re: leftee]
leftee Offline
OL Newbie

Registered: 03/09/15
Posts: 21
Hi - The above code works. Thank you very much!! Maybe I was advised incorrectly before. What I need is the 8 pages to be deleted. I was told this could be done by using the extractTo. I see that it does extract the 8 pages but also leaves the 8 pages in the original document. Ultimately I need to end up with the first page only.

Thanks!!!

Top
#56755 - 02/11/19 05:36 PM Re: Alambic script for ExtractTo [Re: leftee]
Philippe F. Offline
OL Expert

Registered: 09/06/00
Posts: 1934
Loc: Objectif Lune, Montreal, Qc
Uhm… that's not any clearer.
You say you need to delete the last 8 pages and then you say you just need to end up with the first page only.
So assuming the latter is what's really important (retaining only the first page of the original PDF), then you could do it as follows, regardless of the number of pages in the original PDF:
Code:
var myPDF = Watch.GetPDFEditObject();
myPDF.Open(Watch.GetJobFileName(),false);
var pageCount = myPDF.Pages().Count();
for(var i=1;i<pageCount;i++){
  myPDF.Pages().Delete(1);
}
myPDF.Save(true);
myPDF.Close()
_________________________
Technical Product Manager
I don't want to achieve immortality through my work; I want to achieve immortality through not dying - Woody Allen

Top
#56757 - 02/12/19 08:30 AM Re: Alambic script for ExtractTo [Re: leftee]
leftee Offline
OL Newbie

Registered: 03/09/15
Posts: 21
That works perfect!!! Sorry if I was not clear. I should have said I needed page 2-9 deleted. that might have helped.

This one and the previous script will help me tremendously in streaming some of my processes.

Again - thank you very much!!!

Top