Recent Posts

Pages: 1 ... 5 6 [7] 8 9 10
61
Ideas/Suggestions / Re: replace filename
« Last post by RTT on January 18, 2023, 02:29:20 AM »
Not possible while using the builtin ReplaceS function (the parameters are fixed, not parsed for dynamic content), but doable with a custom script.

With a custom script, named ReplaceStr, with this code:
Code: [Select]
function ReplaceStr() {
    var params = CurrentField.value.split(',', 3);
    if (params.length == 3) {
        return params[0].replace(params[1], params[2]);
    }
}
you can then use this syntax: [ReplaceStr](source,searchValue,newValue)
With your example: [ReplaceStr]([F],replace this,[myScript])
62
Ideas/Suggestions / replace filename
« Last post by Nick Riviera on January 17, 2023, 08:43:20 AM »
Hello,
...can I replace a string from a filename with a custom script...?

something like this:

[ReplaceS:replace this|[myScript]]([f])
63
Ideas/Suggestions / Re: Script For Shuffle (Random)
« Last post by nightslayer23 on October 13, 2022, 02:59:12 AM »
worked perfectly   ;D ;D thankyou again!
64
Ideas/Suggestions / Re: Script For Shuffle (Random)
« Last post by RTT on October 13, 2022, 01:54:28 AM »
Check if this works.
Code: [Select]
var Merger = pdfe.CreateDocumentMerger();
var ProgressBar = pdfe.ProgressBar;
ProgressBar.max = pdfe.SelectedFiles.Count;
var MainPageIndex = 0;
for (var i = 0; i < pdfe.SelectedFiles.Count; i++) {
    var File = pdfe.SelectedFiles(i);
    var Filename = File.Filename;
    pdfe.echo('Shuffling ' + Filename);
    ProgressBar.position = i + 1;
    var Pages = File.Pages;
    ShuffledIndexesArray = createShuffledIndexesArray(Pages.Count);

    for (var p = 0; p < ShuffledIndexesArray.length; p++) {
        var Page = Pages(ShuffledIndexesArray[p]);
        Merger.MergePage(Page);
    }
    var newFilename = Filename.substring(0, Filename.lastIndexOf('.')) + '_Shuffled.pdf';
    Merger.EndAndSaveTo(newFilename);
    pdfe.echo(' [OK]', 0, 1);
}
pdfe.echo('Done.');

/*https://stackoverflow.com/questions/2450954/how-to-randomize-shuffle-a-javascript-array
Randomize array in-place using Durstenfeld shuffle algorithm */
function shuffleArray(array) {
    for (var i = array.length - 1; i > 0; i--) {
        var j = Math.floor(Math.random() * (i + 1));
        var temp = array[i];
        array[i] = array[j];
        array[j] = temp;
    }
}

function createShuffledIndexesArray(N) {
    var Indexes = [];
    for (var i = 0; i < N; i++) {
        Indexes.push(i);
    }
    shuffleArray(Indexes);
    return Indexes
}
65
Ideas/Suggestions / Script For Shuffle (Random)
« Last post by nightslayer23 on October 12, 2022, 06:48:32 AM »
Hi again, would you be able to write a custom script for shuffling the PDF page order from a multipage pdf?
66
Ideas/Suggestions / Re: Stamps: Filename (without file extension)
« Last post by RTT on October 08, 2022, 01:42:36 AM »
That's not possible with the current version. Only the standard PDF fonts can be used.
67
Ideas/Suggestions / Re: Stamps: Filename (without file extension)
« Last post by nightslayer23 on October 07, 2022, 07:53:21 AM »
How can we add more font choices to the list?
68
Ideas/Suggestions / Re: Script to count how many colour pages in PDF?
« Last post by Nick Riviera on August 22, 2022, 08:36:52 AM »
Thank you.

works with this version ImageMagick-7.1.0-8-Q16-HDRI-x86-dll.exe


It seems the ActiveX ImageMagickObject is not included anymore in the installer (Windows Installer option ImageMagickObject is missing).
Get the old version installer, that includes it, from the Wayback Machine website. Don't forget to select the "Install ImageMagickObject OLE Control for VBScript,..." when installing it.
69
Ideas/Suggestions / Re: Script to count how many colour pages in PDF?
« Last post by RTT on August 19, 2022, 02:47:44 AM »
It seems the ActiveX ImageMagickObject is not included anymore in the installer (Windows Installer option ImageMagickObject is missing).
Get the old version installer, that includes it, from the Wayback Machine website. Don't forget to select the "Install ImageMagickObject OLE Control for VBScript,..." when installing it.
70
Ideas/Suggestions / Re: Script to count how many colour pages in PDF?
« Last post by Nick Riviera on August 18, 2022, 07:53:07 AM »
hello,
I also tried this script but  is not working or did I do something wrong. It gives me this "Error (11,0): Automation server can't create object"
I installed this version "ImageMagick-7.1.0-46-Q16-x86-dll" because there is no other older version and this version of https://www.ghostscript.com/releases/gsdnld.html
Thank you

That's functionality not directly available from the scripts API but we can create a script to automate the ImageMagick tool and get that info.
The idea is to render each PDF page and analyze the result bitmaps for color content.

Made some test and here is a sample script that creates a .csv file with a "Color Pages Count" and "BW/Gray Page Count" columns. It renders each PDF page, converts the result bitmaps to the HSI colorspace and computes the mean value of the saturation channel. The page is considered colorized if this value is higher than 0, or BW/Gray otherwise. You may adjust this threshold to your needs.


To test it, just import the attached .myscript file into the PDF-ShellTools My Scripts, and you will get a "Number of Color and BW/Gray pages" named script, you can invoke for all the selected PDF files from the Windows shell PDF files context menu, from the PDF-ShellTools>My Scripts sub menu.
The scrip needs to have the 32-bit version of the ImageMagick tool installed. I've tested with the ImageMagick-7.0.5-5-Q16-x86-dll.exe one. While installing, make sure you select the "Install ImageMagickObject OLE Control for VBScript,..." option, under the "additional tasks" page of the installer.
The ImageMagick also needs to have the Ghostscript tool installed, to handle the PDF format.

If the script is performing as needed we can change it to put the info into custom metadata properties, as you suggested.
Pages: 1 ... 5 6 [7] 8 9 10