PDF-ShellTools > General
Displaying PDF Page Size in Windows Explorer
RTT:
Check if the attached script, a modification of the first script to also fill a PageOrientation named property, does the job.
Don't forget to configure a metadata property named "PageOrientation", before testing.
The script code, for easy reference.
--- Code: ---var ProgressBar = pdfe.ProgressBar;
ProgressBar.max = pdfe.SelectedFiles.Count;
for (var i = 0; i < pdfe.SelectedFiles.Count; i++) {
ProgressBar.position = i + 1;
var file = pdfe.SelectedFiles(i);
var Page = file.Pages(0);
if (Page) {
var w = Math.min(Page.Width, Page.Height);
var h = Math.max(Page.Width, Page.Height);
var PSizeStr = w.toFixed() + 'x' + h.toFixed();
var FileMetadata = file.Metadata;
var Changed = false;
if (FileMetadata.PageSize !== PSizeStr) {
FileMetadata.PageSize = PSizeStr;
Changed = true;
}
var PageOrientationStr;
(Page.Height > Page.Width) ? PageOrientationStr = 'Portrait' : PageOrientationStr = 'Landscape';
if (FileMetadata.PageOrientation !== PageOrientationStr) {
FileMetadata.PageOrientation = PageOrientationStr;
Changed = true;
}
if (Changed) {
if (FileMetadata.CommitChanges()) {
pdfe.echo(file.Filename + ' : (' + PSizeStr + ' - ' + PageOrientationStr + ') [OK]');
} else {
pdfe.echo(file.Filename + ' [commit changes failed]', 0xFF0000);
}
} else {
pdfe.echo(file.Filename + ' : (' + PSizeStr + ' - ' + PageOrientationStr + ') [properties already set]');
}
}
}
pdfe.echo("Done");
--- End code ---
nightslayer23:
this only works for the first page?
RTT:
It's coded that way. Only the first page is checked for page orientation.
nightslayer23:
--- Quote from: RTT on March 04, 2020, 12:17:47 AM ---It's coded that way. Only the first page is checked for page orientation.
--- End quote ---
Could we adjust the script to look at every page and display them as a list similar to the page size check?
RTT:
Please give me a practical example, with an attached PDF or by describing the PDF pages size and orientation, of what you expect to be the result PageSize and PageOrientation metadata properties.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version