Copy link to clipboard
Copied
I have pdf file consists of 31 pages , each page contain 8 images , each of them size is 8.6 * 5.5 cm
Is there a script or automatic method to save each image as a single pdf page with its size ( 8.6 * 5.5 cm ) ?
Note : Images that I want to save each as single pdf page is marked by red rectangle in the example image attached here
Thanks
Copy link to clipboard
Copied
In fact that was not too long.
Forget my "86x55_BB.pdf" file and only open your "Test.pdf" file, then run this script from the console window.
//
var largeur=86;
var hauteur=55;
var offsetH=-16.5;
var deltaH=91;
var offsetV=31;
var deltaV=60;
//
var mm2pt=72/25.4;
var nbPages=this.numPages;
for (var p=0; p<nbPages; p++) {
for (v=0; v<4; v++) {
for (h=0; h<2; h++) {
this.newPage({
nWidth: largeur*mm2pt,
nHeight: hauteur*mm2pt
});
this.addWatermarkFromFile({
cDIPath: this.path,
nSourcePage: p,
nStart: this.numPages-1,
nHorizAlign: app.constants.align.left,
nVertAlign: app.constants.align.top,
nHorizValue: (offsetH-h*deltaH)*mm2pt,
nVertValue: (offsetV+v*deltaV)*mm2pt
});
}
}
}
this.deletePages(0,nbPages-1);
this.saveAs(this.path.replace(/.pdf$/i," \(One Image Per Page\).pdf"));
Is that working fine? Let me know.
@+
Copy link to clipboard
Copied
Any help Here
Copy link to clipboard
Copied
Hi,
Place the attached file in the same folder as your file then open it and run this script from the console window:
//
var offsetH=-16.5;
var deltaH=91;
var offsetV=31;
var deltaV=60;
//
var aRect=this.getPageBox();
var thePath=this.path;
var directory=thePath.substring(0,thePath.length-this.documentFileName.length);
var theFile=directory+"Test.pdf";
var mm2pt=72/25.4;
var otherDoc=app.openDoc(theFile);
var nbPages=otherDoc.numPages;
otherDoc.closeDoc();
for (var p=0; p<nbPages; p++) {
for (v=0; v<4; v++) {
for (h=0; h<2; h++) {
this.newPage({
nWidth: aRect[2],
nHeight: aRect[1]
});
this.addWatermarkFromFile({
cDIPath: theFile,
nSourcePage: p,
nStart: this.numPages-1,
nHorizAlign: app.constants.align.left,
nVertAlign: app.constants.align.top,
nHorizValue: (offsetH-h*deltaH)*mm2pt,
nVertValue: (offsetV+v*deltaV)*mm2pt
});
}
}
}
this.deletePages(0);
this.saveAs(this.path.replace(/.pdf$/i," \(One Image Per Page\).pdf"));
@+
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Hi,
Please note that the script can't check if there is effectively an image on each page and extract 8 images per page.
So, as on your last page you only have one image, it will extract 7 blank pages at the end of the new file...
@+
Copy link to clipboard
Copied
Copy link to clipboard
Copied
???
when you run the script, does the process take a few time or is the result immediately?
@+
Copy link to clipboard
Copied
No , It doesn't take any time , result immediately .
Copy link to clipboard
Copied
Hi
Is there any news about this problem ?
I think that related to the path of Test.pdf file in the script
Copy link to clipboard
Copied
Hi,
... me too!!!
I have an idea for an other script but I have no time today (sorry). I will give it later in the evenening or tomorrow morning.
Waiting for, could you run these lines from the "86x55_BB.pdf" file.
var thePath=this.path;
var directory=thePath.substring(0,thePath.length-this.documentFileName.length);
var theFile=directory+"Test.pdf";
var otherDoc=app.openDoc(theFile);
That should open the "Test.pdf" file... let me know.
@+
Copy link to clipboard
Copied
No problem , take your time , I'll wait you
Is these 4 lines I test them alone ? or put them in the first script you attached ? or How ?
when I tested them alone this message apears : ReferenceError: theFile is not defined
1:Console:Exec
undefined
Copy link to clipboard
Copied
In fact that was not too long.
Forget my "86x55_BB.pdf" file and only open your "Test.pdf" file, then run this script from the console window.
//
var largeur=86;
var hauteur=55;
var offsetH=-16.5;
var deltaH=91;
var offsetV=31;
var deltaV=60;
//
var mm2pt=72/25.4;
var nbPages=this.numPages;
for (var p=0; p<nbPages; p++) {
for (v=0; v<4; v++) {
for (h=0; h<2; h++) {
this.newPage({
nWidth: largeur*mm2pt,
nHeight: hauteur*mm2pt
});
this.addWatermarkFromFile({
cDIPath: this.path,
nSourcePage: p,
nStart: this.numPages-1,
nHorizAlign: app.constants.align.left,
nVertAlign: app.constants.align.top,
nHorizValue: (offsetH-h*deltaH)*mm2pt,
nVertValue: (offsetV+v*deltaV)*mm2pt
});
}
}
}
this.deletePages(0,nbPages-1);
this.saveAs(this.path.replace(/.pdf$/i," \(One Image Per Page\).pdf"));
Is that working fine? Let me know.
@+
Copy link to clipboard
Copied
I run the script on my Test.pdf
A new file created : Test (One Image Per Page).pdf , is same as old Test.pdf file
No change occured
Copy link to clipboard
Copied
Exactly the same file as your "Test.pdf" file???
Let me think today...
@+
Copy link to clipboard
Copied
Exactly the same file , take your time , I'll wait your reply
Copy link to clipboard
Copied
Select the whole script and run it.
ctrl-a ctrl-enter
Copy link to clipboard
Copied
Did you try this...
does that open the file?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
No, this script:
var thePath=this.path;
var directory=thePath.substring(0,thePath.length-this.documentFileName.length);
var theFile=directory+"Test.pdf";
var otherDoc=app.openDoc(theFile);
does it open the "Tesr.pdf" file?
Copy link to clipboard
Copied
No , I tried it now
message appears :
ReferenceError: theFile is not defined
1:Console:Exec
undefined
Copy link to clipboard
Copied
Could you open your Test.pdf file then execute "this.path" from the console window.
You should get the path in the console window.
Could you send me a screenshot of the path?
@+
Copy link to clipboard
Copied
Is it safe to send you full path here or send it as a private message ?
Copy link to clipboard
Copied
In PM if you wish...
Copy link to clipboard
Copied
I sent it in PM
Copy link to clipboard
Copied
With no file open, if you execute this script with your entire path, does that open the Test.pdf file?