Copy link to clipboard
Copied
Hi,
I do not mean to change from A4 to A3 or like.
I mean to adjust the exact size of inches for a custom paper size.
The reason for asking is that I have a file that needs to be printed and it has a lot of margins, so after removing all margins using the crop pages toolboxes, I am still not satisfied but the result for the printed document, because it still has some margins, while the soft copy has no margins at all.
So I thought about having a custom page size, then printing it.
I will print it on A4 paper.
This is the page after the crop:
This is the page in print preview:
So is there any way or workaround to remove all margins and print without margins? I mean to let the printed paper page be precisely like the cropped one without margins.
The real printed paper page is exactly as shown in the preview, which is not what I am looking for.
Thanks
Hi,
Sorry if my answer is a bit late...
If you want resize your text area manually with distorsion, you can do that importing your file in an empty A4 format file, then place it at the right position and resize it as required.
You can then print this file with the "fit" option to hold the max space of the sheet.
If your text is editable and you want to automatically resize the pages cropping the closer to the text, you can use this script from the console window or in an action wizard. It wil
...use the "Scale pages to specified size" profile. I think I duplicated and edited this profile to make the new profile "Scale pages to specified size with distortion". Duplicate and re-name the profile from the little fly-out menu "Options", when you have your new profile, click on "Edit" to change the settings.
Hi,
Here is what I did for you.
1) Open your file "1.Pages from crop.pdf" then type ctrl J to open the console window.
If the console window is not empty, click on the trash at the bottom right of the window.
2) Copy and paste the following script in the console window.
d0=new Date();
starting=util.printd("mm/dd/yy – HH:MM:ss",d0);
var found=0;
var leftAlign=100;
var topAlign=800;
var bottomAlign=25;
for (var p=0; p<this.numPages; p++) {
console.clear();
console.println("Process starting: "
...
Here is the last script I used for the book I sent you back in PM:
d0=new Date();
starting=util.printd("mm/dd/yy – HH:MM:ss",d0);
var found=0;
for (var p=0; p<this.numPages; p++) {
console.clear();
console.println("Process starting: "+starting);
console.println("Processing the page #"+(p+1)+"/"+this.numPages);
if (this.getPageNumWords(p)) {
var thisPage=this.getPageBox("Crop",p);
var topAlign=780;
var bottomAlign=90;
var topLine=0;
var header="";
var bottomLine=0;
var footer=""
...
Copy link to clipboard
Copied
Thanks a lot.
Please, I've tried to import it but failed.
I've just downloaded it and renamed it.
Copy link to clipboard
Copied
I suspected a bit!
Do you know how to use action wizards?
@+
Copy link to clipboard
Copied
Somehow I think I managed to do it.
Much appreciate your valuable time helping me.
Copy link to clipboard
Copied
Hi,
Sorry, but I don't understand what did you manage!
Is everything OK for you now?
@+
Copy link to clipboard
Copied
Here is the last script I used for the book I sent you back in PM:
d0=new Date();
starting=util.printd("mm/dd/yy – HH:MM:ss",d0);
var found=0;
for (var p=0; p<this.numPages; p++) {
console.clear();
console.println("Process starting: "+starting);
console.println("Processing the page #"+(p+1)+"/"+this.numPages);
if (this.getPageNumWords(p)) {
var thisPage=this.getPageBox("Crop",p);
var topAlign=780;
var bottomAlign=90;
var topLine=0;
var header="";
var bottomLine=0;
var footer="";
var topChapter=0;
var chapter="";
var leftMargin=Number(thisPage[2]);
var topMargin=0;
var rightMargin=0;
var bottomMargin=Number(thisPage[1]);
for (var i=0; i<this.getPageNumWords(p); i++) {
var pagination=0;
var q=this.getPageNthWordQuads(p,i);
var m=(new Matrix2D).fromRotated(this,p);
var mInv=m.invert();
var r=mInv.transform(q);
var r=r.toString();
var r=r.split(",");
if (Number(r[1])>35 && Number(r[1])<820) {
if (Number(r[1])>topAlign) {
if (!topLine && Number(r[0])<77) {
var header=header+this.getPageNthWord(p,i,true)+" - ";
var theAlignment="left";
} else if (Number(r[6])>590) {
header+="- "+this.getPageNthWord(p,i,true);
var theAlignment="right";
} else header+=this.getPageNthWord(p,i,false);
topLine++;
}
if (Number(r[1])<bottomAlign) {
bottomLine++;
//var footer=this.getPageNthWord(p,i,true);
}
if (Number(r[0])<leftMargin) leftMargin=Number(r[0]);
if (Number(r[1])>topMargin) topMargin=Number(r[1]);
if (Number(r[6])>rightMargin) rightMargin=Number(r[6]);
if (Number(r[7])<bottomMargin) bottomMargin=Number(r[7]);
}
}
this.setPageBoxes({
cBox: "Crop",
nStart: p,
rBox: [leftMargin-2,topMargin,rightMargin-2,bottomMargin-2]
});
var thisPage=this.getPageBox("Crop",p);
if (topLine && (theAlignment=="right" || (theAlignment=="left" && header.length<60))) {
var f=this.addField("header"+p,"text",p,[0,thisPage[1],thisPage[2],thisPage[1]-22]);
f.textSize=10;
f.alignment="center";
f.textFont=font.HelvB;
f.fillColor=color.white;
f.value=header;
}
if (bottomLine) {
var f=this.addField("footer"+p,"text",p,[0,12,thisPage[2],0]);
f.textSize=0;
f.alignment="center";
f.textFont=font.HelvB;
f.fillColor=color.white;
f.value=this.getPageLabel(p);
}
found++;
}
}
if (found) {
this.flattenPages();
this.saveAs(this.path.replace(/.pdf$/i," \(Cropped\).pdf"));
df=new Date();
ending=util.printd("mm/dd/yy – HH:MM:ss",df);
temps=(df.valueOf()-d0.valueOf())/1000/60;
var theMinutes=parseInt(temps);
var theSeconds=(temps-theMinutes)*60;
var theSeconds=parseInt(theSeconds*10)/10;
var theTime="";
if (theMinutes>0) {
if (theMinutes==1) var theTime="1 minute";
else var theTime=theMinutes+" minutes";
}
if (theSeconds>0) {
if (theSeconds<2) var theTime=theTime+" "+theSeconds+" second";
else var theTime=theTime+" "+theSeconds+" seconds";
}
var theTime=theTime.replace(/^\s+|\s+$/gm,"");
var plurial=found>1?"s":"";
var txt="Process starting: "+starting+"\rProcess ending: "+ending+"\rProcess duration: "+theTime+"\r\r"+found+"/"+this.numPages+" page"+plurial+" cropped.";
console.clear();
console.println(txt);
app.alert(txt,3);
}
Attached is a pdf file with a header and a footer you can use if some pages are not correct.
@+
Copy link to clipboard
Copied
Thanks a lot and much appreciated.
I am much thankful for all your help.
Copy link to clipboard
Copied
Hi,
Please, I am digging more and more to find desired results.
Please, and sorry for bothering you, but here is the editable copy of my PDF file:
After I do the crop for all pages, I get this result:
Which is fine and good enough for me.
Now after crop pages using Set Pages Boxes, I found some parts of pages are trimmed, which is making sense of course.
When I hit the Edit PDF option I can find all text editable, so does there is a way to move the headers inside a few inches?
Like here:
So here after I did the crop:
Now when I click on edit PDF I get everything editable, like here:
So my question is:
The area at the far top left of the page, where it says the title of the chapter and book, is an editable box that exists on all pages all over the document, so does there is any way or any profile in PreFlight settings to move the title to the right for all pages, so I can see the title after I cropped the pages?
I mean like this:
So is it doable?
I hope that I was able to express my point correctly.
This is the final result after the crop:
Which is good for me.
I do hope that you may help 🙂
Copy link to clipboard
Copied
No, there is no automation to move the box. Indeed, there is no actual box. It's just invented by the editor each time you visit the page, by guesswork, where it thinks editing would be most convenient. Move two boxes close together, and they are likely to become one box. Put white space in a box, it's likely to become two boxes.
Copy link to clipboard
Copied
I am not a preflight specialist, but it should not be possible to move text with a preflight profile.
What is possible to do with a script is to copy the text of this first line and add a white field containing this text at the right position and which will hide the original text.
With your screenshots, I guess you didn't use my scripts to crop pages.
If you want to add the header at a correct place, you will have to use a script...
Is it possible for you to share a few pages (about 20 with different chapters) of your file.
@+
Copy link to clipboard
Copied
Hi,
Thanks a lot for your valuable time helping me.
I guess you didn't use my scripts to crop pages.
If you want to add the header at a correct place, you will have to use a script...
Is it possible for you to share a few pages (about 20 with different chapters) of your file.
@+
By @bebarth
Yes, I was not able to figure out how to use the script and even YouTube videos were not helpful for me.
I am spending a lot of hours so far to figure it out, please excuse my ignorance 😞
I di appreciated the wonderful help I am getting here in the community.
The first trial to remove only the margins and I used the PreFlight to convert the trim box to crop box, is the file titled:
1. Pages from crop.pdf
And the other trial where I removed extra margins and I want to replace the title box at the top is in the file titled:
2. final Pages from crop.pdf
So you will use the 2nd file titled "2. final Pages from crop.pdf" to adjust the header.
Please, if possible you may share the steps or the technique you will follow so I can learn as this is the most important thing for me regarding this issue.
Thanks for your understanding!
Copy link to clipboard
Copied
Hi,
Here is what I did for you.
1) Open your file "1.Pages from crop.pdf" then type ctrl J to open the console window.
If the console window is not empty, click on the trash at the bottom right of the window.
2) Copy and paste the following script in the console window.
d0=new Date();
starting=util.printd("mm/dd/yy – HH:MM:ss",d0);
var found=0;
var leftAlign=100;
var topAlign=800;
var bottomAlign=25;
for (var p=0; p<this.numPages; p++) {
console.clear();
console.println("Process starting: "+starting);
console.println("Processing the page #"+(p+1)+"/"+this.numPages);
if (this.getPageNumWords(p)) {
var topLine=0;
var header="";
var bottomLine=0;
var footer="";
var topChapter=0;
var chapter="";
var thisPage=this.getPageBox("Crop",p);
var leftMargin=thisPage[2];
var topMargin=0;
var rightMargin=0;
var bottomMargin=thisPage[1];
for (var i=0; i<this.getPageNumWords(p); i++) {
var q=this.getPageNthWordQuads(p,i);
var m=(new Matrix2D).fromRotated(this,p);
var mInv=m.invert();
var r=mInv.transform(q);
var r=r.toString();
var r=r.split(",");
if (Number(r[0])<leftAlign) {
if (Number(r[1])>topMargin) topMargin=r[1];
if (Number(r[7])<bottomMargin) bottomMargin=r[7];
if (Number(r[7])>topAlign) topLine++;
else if (Number(r[7])<bottomAlign) bottomLine++;
else if (!topChapter) {
topChapter++;
var theBottom=Number(r[7]);
topMargin=Number(r[1])+50;
}
}
if (topLine && Number(r[7])>topAlign) header+=this.getPageNthWord(p,i,false);
else if (bottomLine && Number(r[7])<bottomAlign) footer+=this.getPageNthWord(p,i,true);
else if (topChapter && Number(r[7])==theBottom) chapter+=this.getPageNthWord(p,i,false);
else {
if (Number(r[0])<leftMargin) leftMargin=r[0];
if (Number(r[1])>topMargin) topMargin=r[1];
if (Number(r[6])>rightMargin) rightMargin=r[6];
if (Number(r[7])<bottomMargin) bottomMargin=r[7];
}
}
this.setPageBoxes({
cBox: "Crop",
nStart: p,
rBox: [leftMargin,topMargin,rightMargin,bottomMargin]
});
var thisPage=this.getPageBox("Crop",p);
if (topLine) {
var f=this.addField("header"+p,"text",p,[0,thisPage[1],thisPage[2],thisPage[1]-22]);
f.textSize=10;
f.textFont=font.HelvB;
f.fillColor=color.white;
f.value=header;
}
if (topChapter) {
var f=this.addField("header"+p,"text",p,[0,thisPage[1],thisPage[2],thisPage[1]-22]);
f.textSize=10;
f.textFont=font.HelvB;
f.fillColor=color.white;
f.value=chapter;
}
if (bottomLine) {
var f=this.addField("footer"+p,"text",p,[0,22,thisPage[2],0]);
f.textSize=14;
f.textFont=font.HelvB;
f.fillColor=color.white;
f.value=footer;
}
found++;
}
}
if (found) {
this.flattenPages();
this.saveAs(this.path.replace(/.pdf$/i," \(Cropped\).pdf"));
df=new Date();
ending=util.printd("mm/dd/yy – HH:MM:ss",df);
temps=(df.valueOf()-d0.valueOf())/1000/60;
var theMinutes=parseInt(temps);
var theSeconds=(temps-theMinutes)*60;
var theSeconds=parseInt(theSeconds*10)/10;
var theTime="";
if (theMinutes>0) {
if (theMinutes==1) var theTime="1 minute";
else var theTime=theMinutes+" minutes";
}
if (theSeconds>0) {
if (theSeconds<2) var theTime=theTime+" "+theSeconds+" second";
else var theTime=theTime+" "+theSeconds+" seconds";
}
var theTime=theTime.replace(/^\s+|\s+$/gm,"");
var plurial=found>1?"s":"";
var txt="Process starting: "+starting+"\rProcess ending: "+ending+"\rProcess duration: "+theTime+"\r\r"+found+"/"+this.numPages+" page"+plurial+" cropped.";
console.clear();
console.println(txt);
app.alert(txt,3);
}
3) Select all this script typing ctrl A.
4) Press the "ENTER" key of the numerical panel or the corresponding combinaison of the keypad (certainly ctrl Return).
5) The script run.
Attached is the result file from your file.
Here is the positions of the margins in your original file if you try to modify them for an other book...
I hope you will understand and will be able to use and modify this script...
@+
...in the last screenshot, read "pts".
Copy link to clipboard
Copied
I am much thankful for your valuable help and your valuable time.
The script runs flawlessly with a brilliant result indeed.
Please, to run the script on other files, what parts do I need to edit or change?
So which parts of the script, do I need to edit?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Hi,
The problem is that each book has its own layout. For example, in this one the pagination is at the top of the page. It is therefore very difficult to write a script that will be effective for all books without having to adapt it!
With my previous script, we can only change the margins as below:
...
var leftAlign=100;
var topAlign=780;
var bottomAlign=68;
...
and the result after the distorsion preflight is such as the example attached.
I don't know if this result will suit you...
@+
Copy link to clipboard
Copied
The problem is that each book has its own layout.
Yes, it is.
...
var leftAlign=100;
var topAlign=780;
var bottomAlign=68;
...
Why there is no line for the right align margin side of the page? as I used to adjust the margins by cropping the four sides of the page using the pages box crop tool.
and the result after the distorsion preflight is such as the example attached.
I don't know if this result will suit you...
The scenario I used to do, is:
1- Use page boxes to crop margins from all sides of the page.
2- Use preflight to resize it to enlarge and fill the page using the profile "Scale pages to specified size", and add dimensions manually 210x297.
3- Finally choose to print it, set the paper size to A4, and choose fit page size.
I do not mean to be impolite, but the attached size is not good for reading if printed.
Please, is it possible that me to calculate the crop margins manually first for the four sides of the page then add it to the script, then run the script? so the main idea for the script is to set the header of the page which includes:
* Page number.
* Chapter title (if exist).
* Book title (if exists).
Set this header to the middle of the page.
Then I print it.
Am I following you correctly or did I miss understood what you said?
Copy link to clipboard
Copied
Hi,
Just want to sincerely thank every member here in the community as it is a treasure indeed, and especially @bebarth for the invaluable and amazing help I've got.
Thanks a lot indeed.
Copy link to clipboard
Copied
The best way to thank those who helped you would be to mark those answers as correct.
Copy link to clipboard
Copied
I've marked the replies that provided solutions as the correct answer.
But there are too many other useful replies, may I mark more?
Copy link to clipboard
Copied
What and how many you mark is up to you, but they should be answers that directly related to your original post/question.