@ 2017-07-11T22:44:29Z <?php
// Say we have a 74-page file
$num_pages = 74;
// Fill an array of commands.
$sections = array();
for ($i = 1; $i <= $num_pages; $i = $i+2) {
$next = $i+1;
$sections[] = "pdftk A=the.pdf cat A{$i}-{$next} output the_pages_{$i}-{$next}.pdf";
// Or, y'know, run them directly with shell_exec or something.
// shell_exec("pdftk A=the.pdf cat A{$i}-{$next} output the_pages_{$i}-{$next}.pdf");
}
print_r($sections);
// Then of course run them all.
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 7.0.0 - 7.0.31 , 7.1.0 - 7.1.33 , 7.2.0 - 7.2.33 , 7.3.0 - 7.3.33 , 7.4.0 - 7.4.33 , 8.0.0 - 8.0.30 , 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 , 8.3.0 - 8.3.4 , 8.3.6 Array
(
[0] => pdftk A=the.pdf cat A1-2 output the_pages_1-2.pdf
[1] => pdftk A=the.pdf cat A3-4 output the_pages_3-4.pdf
[2] => pdftk A=the.pdf cat A5-6 output the_pages_5-6.pdf
[3] => pdftk A=the.pdf cat A7-8 output the_pages_7-8.pdf
[4] => pdftk A=the.pdf cat A9-10 output the_pages_9-10.pdf
[5] => pdftk A=the.pdf cat A11-12 output the_pages_11-12.pdf
[6] => pdftk A=the.pdf cat A13-14 output the_pages_13-14.pdf
[7] => pdftk A=the.pdf cat A15-16 output the_pages_15-16.pdf
[8] => pdftk A=the.pdf cat A17-18 output the_pages_17-18.pdf
[9] => pdftk A=the.pdf cat A19-20 output the_pages_19-20.pdf
[10] => pdftk A=the.pdf cat A21-22 output the_pages_21-22.pdf
[11] => pdftk A=the.pdf cat A23-24 output the_pages_23-24.pdf
[12] => pdftk A=the.pdf cat A25-26 output the_pages_25-26.pdf
[13] => pdftk A=the.pdf cat A27-28 output the_pages_27-28.pdf
[14] => pdftk A=the.pdf cat A29-30 output the_pages_29-30.pdf
[15] => pdftk A=the.pdf cat A31-32 output the_pages_31-32.pdf
[16] => pdftk A=the.pdf cat A33-34 output the_pages_33-34.pdf
[17] => pdftk A=the.pdf cat A35-36 output the_pages_35-36.pdf
[18] => pdftk A=the.pdf cat A37-38 output the_pages_37-38.pdf
[19] => pdftk A=the.pdf cat A39-40 output the_pages_39-40.pdf
[20] => pdftk A=the.pdf cat A41-42 output the_pages_41-42.pdf
[21] => pdftk A=the.pdf cat A43-44 output the_pages_43-44.pdf
[22] => pdftk A=the.pdf cat A45-46 output the_pages_45-46.pdf
[23] => pdftk A=the.pdf cat A47-48 output the_pages_47-48.pdf
[24] => pdftk A=the.pdf cat A49-50 output the_pages_49-50.pdf
[25] => pdftk A=the.pdf cat A51-52 output the_pages_51-52.pdf
[26] => pdftk A=the.pdf cat A53-54 output the_pages_53-54.pdf
[27] => pdftk A=the.pdf cat A55-56 output the_pages_55-56.pdf
[28] => pdftk A=the.pdf cat A57-58 output the_pages_57-58.pdf
[29] => pdftk A=the.pdf cat A59-60 output the_pages_59-60.pdf
[30] => pdftk A=the.pdf cat A61-62 output the_pages_61-62.pdf
[31] => pdftk A=the.pdf cat A63-64 output the_pages_63-64.pdf
[32] => pdftk A=the.pdf cat A65-66 output the_pages_65-66.pdf
[33] => pdftk A=the.pdf cat A67-68 output the_pages_67-68.pdf
[34] => pdftk A=the.pdf cat A69-70 output the_pages_69-70.pdf
[35] => pdftk A=the.pdf cat A71-72 output the_pages_71-72.pdf
[36] => pdftk A=the.pdf cat A73-74 output the_pages_73-74.pdf
)
Output for 8.3.5 Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
Array
(
[0] => pdftk A=the.pdf cat A1-2 output the_pages_1-2.pdf
[1] => pdftk A=the.pdf cat A3-4 output the_pages_3-4.pdf
[2] => pdftk A=the.pdf cat A5-6 output the_pages_5-6.pdf
[3] => pdftk A=the.pdf cat A7-8 output the_pages_7-8.pdf
[4] => pdftk A=the.pdf cat A9-10 output the_pages_9-10.pdf
[5] => pdftk A=the.pdf cat A11-12 output the_pages_11-12.pdf
[6] => pdftk A=the.pdf cat A13-14 output the_pages_13-14.pdf
[7] => pdftk A=the.pdf cat A15-16 output the_pages_15-16.pdf
[8] => pdftk A=the.pdf cat A17-18 output the_pages_17-18.pdf
[9] => pdftk A=the.pdf cat A19-20 output the_pages_19-20.pdf
[10] => pdftk A=the.pdf cat A21-22 output the_pages_21-22.pdf
[11] => pdftk A=the.pdf cat A23-24 output the_pages_23-24.pdf
[12] => pdftk A=the.pdf cat A25-26 output the_pages_25-26.pdf
[13] => pdftk A=the.pdf cat A27-28 output the_pages_27-28.pdf
[14] => pdftk A=the.pdf cat A29-30 output the_pages_29-30.pdf
[15] => pdftk A=the.pdf cat A31-32 output the_pages_31-32.pdf
[16] => pdftk A=the.pdf cat A33-34 output the_pages_33-34.pdf
[17] => pdftk A=the.pdf cat A35-36 output the_pages_35-36.pdf
[18] => pdftk A=the.pdf cat A37-38 output the_pages_37-38.pdf
[19] => pdftk A=the.pdf cat A39-40 output the_pages_39-40.pdf
[20] => pdftk A=the.pdf cat A41-42 output the_pages_41-42.pdf
[21] => pdftk A=the.pdf cat A43-44 output the_pages_43-44.pdf
[22] => pdftk A=the.pdf cat A45-46 output the_pages_45-46.pdf
[23] => pdftk A=the.pdf cat A47-48 output the_pages_47-48.pdf
[24] => pdftk A=the.pdf cat A49-50 output the_pages_49-50.pdf
[25] => pdftk A=the.pdf cat A51-52 output the_pages_51-52.pdf
[26] => pdftk A=the.pdf cat A53-54 output the_pages_53-54.pdf
[27] => pdftk A=the.pdf cat A55-56 output the_pages_55-56.pdf
[28] => pdftk A=the.pdf cat A57-58 output the_pages_57-58.pdf
[29] => pdftk A=the.pdf cat A59-60 output the_pages_59-60.pdf
[30] => pdftk A=the.pdf cat A61-62 output the_pages_61-62.pdf
[31] => pdftk A=the.pdf cat A63-64 output the_pages_63-64.pdf
[32] => pdftk A=the.pdf cat A65-66 output the_pages_65-66.pdf
[33] => pdftk A=the.pdf cat A67-68 output the_pages_67-68.pdf
[34] => pdftk A=the.pdf cat A69-70 output the_pages_69-70.pdf
[35] => pdftk A=the.pdf cat A71-72 output the_pages_71-72.pdf
[36] => pdftk A=the.pdf cat A73-74 output the_pages_73-74.pdf
)
preferences:dark mode live preview
232.74 ms | 409 KiB | 241 Q