Recent Posts

Pages: 1 ... 8 9 [10]
91
Ideas/Suggestions / Re: Script to count how many colour pages in PDF?
« Last post by nightslayer23 on July 19, 2017, 12:29:43 AM »
whatever ISN'T white space..
Not easy to find a ImageMagick set of commands to calculate this properly for all the situations, even because I'm not an expert on this subject, but thresholding the image, to convert to black all non-white pixels, and then calculating the page percentage of black pixels seems to be giving good results.
Code: [Select]
var imo = new ActiveXObject("ImageMagickObject.MagickImage.1");
var fso = new ActiveXObject("Scripting.FileSystemObject");

var tmpfolder = fso.GetSpecialFolder(2 /*TemporaryFolder*/ );
var InfoFilename = tmpfolder + '\\PagesInfo.txt';

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 FileMetadata = file.Metadata;

    //Bypass already processed files.
    if (FileMetadata.InkCoverage) {
        pdfe.echo(file.filename + ': Ink coverage = ' + FileMetadata.InkCoverage);
        pdfe.echo(' [Already set]', 0xFF, 1);
        continue;
    }

    pdfe.echo('Processing ' + file.filename + ' (' + file.NumPages + ' pages)');
    try {
        //use imagemagick to render each pdf page, convert all non-white colors to black
        //and calculate the average of black pixels, that correspond to the percentage of non-white area.

        //imo.convert(file.filename, "-fuzz","1%","-fill","white","opaque","white","-fill","black","+opaque","white","-format", "%[fx:100-mean*100]\n", "info:" + InfoFilename);               
        imo.convert(file.filename, "-colorspace", "gray", "-auto-level", "-threshold", "99%", "-format", "%[fx:100-mean*100]\n", "info:" + InfoFilename);

        //read the result info file, that contains a line of ink coverage percentage value for each page.
        var f = fso.GetFile(InfoFilename);
        var fts = f.OpenAsTextStream();
        var PagesInkCoverage = fts.ReadAll().split('\n');
        fts.Close();
        f.Delete();

        //calculate the document total ink coverage by averaging the by page values.
        var InkCoverage = 0;
        for (var index = 0, len = PagesInkCoverage.length - 1; index < len; index++) {
            InkCoverage += Number(PagesInkCoverage[index]);
        }
        InkCoverage = Math.round((InkCoverage / (len ? len : 1)));

        pdfe.echo(file.filename + ': Ink coverage=' + InkCoverage + '%', 0, 2);

        if (FileMetadata.InkCoverage !== InkCoverage.toString()) {
            FileMetadata.InkCoverage = InkCoverage;
            if (FileMetadata.CommitChanges()) {
                pdfe.echo(' [OK]', 0x006400, 1);
            } else {
                pdfe.echo(' [Setting metadata failed]', 0xFF0000, 1);
            }
        } else {
            pdfe.echo(' [Already set]', 0xFF, 1);
        }

    } catch (e) {
        pdfe.echo(file.filename + ' : ', 0, 2);
        pdfe.echo(e.name + ' ( ' + e.message + ' )', 0xff0000, 1);
    }
}

pdfe.echo('Done');
This script expects a custom property named InkCoverage and to show in the Shell this ink coverage percentage value as ranges named "Line", "Medium" or "High", this custom property needs to be configured as depicted in the attached screenshots.

If it's not giving the expected results, better if you ask in a ImageMagick forum on how to calculate this and then we can update the script with a better set of image processing/analysis commands.


Is there a way for the file to be flattened first before doing this conversion? Some work perfectly, but others come out at a really high percentage when they aren't technically going to print that way. I figured it was looking at other layers or some other hidden info and converting that to bw too.

I did a test saving one to jpg, converting it back to pdf then running the tool again which gave me an accurate result. However the process to convert one to jpg and back to pdf was quite slow. I am needing to colm over hundreds of files at once with this tool to get a fast result. So would i be possible in code to first flatten layers before running the check?

I actually batch flattened layers in acrobat and it didn't solve the issue.. I had to batch flatten AND convert everything to CMYK to get it to work.

In the optimizer tool, can CMYK and RGB colour spaces be added somehow? Because Acrobat is just way too slow at doing these steps.. your tool is much faster!
92
Ideas/Suggestions / Re: Remove illegal charters from file names
« Last post by Spinnaker on July 14, 2017, 09:23:24 AM »
Happy to beta test  ;)
93
Ideas/Suggestions / Re: Remove illegal charters from file names
« Last post by RTT on July 14, 2017, 01:15:40 AM »
Good idea! I've just finished to add code that, if pasting to the filename field, removes these invalid characters from the capture assisted text.

