Topic Options
#57080 - 05/30/19 05:44 AM Move PDF page
PPlearner Offline
OL Newbie

Registered: 05/30/19
Posts: 1
Hi all,

Would like to know is a way to move the pdf page?
eg. page1 -> page3
end result
page 2 - page 3 - page 1

i tried using move which is stated from the alambcedit-api, but to no avail.

http://help.objectiflune.com/files/EN/alambicedit-api/AlambicEdit.html

As the number of documents to be processed is in large amount, approximately 200,000 or more.
efficiency is crucial.

Top
#57081 - 05/30/19 09:23 AM Re: Move PDF page [Re: PPlearner]
Jean-Cédric Offline
OL Expert

Registered: 10/03/16
Posts: 459
Loc: Québec, Canada
The following code works for me. It takes the 2 first pages and offset them of 2 places.

Code:
var objPDF = Watch.GetPDFEditObject();
objPDF.Open(Watch.GetJobFileName(), false);

objPDF.Pages().Move(0,2,2);

CollectGarbage();

objPDF.Save(false);
objPDF.Close();


Top
#57089 - 05/31/19 10:26 AM Re: Move PDF page [Re: PPlearner]
Philippe F. Offline
OL Expert

Registered: 09/06/00
Posts: 1926
Loc: Objectif Lune, Montreal, Qc
The way I understand the question is "Is there a way to take the first page and make it the last page of a PDF". The following code would work, regardless of the number of pages in the PDF:
Code:
var objPDF = Watch.GetPDFEditObject();
objPDF.Open(Watch.GetJobFileName(), false);

objPDF.Pages().Move(0,1,objPDF.Pages().Count()-1);

CollectGarbage();

objPDF.Save(false);
objPDF.Close();


This is as efficient a process as can be since the PDF is not actually modified: only its reference table gets adjusted so that the first page is now considered the last one. On my system, this scripts runs in about 15ms, which means it would take less than an hour to process those 200,000 files on a single thread.

You can run the same process in self-replication mode, which would allow you to have several threads doing the same thing and which would probably allow you to significantly cut that time down.

Your mileage will vary, mind you.


Edited by Philippe F. (05/31/19 10:31 AM)
_________________________
Technical Product Manager
I don't want to achieve immortality through my work; I want to achieve immortality through not dying - Woody Allen

Top