PDF-ShellTools > General

rename page size file

<< < (2/2)

RTT:

--- Quote from: Urraco on May 24, 2019, 07:38:41 AM ---I updated the script but still same error." Unable to rename..."

--- End quote ---
It's working here, with the 3.3 version and Windows 10.
Did you deleted the the old one, from the list of scripts, before importing the updated script? If not, it's still using the old one, and the imported script ended named PageSize1.


--- Quote ---About format if you can, i want to get trimbox size of the pdf document and if does not contain trim size, return cropbox or mediabox size

--- End quote ---

Check if this one works:

--- Code: ---function PageTrimSize() {
    var Size = '';
    var Page = BatchFile.Pages(0);
    if (Page) {
        var box = Page.TrimBox ? Page.TrimBox : Page.CropBox ? Page.CropBox : Page.MediaBox;
        if (Page.Rotation == 90 || Page.Rotation == 270) {
            Size = GetDist_mm(box.top, box.bottom).toFixed() + 'x' + GetDist_mm(box.left, box.right).toFixed() + ' mm';
        } else {
            Size = GetDist_mm(box.left, box.right).toFixed() + 'x' + GetDist_mm(box.top, box.bottom).toFixed() + ' mm';
        }
    }
    BatchFile.close();
    return Size;
}

function GetDist_mm(x1, x2) {
    return Math.abs(x1 - x2) * 25.4 / 72
}

--- End code ---

Type [F]_[PageTrimSize] in the tool rename formula field, to use this new script.

Urraco:

--- Quote from: RTT on May 25, 2019, 01:21:26 AM ---
--- Quote from: Urraco on May 24, 2019, 07:38:41 AM ---I updated the script but still same error." Unable to rename..."

--- End quote ---
It's working here, with the 3.3 version and Windows 10.
Did you deleted the the old one, from the list of scripts, before importing the updated script? If not, it's still using the old one, and the imported script ended named PageSize1.


--- Quote ---About format if you can, i want to get trimbox size of the pdf document and if does not contain trim size, return cropbox or mediabox size

--- End quote ---

Check if this one works:

--- Code: ---function PageTrimSize() {
    var Size = '';
    var Page = BatchFile.Pages(0);
    if (Page) {
        var box = Page.TrimBox ? Page.TrimBox : Page.CropBox ? Page.CropBox : Page.MediaBox;
        if (Page.Rotation == 90 || Page.Rotation == 270) {
            Size = GetDist_mm(box.top, box.bottom).toFixed() + 'x' + GetDist_mm(box.left, box.right).toFixed() + ' mm';
        } else {
            Size = GetDist_mm(box.left, box.right).toFixed() + 'x' + GetDist_mm(box.top, box.bottom).toFixed() + ' mm';
        }
    }
    BatchFile.close();
    return Size;
}

function GetDist_mm(x1, x2) {
    return Math.abs(x1 - x2) * 25.4 / 72
}

--- End code ---

Type [F]_[PageTrimSize] in the tool rename formula field, to use this new script.

--- End quote ---



It works!
Thank for help, I appreciate it
Great software, I recommend.

Navigation

[0] Message Index

[*] Previous page

Go to full version