Page 1 of 3
Converting a multi-page PDF to a multi-page PDF
Posted: Mon Mar 29, 2021 1:50 pm
by IxenPDF
Hello,
I have tried to convert my multi-page pdf into a brighter multi page pdf.
Problem:
The source pdf has 9 pages. Each page has a page number. So page 1 has the number 1, page 2 has the number 2 and so on.
After the conversion I have a pdf also with 9 pages.
My expectation was, that now also page 1 has the number 1 and page 2 has the number 2 and so on.
But: All 9 pages of the target pdf have now the number "1" in it.
What do I miss?
Here is what I have done:
1. I have created the command via XnViewMP (export for NConvert function).
This way I got this:
Code: Select all
nconvert -brightness 124 -gamma 0.72 -o png -clevel 9
2. I have downloaded and installed this:
http://download.xnview.com/NConvert-linux64.tgz
3. I have modified the command into:
Code: Select all
$ ./nconvert -brightness 124 -gamma 0.72 -multi -clevel 9 -out pdf -multi -o XnVOut 10pages.pdf
So this is the output of my terminal:
Code: Select all
$ ./nconvert -brightness 124 -gamma 0.72 -multi -clevel 9 -out pdf -multi -o XnVOut 10pages.pdf
** NCONVERT v7.39 (c) 1991-2019 Pierre-E Gougelet (Feb 25 2020/13:19:45) **
Version for Linux x86 (X11) (All rights reserved)
** This is freeware software (for non-commercial use)
Over...
Conversion of 10pages.pdf into XnVOut_3.pdf OK
Over...
Conversion of 10pages.pdf into XnVOut_3.pdf OK
Over...
Conversion of 10pages.pdf into XnVOut_3.pdf OK
Over...
Conversion of 10pages.pdf into XnVOut_3.pdf OK
Over...
Conversion of 10pages.pdf into XnVOut_3.pdf OK
Over...
Conversion of 10pages.pdf into XnVOut_3.pdf OK
Over...
Conversion of 10pages.pdf into XnVOut_3.pdf OK
Over...
Conversion of 10pages.pdf into XnVOut_3.pdf OK
Over...
Conversion of 10pages.pdf into XnVOut_3.pdf OK
After the conversion I have a pdf also with 9 pages.
My expectation was, that now also page 1 has the number 1 and page 2 has the number 2 and so on.
But: All 9 pages of the target pdf have now the number one in it.
What do I miss? Would appreciate some help. Thank you.
Re: converting multi-page pdf
Posted: Mon Mar 29, 2021 2:44 pm
by cday
Your output is a 9-page file with each page the first page of the source file?
On some details, comments that may or not actually be relevant:
In your terms:
Code: Select all
-multi -clevel 9 -out pdf -multi -o XnVOut
I don't think you need the first
-multi, I would expect:
Code: Select all
-out pdf -multi -clevel 9 -o XnVOut
Also the:
term has no file extension, but possibly that doesn't matter in practice.
The NConvert documentation is in some respects limited, so one uses what one has found from experience to work, which doesn't mean that alternative code won't work!
I'm using Linux (Mint) now but still have to boot into Windows to run NConvert, as I haven't made the transition to running it in Linux yet, and in Windows I normally work using batch files as that works well for me.
Edit:
Checking the NConvert help file, for PDF output you need to use
-c value, not
-clevel which sets the compression level for a PNG file, so
-c 1 for fax compression, for example.
Code: Select all
-c value : Compression number
default : 0 (uncompressed)
PDF : 1 (Fax), 2 (Rle), 3 (LZW), 4(ZIP), 5 (JPEG)
TIFF : 1 (Rle), 2 (LZW), 3 (LZW+Prediction)
4 (ZLIB)
5 (CCITT G3), 6 (CCITT G3-2D), 7 (CCITT G4) only B/W
8 (JPEG) only 24/32 bits
TARGA, Softimage, SGI, PCX, IFF, BMP : 1 (Rle)
-c_bw value : Compression number for black&white picture (default : 0)
-c_grey value : Compression number for greyscale picture (default : 0)
-c_rgb value : Compression number for color picture (default : 0)
-q value : JPEG/FPX/WIC/PDF quality (default : 85)
-clevel value : PNG Compression level (default : 6)
Re: Converting a multi-page PDF to a multi-page PDF
Posted: Mon Mar 29, 2021 3:07 pm
by IxenPDF
Thank you for your tips.
Your output is a 9-page file with each page the first page of the source file?
Yes, exactly.
I have now all your tips implemented. So the code now looks like this:
Code: Select all
$ ./nconvert -brightness 124 -gamma 0.72 -out pdf -multi -c 0 -o XnVOut.pdf 10pages.pdf
But unfortunately the result is the same.
Re: Converting a multi-page PDF to a multi-page PDF
Posted: Mon Mar 29, 2021 3:20 pm
by cday
Are you able to upload the source file or another file that illustrates the problem that I can test?
I don't immediately have another idea, but you could possibly try inserting -xall early in your code, that should extract the individual pages, although from memory I don't thing that term is necessary.
Otherwise, you could use two steps: first extract the pages, then in a separate line of code form a new multi-page file.
You also don't have a -DPI term, which means that the default GS rather value of 72 will be used, I believe.
When you check the output file you are remembering, if you check in XnView software, to use the small arrows to step through the pages?
Re: Converting a multi-page PDF to a multi-page PDF
Posted: Mon Mar 29, 2021 3:28 pm
by IxenPDF
Thank you.
Here is the source file:
Re: Converting a multi-page PDF to a multi-page PDF
Posted: Mon Mar 29, 2021 3:44 pm
by cday
IxenPDF wrote: Mon Mar 29, 2021 3:28 pm
Thank you.
Here is the source file:
10pages.pdf
Your source file is 24-bit colour, you may need to convert to black and white before outputting to a 1-bit TIFF, I'm not immediately sure...
I'm attaching a 3-page 1-bit Fax compression PDF that I've created as a test file, the pages are in the wrong order due to a quirk in the XnView MP creation interface, please test your code with that file to check if you get the correct result.
Re: Converting a multi-page PDF to a multi-page PDF
Posted: Mon Mar 29, 2021 3:58 pm
by IxenPDF
Thank you.
Same behaviour. Here is my output:
With this command:
Code: Select all
$ ./nconvert -brightness 124 -gamma 0.72 -out pdf -multi -c 0 -o XnVOut.pdf M-PDF3-1.pdf
** NCONVERT v7.39 (c) 1991-2019 Pierre-E Gougelet (Feb 25 2020/13:19:45) **
Version for Linux x86 (X11) (All rights reserved)
** This is freeware software (for non-commercial use)
Over...
Conversion of M-PDF3-1.pdf into XnVOut.pdf OK
Over...
Conversion of M-PDF3-1.pdf into XnVOut.pdf OK
Over...
Conversion of M-PDF3-1.pdf into XnVOut.pdf OK
Re: Converting a multi-page PDF to a multi-page PDF
Posted: Mon Mar 29, 2021 4:06 pm
by cday
Yes same result, could you please post your latest code in case you missed any edits I made to my earlier posts.
I'll try to have a look later on another laptop booted into Windows 10 but strictly offline...

