[softwarelist] Re: Potential TransPDF improvements

  • From: Peter Newble <peter@xxxxxxxxxx>
  • To: davidpilling@xxxxxxxxxxxxx
  • Date: Tue, 29 Jan 2019 23:34:58 +0000

On 29 Jan 2019, at 21:58, David Pilling <david@xxxxxxxxxxxxxxxx> wrote:


I see what follows is missing from the list archive - it could be useful - so 
I'm reposting it.

Peter's notes tell anyone how to add their own filter to OP on Windows.

If you want to use ImageMagick to import transparent PNG files or something 
similar.

A postscript (pun intended) to that:

I had forgotten that the ImageMagick attribute ‘-density’ (for setting output 
resolution in dpi) only works if it precedes the input filename in the command 
line. Thus the TransPDF.cmd batch file should be:

if exist C:\Temp.tif del C:\Temp.tif
if exist C:\Temp.eps del C:\Temp.eps
"C:\Program Files\gs\gs9.26\bin\gswin32c.exe" -dSAFER -dBATCH -dNOPAUSE 
-sDEVICE=eps2write -sOutputFile=C:\Temp.eps -r600 -q -dFirstPage=1 -dLastPage=1 
%1
"C:\Program Files\ImageMagick-7.0.8-Q16-HDRI\convert.exe" -density 300 -depth 8 
-type TrueColorMatte %1[0] C:\Temp.tif
"C:\Program Files\epstool-3.09\bin\epstool.exe" --add-user-preview C:\Temp.tif 
C:\Temp.eps %2
if exist C:\Temp.tif del C:\Temp.tif
if exist C:\Temp.eps del C:\Temp.eps

Beware that there are only seven lines of commands there, not eleven as it was 
quoted in David’s posting, and the correct paths need to be used for the 
versions of Ghostscript, ImageMagick and epstools installed on your machine.

In the third line, ‘-r600’ sets a deliberately high resolution of 600dpi for 
any elements of the PDF which may only be rendered in a Postscript 2 EPS by 
rasterisation. However, in that case importing a PDF will usually be very slow 
and the resulting file very large. For many purposes ‘-r300’ would be 
sufficient, and much quicker.

In the fourth line, ‘-density 300’ creates a 300dpi preview image. Many might 
consider a 96dpi or 120dpi preview more appropriate for Windows, and it would 
certainly be quicker.

To recap, that should be saved as a file TransPDF.cmd in the same directory as 
the other transfilters (in my case C:\Program 
Files\DavidPilling\Filters\Filters) and regedit should be used to change the 
entry for TransPDF from

-T pdf eps -R "C:\Program Files\DavidPilling\Filters\Filters\TransPDF.exe"

to

-T pdf eps -R "C:\Program Files\DavidPilling\Filters\Filters\TransPDF.cmd"

Some PDFs cannot be converted and will cause an error when you try to import 
them. Others will appear to have been imported OK, because a valid preview 
image is generated, but then might cause a Postscript error when printed. (This 
has always been true of EPSs too, in my experience.) And, because this works by 
converting PDF to EPS, or trying to, it only applies when printing to 
Postscript drivers, otherwise presumably the preview image will be printed.

This is the equivalent batch file TransPNG.cmd, to replace the current 
TransPNG.exe in the same way but preserving transparency which TransPNG.exe 
does not. It too requires ImageMagick to be installed, but not Ghostscript or 
epstool. As David suggested, it converts the PDF to a TIFF (retaining 
transparency) then uses the existing TransTIF to convert that to a scaled 
sprite within a drawfile as Ovation Pro requires:

if exist C:\Temp.tif del C:\Temp.tif
"C:\Program Files\ImageMagick-7.0.8-Q16-HDRI\convert.exe" -type TrueColorMatte 
%1 C:\Temp.tif
"C:\Program Files\DavidPilling\Filters\Filters\TransTIF.exe" C:\Temp.tif %2
if exist C:\Temp.tif del C:\Temp.tif

Again, the path for TransTIF.exe must be correct and might be different on your 
machine (e.g. if using 64-bit Windows).

In all cases you might prefer, or need, to create Temp.tif and Temp.eps 
somewhere other than C:\


Peter.


Other related posts: