[SOLVED]Dynamic append
Posted: 2014-09-13T15:12:06-07:00
Hello,
I have a first program which creates a Repository (/home/working) containing multiples png files.
Each png file represent an exercice (I teach chemistry).
I succeed to write in each filename the dimensions of the image.
For instance, I have my Repository with:
/home/working/exo1#2400#816.png
/home/working/exo2#2400#676.png
/home/working/exo3#2400#450.png
/home/working/exo4#2400#1256.png
/home/working/exo5#2400#498.png
/home/working/exo6#2400#2244.png
/home/working/exo7#2400#832.png
/home/working/exo8#2400#524.png
/home/working/exo9#2400#624.png
(Sometimes I have less files, sometimes more, generally between 5 et 30 exercices/png-files.)
They all have the same width (2400px, but I can change it very easily if necessary) but they all have a different height (816px, 676px, 450px, 1258px,498px....).
I choose 2400px because I read that the dimensions of A4 page is 2480*3508 in 300 dpi.
I would like to generate a pdf file with all those exerices (keeping the original size of each png file), so I started to look on internet.
My first researchs always gave me the same example : the command line "convert *.png multipage.pdf"
This command doesn't work for me because the final pdf file have 9 pages (as much as the initial number of png files. It is a huge waste of paper when I have 30 exercices to print for the students).
Then I found the "-append" option but the command line "convert -append *.png final.pdf" doesn't work for me neither because this generates a final pdf file with 1 big page (extra tall one, so you can't read it when it's printed on A4)
So I suppose I need a special script/command in order to append (vertically) the exercices/png-files, and this "append function" need to be dynamic (because the number of files and their heights may vary : sometimes, 9 png files will "fill" 3 pages A4, sometimes 9 png files will "fill" only one page A4).
Considering the example below, a simple/stupid script (which append the files, one by one, till the total height is less than 3500) could generate a pdf file containing 3 pages A4, the first one contains exo1+exo2+exo3+exo4, the second page contains exo5+exo6 and the last page contains exo7+exo8.
Is it possible to do this? And how?
Thank you very much for your time and consideration.
PS : I have a drawing of what I need, in case you don't understand what I mean, but I don't know how to add it.
I have a first program which creates a Repository (/home/working) containing multiples png files.
Each png file represent an exercice (I teach chemistry).
I succeed to write in each filename the dimensions of the image.
For instance, I have my Repository with:
/home/working/exo1#2400#816.png
/home/working/exo2#2400#676.png
/home/working/exo3#2400#450.png
/home/working/exo4#2400#1256.png
/home/working/exo5#2400#498.png
/home/working/exo6#2400#2244.png
/home/working/exo7#2400#832.png
/home/working/exo8#2400#524.png
/home/working/exo9#2400#624.png
(Sometimes I have less files, sometimes more, generally between 5 et 30 exercices/png-files.)
They all have the same width (2400px, but I can change it very easily if necessary) but they all have a different height (816px, 676px, 450px, 1258px,498px....).
I choose 2400px because I read that the dimensions of A4 page is 2480*3508 in 300 dpi.
I would like to generate a pdf file with all those exerices (keeping the original size of each png file), so I started to look on internet.
My first researchs always gave me the same example : the command line "convert *.png multipage.pdf"
This command doesn't work for me because the final pdf file have 9 pages (as much as the initial number of png files. It is a huge waste of paper when I have 30 exercices to print for the students).
Then I found the "-append" option but the command line "convert -append *.png final.pdf" doesn't work for me neither because this generates a final pdf file with 1 big page (extra tall one, so you can't read it when it's printed on A4)
So I suppose I need a special script/command in order to append (vertically) the exercices/png-files, and this "append function" need to be dynamic (because the number of files and their heights may vary : sometimes, 9 png files will "fill" 3 pages A4, sometimes 9 png files will "fill" only one page A4).
Considering the example below, a simple/stupid script (which append the files, one by one, till the total height is less than 3500) could generate a pdf file containing 3 pages A4, the first one contains exo1+exo2+exo3+exo4, the second page contains exo5+exo6 and the last page contains exo7+exo8.
Is it possible to do this? And how?
Thank you very much for your time and consideration.
PS : I have a drawing of what I need, in case you don't understand what I mean, but I don't know how to add it.