Re: Converting a multi-page PDF to a multi-page PDF
Posted: Mon Mar 29, 2021 4:37 pm
by IxenPDF
Code: Select all
$ ./nconvert -brightness 124 -gamma 0.72 -out pdf -multi -c 0 -o XnVOut.pdf M-PDF3-1.pdf
Re: Converting a multi-page PDF to a multi-page PDF
Posted: Mon Mar 29, 2021 6:06 pm
by cday
I have now tested in Windows and found the immediate issue, something I had mentioned above as a possibility but thought unlikely.
It is necessary to insert a
-xall term, which extracts the individual page images: that is used when it is wished to extract the page images to a folder for use, I had forgotten that it is also needed when converting a multi-page file directly to a multi-page file, but that seems to be the case.
This is the basic code:
Code: Select all
nconvert -xall -dpi 72 -out pdf -multi -o XnVOut.pdf 10pages.pdf
Your source page images are 24-bit colour as are the above output page images, you will probably wish to add suitable compression as required, for example JPEG compression with an appropriate compression setting, information in the help file.
The
-dpi 72 term is probably actually unnecessary as that is the GhostScript default value, however a higher value can be set if required.
You can also add the other conversion options that you need.
Re: Converting a multi-page PDF to a multi-page PDF
Posted: Mon Mar 29, 2021 8:13 pm
by IxenPDF
Wow. This has worked. You are my hero.
With the command:
Code: Select all
$ ./nconvert -brightness 124 -gamma 0.72 -xall -dpi 300 -out pdf -multi -c 0 -o XnVOut.pdf M-PDF3-1.pdf
Thank you.
Re: Converting a multi-page PDF to a multi-page PDF
Posted: Tue Mar 30, 2021 8:43 am
by IxenPDF
An other question has occured:
1. I make a pdf with dpi 300
2. I run the command "nconvert -info"
My expectation was, that now "-info" will show me
But it shows me:
Very confusing? What do I miss?
Here is what I have exactly done in the terminal:
Code: Select all
IxenPdf@IxenPdf:~/Downloads/NConvert
$ ./nconvert -brightness 124 -gamma 0.72 -xall -dpi 300 -out pdf -multi -c 0 -o XnVOut.pdf M-PDF3-1.pdf
** NCONVERT v7.39 (c) 1991-2019 Pierre-E Gougelet (Feb 25 2020/13:19:45) **
Version for Linux x86 (X11) (All rights reserved)
** This is freeware software (for non-commercial use)
Over...
Conversion of M-PDF3-1.pdf into XnVOut_3.pdf OK
Over...
Conversion of M-PDF3-1.pdf into XnVOut_3.pdf OK
Over...
Conversion of M-PDF3-1.pdf into XnVOut_3.pdf OK
And after:
Code: Select all
IxenPdf@IxenPdf:~/Downloads/NConvert
$ ./nconvert -info XnVOut_3.pdf
** NCONVERT v7.39 (c) 1991-2019 Pierre-E Gougelet (Feb 25 2020/13:19:45) **
Version for Linux x86 (X11) (All rights reserved)
** This is freeware software (for non-commercial use)
Over...
XnVOut_3.pdf : Success
Format : Portable Document Format
Name : pdf
Compression : Uncompressed
Width : 359
Height : 359
Components per pixel : 3
Bits per component : 8
Depth : 24
# colors : 16777216
Color model : RGB
Bytes Per Plane : 1077
Orientation : Top Left
Xdpi : 72
Ydpi : 72
Page(s) : 3
Info:
PhotometricInterpretation: 2
PlanarConfiguration: 1
SamplesPerPixel: 3
DateTime: 2021:03:30 10:35:55
Software: GPL Ghostscript 9.27
Metadata : ( EXIF ICC )
Color Profile : Artifex Software sRGB ICC Profile
Re: Converting a multi-page PDF to a multi-page PDF
Posted: Tue Mar 30, 2021 8:55 am
by cday
IxenPDF wrote: Tue Mar 30, 2021 8:43 am
What do I miss?
I suspect the problem is that GS opens files using a default DPI value of 72, unless a specific value is set in the code used...
If you don't have one already you should insert a
-dpi 300 term in your code, that should result in the images being rasterised at 300 DPI.
The sun is shining here today and it's not too cold, quite rare in March even before Brexit, so I may not have much time to spare the next few hours...

