Post reply

Name:
Email:
Subject:
Message icon:

Verification:

shortcuts: hit alt+s to submit/post or alt+p to preview


Topic Summary

Posted by: RTT
« on: August 07, 2017, 04:05:16 PM »

question though... can we get it to save over the original file or save it to another location with the same filename?
The relevant line is:
if (Pages.CommitChanges(pdfe.SelectedFiles(i).Filename + '(rot).pdf')) {

To save over, replace it by:
if (Pages.CommitChanges() {

To save to another location, replace it by:
var Filename=pdfe.SelectedFiles(i).Filename;
if (Pages.CommitChanges('c:\\your\\other\path\\'+Filename.substr(Filename.lastIndexOf('\\') + 1)) {
Posted by: nightslayer23
« on: August 04, 2017, 05:58:15 AM »

question though... can we get it to save over the original file or save it to another location with the same filename?
Posted by: nightslayer23
« on: August 04, 2017, 05:04:30 AM »

awesome! thank you
Posted by: RTT
« on: August 04, 2017, 01:28:48 AM »

In the next version, 3.2, it will be possible to use the words "landscape" and "portrait" as page selectors, in any of the tools that have the possibility to define the list of affected pages. I have it already implemented, as depicted in the attached screenshot.

Even so, you can do it already with a script.
Here's one that rotates all the portrait pages by 90 degrees:
Code: [Select]
var ProgressBar = pdfe.ProgressBar;
ProgressBar.max = pdfe.SelectedFiles.Count;

for (var i = 0; i < pdfe.SelectedFiles.Count; i++) {
    ProgressBar.position = i + 1;
    try {
        var Pages = pdfe.SelectedFiles(i).Pages;
        var RotatedPagesCount = 0;
        for (var PageIndex = 0; PageIndex < Pages.Count; PageIndex++) {
            var Page = Pages(PageIndex);
            if (Page) {
                //Note: this rotation angle check should be removed for versions>3.1.x           
                if (Page.Rotation == 90 || Page.Rotation == 270) {
                    var w = Page.Height;
                    var h = Page.Width;
                } else {
                    var w = Page.Width;
                    var h = Page.Height;
                }

                if (h > w) {
                    Page.Rotation = Page.Rotation + 90;
                    RotatedPagesCount++;
                }
            }
        }
        if (RotatedPagesCount) {
            if (Pages.CommitChanges(pdfe.SelectedFiles(i).Filename + '(rot).pdf')) {
                pdfe.echo(pdfe.SelectedFiles(i).Filename + ' (rotated ' + RotatedPagesCount + ' pages)');
            } else {
                pdfe.echo(pdfe.SelectedFiles(i).Filename + ' (failed to commit changes)', 0xFF0000);
            }
        } else {
            pdfe.echo(pdfe.SelectedFiles(i).Filename + ' (nothing to rotate)');
        }
    } catch (e) {
        pdfe.echo(pdfe.SelectedFiles(i).Filename + ' :' + e.message, 0xFF0000);
    }
}
pdfe.echo("Done");
Posted by: nightslayer23
« on: August 03, 2017, 03:14:45 AM »

Can we get an update for the Rotate Pages Batch Command to incorporate the parameter of Landscape or Portrait pages?

At the moment it can only rotate by page numbers, if it could rotate "portrait pages only" or something it'd be awesome!