0
votes

I want to convert a PDF file to PNG, I want the output to be 595*842 with high resolution,

I used this command:

gswin64.exe -q -sDEVICE=png16m -dSAFER -dMaxBitmap=1000000000 -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -dPDFFitPage=true -sDEVICE=pngalpha -dBATCH -dNOPAUSE -sOutputFile=C:\cover.png C:\cover.pdf

I know that I can use -r300 but it will change the dimension to 2479*3509 also, I've tried -sPAPERSIZE=a4 + -r300 which didn't work.

How can I have the output in 595x842 with high resolution?

Current code:

ProcessInfo = new System.Diagnostics.ProcessStartInfo( "gswin64.exe", "-q -sDEVICE=pngalpha -dBATCH -dNOPAUSE -sOutputFile=C:\\Users\\MNiyatkhair\\Desktop\\cairoCopy\\cover.png C:\\Users\\MNiyatkhair\\Desktop\\cairoCopy\\Holding.pdf" ); 
// -r300 
ProcessInfo.CreateNoWindow = true; 
ProcessInfo.UseShellExecute = true; 
ProcessInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; 
Process = Process.Start(ProcessInfo); Process.WaitForExit(); 
1
What does "with high resolution" mean? How is it different from 595*842? What does this have to do with C#?Gabe
my code is like this now: ProcessInfo = new System.Diagnostics.ProcessStartInfo("gswin64.exe", "-q -sDEVICE=pngalpha -dBATCH -dNOPAUSE -sOutputFile=C:\\Users\\MNiyatkhair\\Desktop\\cairoCopy\\cover.png C:\\Users\\MNiyatkhair\\Desktop\\cairoCopy\\Holding.pdf"); // -r300 ProcessInfo.CreateNoWindow = true; ProcessInfo.UseShellExecute = true; ProcessInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; Process = Process.Start(ProcessInfo); Process.WaitForExit();Mina N
i want the dimension of the png to be 595*842Mina N
It sounds like you just want to know how to make your PDF render to 595x842. Did you try -r72?Gabe
if I don't specify resolution, the png file will be 595*842, but I want a higher resolution with the same dimension and -r72 don't change any thing.Mina N

1 Answers

1
votes

You can try to increase the image resolution (for example -r(72*3)) and add proportional downscale factor -dDownScaleFactor=3. It will work like native PDF MatrixTransform.