Re: Converting a multi-page PDF to a multi-page PDF
Posted: Tue Mar 30, 2021 8:09 pm
by IxenPDF
cday wrote: Tue Mar 30, 2021 8:55 am
I suspect the problem is that GS opens files using a default DPI value of 72, unless a specific value is set in the code used...
I do not understand. Doesn't the command "nconvert -info XnVOut_3.pdf" not just retrieve information?
cday wrote: Tue Mar 30, 2021 8:55 am
If you don't have one already you should insert a
-dpi 300 term in your code, that should result in the images being rasterised at 300 DPI.
Do you mean I should create a command like this: "nconvert -dpi 300 -info XnVOut_3.pdf"?
I think this makes no sense.
If no: I have already -dpi 300 in the first command:
nconvert -brightness 124 -gamma 0.72 -xall -dpi 300 -out pdf -multi -c 0 -o XnVOut.pdf M-PDF3-1.pdf
See post "Tue Mar 30, 2021 8:43 am "
(?)
Re: Converting a multi-page PDF to a multi-page PDF
Posted: Tue Mar 30, 2021 8:47 pm
by cday
I only had time to read your post quickly this morning, you already had the -dpi 300 term in you code, so it isn't immediately obvious why -info is showing 72 DPI. You could try changing the order of the terms -xall -dpi 300 to -dpi 300 -xall possibly the order of those terms matters??
Otherwise, could you please upload the source and output files used so that I can have a look sometime tomorrow.