PDF-ShellTools > Ideas/Suggestions

Rasterizing PDFs?

<< < (2/4) > >>

nightslayer23:
Can you run a test with this file? :o

RTT:

--- Quote from: nightslayer23 on October 23, 2017, 02:34:19 AM ---I managed to get a different file to work with the image extractor, but it is only letting me do a PNG?

--- End quote ---
What other format were you expecting? The tool extracts PDF image objects or the rasterization of the pages.
The above script just takes advantage of the tool page rasterization functionality, to create a rasterized PDF by merging all the generated page rasterization images files into a new PDF.

RTT:

--- Quote from: nightslayer23 on October 23, 2017, 02:47:18 AM ---Can you run a test with this file? :o

--- End quote ---
Worked fine. Check attachment.

If you have the ImageMagick tool still installed, as when you requested a "Script to count how many colour pages in PDF?", check if this ImageMagick based rasterization script works for you.

--- Code: ---var RenderDPIs = 120;
//================================================================================

var imo = new ActiveXObject("ImageMagickObject.MagickImage.1");

var ProgressBar = pdfe.ProgressBar;
ProgressBar.max = pdfe.SelectedFiles.Count;

for (var i = 0; i < pdfe.SelectedFiles.Count; i++) {
    ProgressBar.position = i + 1;
    try {
        var File = pdfe.SelectedFiles(i),
            Filename = File.Filename,
            Pages = File.Pages;
        var Path = Filename.substr(0, Filename.lastIndexOf('\\') + 1),
            Name = Filename.substring(Path.length, Filename.lastIndexOf('.'));

        pdfe.echo(' > rasterizing ' + Filename);
        pdfe.echo(' ');
       
        var NewFilename = Path + Name + '_rasterized.pdf';
        imo.convert('-density',RenderDPIs, Filename, NewFilename);
        pdfe.echo('     Saved to: ' + NewFilename + ' [OK]', 0, 2)
    } catch (e) {
        pdfe.echo(e.message, 0xFF0000);
    }
}
pdfe.echo('Done');

--- End code ---
Not so fast as the above solution, and the generated PDF is bigger in size, but should be less cumbersome.

You need to give me more details about what fails with the first script, so I can figure out what may be the cause.

nightslayer23:

--- Quote from: RTT on October 23, 2017, 11:50:12 PM ---
--- Quote from: nightslayer23 on October 23, 2017, 02:34:19 AM ---I managed to get a different file to work with the image extractor, but it is only letting me do a PNG?

--- End quote ---
What other format were you expecting? The tool extracts PDF image objects or the rasterization of the pages.
The above script just takes advantage of the tool page rasterization functionality, to create a rasterized PDF by merging all the generated page rasterization images files into a new PDF.

--- End quote ---

In the image extractor tool (not the new script) I don't have the option of PNG or JPG or TIF etc?

In the help file / webpage it says that should be an option..

nightslayer23:

--- Quote from: RTT on October 24, 2017, 12:06:41 AM ---
--- Quote from: nightslayer23 on October 23, 2017, 02:47:18 AM ---Can you run a test with this file? :o

--- End quote ---
Worked fine. Check attachment.

If you have the ImageMagick tool still installed, as when you requested a "Script to count how many colour pages in PDF?", check if this ImageMagick based rasterization script works for you.

--- Code: ---var RenderDPIs = 120;
//================================================================================

var imo = new ActiveXObject("ImageMagickObject.MagickImage.1");

var ProgressBar = pdfe.ProgressBar;
ProgressBar.max = pdfe.SelectedFiles.Count;

for (var i = 0; i < pdfe.SelectedFiles.Count; i++) {
    ProgressBar.position = i + 1;
    try {
        var File = pdfe.SelectedFiles(i),
            Filename = File.Filename,
            Pages = File.Pages;
        var Path = Filename.substr(0, Filename.lastIndexOf('\\') + 1),
            Name = Filename.substring(Path.length, Filename.lastIndexOf('.'));

        pdfe.echo(' > rasterizing ' + Filename);
        pdfe.echo(' ');
       
        var NewFilename = Path + Name + '_rasterized.pdf';
        imo.convert('-density',RenderDPIs, Filename, NewFilename);
        pdfe.echo('     Saved to: ' + NewFilename + ' [OK]', 0, 2)
    } catch (e) {
        pdfe.echo(e.message, 0xFF0000);
    }
}
pdfe.echo('Done');

--- End code ---
Not so fast as the above solution, and the generated PDF is bigger in size, but should be less cumbersome.

You need to give me more details about what fails with the first script, so I can figure out what may be the cause.

--- End quote ---

This solution was actually much faster.. ? The other is literally just stuck displaying this:
 > rasterizing O:\12010 COOKE & D\og\combined revised hyd-0001.pdf
 Page 1/1

I'll leave ot be and see how long it takes but at this point it doesn't seem to want to spit out a file.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version