I'm also adding the possibility to execute text format scripts, triggered from the assistant extra format functions button, to extend the current "capitalize, "lowercase" and "uppercase" only possibilities.
94
Ideas/Suggestions / Remove illegal charters from file names
« Last post by Spinnaker on July 13, 2017, 12:20:19 PM »
The Metadata capture wizard is a great help, however, the selected text may contain reserved characters that cannot be used in file name.

It would be really helpful if there was an option to remove these characters or have a user option to substitute, e.g. with a "-" or a "_".

List of reserved characters:
Code: [Select]
< (less than)
> (greater than)
: (colon)
" (double quote)
/ (forward slash)
\ (backslash)
| (vertical bar or pipe)
? (question mark)
* (asterisk)
95
Ideas/Suggestions / Re: 6 great new features!
« Last post by RTT on June 28, 2017, 02:30:42 AM »
Quote
3) Convert text to image PDF ( curve fonts)
Not a very good practice, and only useful for very specific scenarios needed by users that already have access to tools that can do this.
This function is used quite often, for example, to reduce the size of text- based pdf file. It is implemented in the Actomat program, http://apps.kuczynski.pl
it works automatically when binarizing pdf. Used Leptonica library http://www.leptonica.com
That program only converts all the source files to black and white images (for PDFs, it renders each PDF to a image first) and then creates a PDF with these images. It's like a fax2pdf, without OCR, converter. No such advanced text to outlines (curves) functionality available.
And converting text to outlines usually increases the data size, so it's not a solution to reduce the file size.

Quote
Quote
6) Send the  pdf file to the program-compressor
These compressors do not support the command line:( but PDF-ShellTools script will help fix it))
If there is no command line, nor COM automation, how do you command these tools from a script?
I'm not an expert, but can not I make a script:
1) In the context menu of the pdf file(s), open the line PDF Shelltools "Compress with..." (Specific settings are filled in by the user himself)
2)Starting the compressor program
3)Automatically transfer of the file(s) icon to the compressor program window.
Then you can manually select the compression mode and start
This will be similar to "Send to" command, if the program-compressor supported the command line
For such a simple task, i.e. to provide a shell context menu to run that external program with the selected files, and if that application installer doesn't do that for you, or you want to provide your custom command line parameters, just create a My Tool to easily add it to the shell context menu. Check attached screenshot for details.

Or you may manually register a custom static verb.
96
Ideas/Suggestions / Re: Pdfshelltools - print function
« Last post by AHN on June 28, 2017, 12:22:24 AM »
You are right. Tabs appear now. Next step ..I will try. Have a nice day.Thanks.
97
Ideas/Suggestions / Re: Pdfshelltools - print function
« Last post by RTT on June 27, 2017, 04:11:55 PM »
Using the Windows registry editor, check if you have a dword value named MyScripts set to 0, at the HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\PDFShellTools\Options\FeaturesState key (or at HKEY_LOCAL_MACHINE\SOFTWARE\PDFShellTools\Options\FeaturesState if Windows is 32-bit). If yes, change its value to 1.
If the key or value doesn't exists, create it and set the value to 1.
Check if now the manager shows the missing settings tabs.
98
Ideas/Suggestions / Re: Pdfshelltools - print function
« Last post by AHN on June 27, 2017, 03:56:13 AM »
Have a nice day.

Thank you for your advise and good program again.

Screenshot is attached. (win 10, 7, xp - now I tested my pc - all the same.)
99
Ideas/Suggestions / Re: 6 great new features!
« Last post by Lev R. on June 27, 2017, 01:13:42 AM »
Quote
3) Convert text to image PDF ( curve fonts)
Not a very good practice, and only useful for very specific scenarios needed by users that already have access to tools that can do this.
This function is used quite often, for example, to reduce the size of text- based pdf file. It is implemented in the Actomat program, http://apps.kuczynski.pl
it works automatically when binarizing pdf. Used Leptonica library http://www.leptonica.com

Quote
6) Send the  pdf file to the program-compressor
These compressors do not support the command line:( but PDF-ShellTools script will help fix it))
If there is no command line, nor COM automation, how do you command these tools from a script?
I'm not an expert, but can not I make a script:
1) In the context menu of the pdf file(s), open the line PDF Shelltools "Compress with..." ( Specific settings are filled in by the user himself)
2)Starting the compressor program
3)Automatically transfer of the file(s) icon to the compressor program window.
Then you can manually select the compression mode and start
This will be similar to "Send to" command, if the program-compressor supported the command line

P.S. Sorry for bad english, i use Google Translator
100
Ideas/Suggestions / Re: Pdfshelltools - print function
« Last post by RTT on June 27, 2017, 12:07:28 AM »
Interesting! All these tabs should be showing.
Please attach a screenshot of that situation, so I can take a look. You need to register in the forum as user, to be able to attach files/images to your replies.
Pages: 1 ... 8 9 [10]