PDF to PNGs

Discussions on NConvert - the command line tool for image conversion and manipulation

Moderators: XnTriq, helmut, xnview

newmember
Posts: 4
Joined: Fri Nov 22, 2013 11:23 am

PDF to PNGs

Post by newmember »

Hello!

1. How can I set the filename of output PNGs like this: oriPDFname####.png instead of oriPDFname-#.png? The "-o %####" switch does not help.

2. After the conversion the PNGs' DPI does not match the source PDF's DPI. I have to use the -dpi switch. Is this a bug?

Thanks
User avatar
xnview
Author of XnView
Posts: 44922
Joined: Mon Oct 13, 2003 7:31 am
Location: France

Re: PDF to PNGs

Post by xnview »

newmember wrote: 1. How can I set the filename of output PNGs like this: oriPDFname####.png instead of oriPDFname-#.png? The "-o %####" switch does not help.
Do you use -n option?
2. After the conversion the PNGs' DPI does not match the source PDF's DPI. I have to use the -dpi switch. Is this a bug?
No, PDF is loaded with -dpi switch
Pierre.
newmember
Posts: 4
Joined: Fri Nov 22, 2013 11:23 am

Re: PDF to PNGs

Post by newmember »

Hello!

No I didn't use the -n switch because page count of PDF file was unknown. (I'm trying to write a common batch for processing PDF files.)
Now I have tried the -n switch but the output filenames were same as before "*-#" and redundant files were generated.
User avatar
xnview
Author of XnView
Posts: 44922
Joined: Mon Oct 13, 2003 7:31 am
Location: France

Re: PDF to PNGs

Post by xnview »

Do you have used something like

Code: Select all

nconvert -n 1 3 1 -o test####.png -out png file.pdf
Pierre.
newmember
Posts: 4
Joined: Fri Nov 22, 2013 11:23 am

Re: PDF to PNGs

Post by newmember »

I have tried 2 methods (with and without the -xall switch) (the source PDF has 6 pages):

Code: Select all

1.: nconvert.exe -n 1 3 1 -xall -o test_2_####.png -out png sporce_pdf.pdf
The result (all the pages were extracted but the naming was not adequate ("-#") and the 3 filesets were identical):
test_2_0001-0.png
test_2_0001-1.png
test_2_0001-2.png
test_2_0001-3.png
test_2_0001-4.png
test_2_0001-5.png

test_2_0002-0.png
test_2_0002-1.png
test_2_0002-2.png
test_2_0002-3.png
test_2_0002-4.png
test_2_0002-5.png

test_2_0003-0.png
test_2_0003-1.png
test_2_0003-2.png
test_2_0003-3.png
test_2_0003-4.png
test_2_0003-5.png

Code: Select all

2.: nconvert.exe -n 1 3 1 -o test####.png -out png source_pdf.pdf
The result (the generated PNGs contain only the first page of the PDF file):
test0001.png
test0002.png
test0003.png

Thanks
User avatar
xnview
Author of XnView
Posts: 44922
Joined: Mon Oct 13, 2003 7:31 am
Location: France

Re: PDF to PNGs

Post by xnview »

newmember wrote:I have tried 2 methods (with and without the -xall switch) (the source PDF has 6 pages):

Code: Select all

1.: nconvert.exe -n 1 3 1 -xall -o test_2_####.png -out png sporce_pdf.pdf
Oh sorry right, the page number is added as '#', and -n must not be used here.
I need to add a template for page number...
Pierre.
newmember
Posts: 4
Joined: Fri Nov 22, 2013 11:23 am

Re: PDF to PNGs

Post by newmember »

Thank you for the reply!
pedronac
Posts: 10
Joined: Mon Feb 29, 2016 12:49 pm

Re: PDF to PNGs

Post by pedronac »

xnview wrote:
newmember wrote:I have tried 2 methods (with and without the -xall switch) (the source PDF has 6 pages):

Code: Select all

1.: nconvert.exe -n 1 3 1 -xall -o test_2_####.png -out png sporce_pdf.pdf
Oh sorry right, the page number is added as '#', and -n must not be used here.
I need to add a template for page number...

Hello Pierre,
Any news on that ?

I have the simillar problem using -xall from a 24 pages pdf.
Using

Code: Select all

nconvert -dither -grey 256 -crop 42 250 945 200 -out png -xall -dpi 250 -o test-### -n 35 104 3 test.pdf
I get 576 images (24 images x 24 pages) :
test-035-0.png
test-035-1.png
test-035-2.png
...
test-035-23.png
test-038-0.png
test-038-1.png
...
test-038-23.png
...
...
test-104-23.png

The annoing point is that there are 24 times more images than necessary.
Because all test-###-0.png images are identical to each other.
The image test-035-0.png = test-038-0.png = test-041-0.png = ... = test-104-0.png
The same is true to test-###-1.png and so on.

I expected to have a cropped image from of each page.
I my case, I would like to have 24 files like this :

test-035.png = crop 42 250 945 200 of page 1
test-038.png = crop 42 250 945 200 of page 2
test-041.png = crop 42 250 945 200 of page 3
test-044.png = crop 42 250 945 200 of page 4
test-047.png = crop 42 250 945 200 of page 5
test-050.png = crop 42 250 945 200 of page 6
test-053.png = crop 42 250 945 200 of page 7
test-056.png = crop 42 250 945 200 of page 8
test-059.png = crop 42 250 945 200 of page 9
test-062.png = crop 42 250 945 200 of page 10
test-065.png = crop 42 250 945 200 of page 11
test-068.png = crop 42 250 945 200 of page 12
test-071.png = crop 42 250 945 200 of page 13
test-074.png = crop 42 250 945 200 of page 14
test-077.png = crop 42 250 945 200 of page 15
test-080.png = crop 42 250 945 200 of page 16
test-083.png = crop 42 250 945 200 of page 17
test-086.png = crop 42 250 945 200 of page 18
test-089.png = crop 42 250 945 200 of page 19
test-092.png = crop 42 250 945 200 of page 20
test-095.png = crop 42 250 945 200 of page 21
test-098.png = crop 42 250 945 200 of page 22
test-101.png = crop 42 250 945 200 of page 23
test-104.png = crop 42 250 945 200 of page 24
User avatar
xnview
Author of XnView
Posts: 44922
Joined: Mon Oct 13, 2003 7:31 am
Location: France

Re: PDF to PNGs

Post by xnview »

hum -n can't be used like that. It's for input files.
Pierre.