Sylvain Mahé Le site Web Retour à l'accueil Principes Partager mes idées et mes projets librement et gratuitement. Thématiques Mécatronique du système embarqué, artisanat pluridisciplinaire, bricolage commun, esthétique logicielle et matérielle, minimalisme fonctionnel, conceptualisation alternative, rédaction technique et littéraire, partage pédagogique documenté. Contact ✆ Téléphone : 06.45.49.96.98
✉ E-mail : contact@sylvainmahe.site
✎ Site Web : sylvainmahe.site
Écriture de la page : Sylvain Mahé
Création automatique du contenu d'un livre à partir d'une arborescence de fichiers Habituellement dans le monde informatique digital, il est commun d'archiver des fichiers sur des supports de sauvegarde analogiques ou numériques (rubans perforés, bandes magnétiques, mémoires à base de semi-conducteurs, etc...). C'est oublier que les supports imprimés (livres, documents divers) peuvent également remplir la fonction d'archivage de données : Mais pour effectuer cette translation, soit la copie des fichiers numériques à sauvegarder vers des supports imprimés, un outil intermédiaire automatique est nécessaire. C'est cet outil remplissant cette fonction qui est proposé ici. Cet outil se présente sous la forme d'une routine (pour le système d'exploitation Linux que j'utilise) qui permet de générer automatiquement le contenu d'un livre complet sous la forme d'un seul fichier PDF via une arborescence de fichiers (organisation hiérarchique des fichiers dans des répertoires) dont le contenu UTF-8 est extrait : C'est le contenu UTF-8 (pour "Unicode Transformation Format 8" ou format de transformation Unicode sur 8 bits) de vos fichiers à sauvegarder qui est utilisé afin de générer un fichier unique PDF imprimable (book content.pdf), contenu prenant ainsi la forme de caractères normalisés qui peut être issu de divers langages, soit par exemple du binaire, de l'hexadécimal, du C++, ou tout autre caractère UTF-8 imprimable. Attention cependant, si des caractères dans vos fichiers ne font pas partie de la norme UTF-8, ils ne pourront pas être traités correctement. Le fichier PDF imprimable qui résulte de la translation peut être envoyé à un imprimeur, ce qui donne le résultat suivant : À noter que le format de fichier PDF (pour "Portable Document Format" ou format de document portable) est le standard directement pris en charge par toutes les imprimeries modernes. La routine d'automatisation proposée prend donc en entrée une arborescence de fichiers, et permet de choisir de multiples paramètres détaillés plus bas (comme par exemple les dimensions des pages du livre, les dimensions des marges, etc...). Une fois ces choix effectués, un fichier nommé book content.pdf est créé. Ce fichier répertorie tout le contenu des fichiers de l'arborescence, avec la pagination, la numérotation des lignes (si besoin), la numérotation des pages, et la table des fichiers en toute fin du livre. Ci dessous, la routine (.sh) permettant la création automatique du contenu d'un livre à partir d'une arborescence de fichiers : #!/bin/bash echo "Page width in mm ?" read menuWidthPage echo -e "\nPage height in mm ?" read menuHeightPage echo -e "\nPage margin in mm ?" read menuMarginPage echo -e "\nGutter margin in mm ?" read menuMarginGutter echo -e "\nFont size in mm ?" read menuFontSize echo -e "\nFont name ?" read menuFontName echo -e "\nCutter margin in mm ?" read menuMarginCutter echo -e "\nFile name prefix ?" read menuPrefixFileName echo "" next=false while [ $next == false ] do echo "File size suffix ?" echo "n = No" echo "e = English" echo "f = French" read menuFileSizeSuffix if [ $menuFileSizeSuffix == "n" ] || [ $menuFileSizeSuffix == "e" ] || [ $menuFileSizeSuffix == "f" ] then next=true else clear fi done echo "" next=false while [ $next == false ] do echo "Line numbering ?" echo "n = No" echo "y = Yes" read menuLineNumbering if [ $menuLineNumbering == "n" ] || [ $menuLineNumbering == "y" ] then next=true else clear fi done echo -e "\nFile table title ?" read menuTitleFileTable echo "" next=false while [ $next == false ] do echo "Color style ?" echo "n = Black and white" echo "y = Colored" read menuColorStyle if [ $menuColorStyle == "n" ] || [ $menuColorStyle == "y" ] then next=true else clear fi done echo "" next=false while [ $next == false ] do echo "Sort option ?" echo "a = Alphanumeric sort" echo "m = Manual sort" read menuSortOption if [ $menuSortOption == "a" ] || [ $menuSortOption == "m" ] then next=true fi clear done rm tmp -r -f rm "book content.pdf" -f nameBash=$(basename "$0") nameLink=$(basename "$1") countTable=0 shopt -s globstar for file in **/* do if [ -f "$file" ] && [ "$file" != "$nameBash" ] && [ "$file" != "$nameLink" ] then fileTable[$countTable]=$file ((countTable++)) fi done if [ $countTable == 0 ] then echo "No file detected" else iterationTable=0 if [ $menuSortOption == "m" ] then next=false while [ $next == false ] do echo "Manual sort :" echo "e = Exit" echo "s = Save file tree (file.tree)" echo "l = Load file tree (file.tree)" echo "d = Delete file tree (file.tree)" echo "" echo "File tree :" for ((iterationTableDisplay=0; $iterationTableDisplay < $countTable; iterationTableDisplay++)) do if [ $iterationTableDisplay == $iterationTable ] then echo $((iterationTableDisplay+1))" = "${fileTable[$iterationTableDisplay]}" <" else echo $((iterationTableDisplay+1))" = "${fileTable[$iterationTableDisplay]} fi done read menuManualSort if [ $menuManualSort == "e" ] then next=true elif [ $menuManualSort == "s" ] then rm file.tree -f for ((iterationTableForWriting=0; $iterationTableForWriting < $countTable; iterationTableForWriting++)) do echo ${fileTable[$iterationTableForWriting]} >> file.tree done elif [ $menuManualSort == "l" ] then countTable=0 while read line do if [ -f "$line" ] then fileTable[$countTable]=$line ((countTable++)) fi done < file.tree elif [ $menuManualSort == "d" ] then rm file.tree -f elif (($menuManualSort >= 1 && $menuManualSort <= $countTable)) then saveTable=${fileTable[$iterationTable]} fileTable[$iterationTable]=${fileTable[$((menuManualSort-1))]} fileTable[$((menuManualSort-1))]=$saveTable fi clear if (($iterationTable == $countTable - 1)) then iterationTable=0 else ((iterationTable++)) fi done fi echo "Progress = 0.0%" rm tmp -r -f mkdir tmp for ((iterationPatternBinary = 0; iterationPatternBinary <= 9; iterationPatternBinary++)) do patternBinaryTable[$iterationPatternBinary]="¡¿¡¿¡¿¡¿"$(echo "obase=2;"$((iterationPatternBinary+1)) | bc | awk '{ printf "%08d\n", $0 }' | sed -e "s/0/¿/g" -e "s/1/¡/g")"¡¿¡¿¡¿¡¿" done printf "\t\n" > tmp/tmpFoldAscii1Byte printf "\t\t\n" > tmp/tmpFoldAscii2Byte for ((iterationAscii = 32; iterationAscii < 127; iterationAscii++)) do printf "\\$(printf %03o "$iterationAscii")\n" >> tmp/tmpFoldAscii1Byte printf "\\$(printf %03o "$iterationAscii")\\$(printf %03o "$iterationAscii")\n" >> tmp/tmpFoldAscii2Byte done sed -i tmp/tmpFoldAscii1Byte -e "s/\t/"${patternBinaryTable[0]}"/g" -e "s/ /"${patternBinaryTable[1]}"/g" -e "s/\\$/"${patternBinaryTable[2]}"/g" -e "s/\\&/"${patternBinaryTable[3]}"/g" -e "s/*/"${patternBinaryTable[4]}"/g" -e "s/\\./"${patternBinaryTable[5]}"/g" -e "s/\\//"${patternBinaryTable[6]}"/g" -e "s/\\[/"${patternBinaryTable[7]}"/g" -e "s/\\\/"${patternBinaryTable[8]}"/g" -e "s/\\^/"${patternBinaryTable[9]}"/g" sed -i tmp/tmpFoldAscii2Byte -e "s/\t/"${patternBinaryTable[0]}"/g" -e "s/ /"${patternBinaryTable[1]}"/g" -e "s/\\$/"${patternBinaryTable[2]}"/g" -e "s/\\&/"${patternBinaryTable[3]}"/g" -e "s/*/"${patternBinaryTable[4]}"/g" -e "s/\\./"${patternBinaryTable[5]}"/g" -e "s/\\//"${patternBinaryTable[6]}"/g" -e "s/\\[/"${patternBinaryTable[7]}"/g" -e "s/\\\/"${patternBinaryTable[8]}"/g" -e "s/\\^/"${patternBinaryTable[9]}"/g" countLineTotal=0 characterMeasure="" for ((iterationCharacter=0; $iterationCharacter < 1000; iterationCharacter++)) do characterMeasure=$characterMeasure"_" done ratioFontSize=$(inkscape --without-gui -W <(echo "<svg><text font-family=\""$menuFontName"\" font-size=\""$menuFontSize"\">"$characterMeasure"</text></svg>") 2>/dev/null) countCharacterPerLine=$(echo "("$menuWidthPage"-(("$menuMarginPage"*2)+"$menuMarginGutter"))/("$ratioFontSize"/1000)" | bc -l) countCharacterPerLineStyle=$(echo "("$menuWidthPage"-(("$menuMarginPage"*2)+("$menuMarginGutter"+"$menuFontSize")))/("$ratioFontSize"/1000)" | bc -l) countCharacterPerLineDisplay=$(echo "scale=0;("$countCharacterPerLine"*10)/10" | bc -l) countCharacterPerLineStyleDisplay=$(echo "scale=0;("$countCharacterPerLineStyle"*10)/10" | bc -l) countLinePerPage=$(echo "("$menuHeightPage"-(("$menuMarginPage"*2)+("$menuFontSize"/3)))/"$menuFontSize | bc -l) countLinePerPageDisplay=$(echo "scale=0;("$countLinePerPage"*10)/10" | bc -l) countLineStylePrevious=0 countLineStyleTotal=0 for ((iterationTable=0; $iterationTable < $countTable; iterationTable++)) do clear progress=$(echo "25/("$countTable"/("$iterationTable"+1))" | bc -l) progressDisplay=$(echo "scale=1;(("$progress"+0.05)*10)/10" | bc -l) if ((${#progressDisplay} == 2)) then echo "Progress = 0"$progressDisplay"%" else echo "Progress = "$progressDisplay"%" fi sizeRaw=$(stat -c "%s" "${fileTable[$iterationTable]}") if [ $sizeRaw == 0 ] then if [ $menuFileSizeSuffix == "e" ] then size="(0 byte)" elif [ $menuFileSizeSuffix == "f" ] then size="(0 octet)" fi elif [ $sizeRaw == 1 ] then if [ $menuFileSizeSuffix == "e" ] then size="(1 byte)" elif [ $menuFileSizeSuffix == "f" ] then size="(1 octet)" fi elif (($sizeRaw < 1024)) then if [ $menuFileSizeSuffix == "e" ] then size="("$sizeRaw" bytes)" elif [ $menuFileSizeSuffix == "f" ] then size="("$sizeRaw" octets)" fi elif (($sizeRaw < 1048576)) then sizeInteger=$((sizeRaw/1024)) sizeDecimal=$(echo "("$sizeRaw"/1024)-"$((sizeRaw/1024)) | bc -l) sizeDecimalDisplay=$(echo "scale=1;("$sizeDecimal"*10)/10" | bc -l) sizeNumber=$(echo $sizeRaw"/1024" | bc -l) sizeNumberDisplay=$(echo "scale=1;("$sizeNumber"*10)/10" | bc -l) if [ $sizeDecimalDisplay == 0 ] then if (($(echo $sizeNumberDisplay" == "$sizeNumber | bc -l))) then if [ $menuFileSizeSuffix == "e" ] then size="("$sizeRaw" bytes = "$sizeInteger"KiB)" elif [ $menuFileSizeSuffix == "f" ] then size="("$sizeRaw" octets = "$sizeInteger"Kio)" fi else if [ $menuFileSizeSuffix == "e" ] then size="("$sizeRaw" bytes ≈ "$sizeInteger"KiB)" elif [ $menuFileSizeSuffix == "f" ] then size="("$sizeRaw" octets ≈ "$sizeInteger"Kio)" fi fi else if (($(echo $sizeNumberDisplay" == "$sizeNumber | bc -l))) then if [ $menuFileSizeSuffix == "e" ] then size="("$sizeRaw" bytes = "$sizeNumberDisplay"KiB)" elif [ $menuFileSizeSuffix == "f" ] then size="("$sizeRaw" octets = "$sizeNumberDisplay"Kio)" fi else if [ $menuFileSizeSuffix == "e" ] then size="("$sizeRaw" bytes ≈ "$sizeNumberDisplay"KiB)" elif [ $menuFileSizeSuffix == "f" ] then size="("$sizeRaw" octets ≈ "$sizeNumberDisplay"Kio)" fi fi fi elif (($sizeRaw < 1073741824)) then sizeInteger=$((sizeRaw/1048576)) sizeDecimal=$(echo "("$sizeRaw"/1048576)-"$((sizeRaw/1048576)) | bc -l) sizeDecimalDisplay=$(echo "scale=1;("$sizeDecimal"*10)/10" | bc -l) sizeNumber=$(echo $sizeRaw"/1048576" | bc -l) sizeNumberDisplay=$(echo "scale=1;("$sizeNumber"*10)/10" | bc -l) if [ $sizeDecimalDisplay == 0 ] then if (($(echo $sizeNumberDisplay" == "$sizeNumber | bc -l))) then if [ $menuFileSizeSuffix == "e" ] then size="("$sizeRaw" bytes = "$sizeInteger"MiB)" elif [ $menuFileSizeSuffix == "f" ] then size="("$sizeRaw" octets = "$sizeInteger"Mio)" fi else if [ $menuFileSizeSuffix == "e" ] then size="("$sizeRaw" bytes ≈ "$sizeInteger"MiB)" elif [ $menuFileSizeSuffix == "f" ] then size="("$sizeRaw" octets ≈ "$sizeInteger"Mio)" fi fi else if (($(echo $sizeNumberDisplay" == "$sizeNumber | bc -l))) then if [ $menuFileSizeSuffix == "e" ] then size="("$sizeRaw" bytes = "$sizeNumberDisplay"MiB)" elif [ $menuFileSizeSuffix == "f" ] then size="("$sizeRaw" octets = "$sizeNumberDisplay"Mio)" fi else if [ $menuFileSizeSuffix == "e" ] then size="("$sizeRaw" bytes ≈ "$sizeNumberDisplay"MiB)" elif [ $menuFileSizeSuffix == "f" ] then size="("$sizeRaw" octets ≈ "$sizeNumberDisplay"Mio)" fi fi fi fi if [ $menuColorStyle == "y" ] && [ $iterationTable != 0 ] then countLineStylePrevious=$(($(wc -l < tmp/tmp2)+(($(wc -l < tmp/tmp2)/(countLinePerPageDisplay-2))*2))) fi if [[ ! -z $menuPrefixFileName ]] then if [ $menuFileSizeSuffix != "n" ] then echo -e $menuPrefixFileName" "${fileTable[$iterationTable]}" "$size"\u00a0:" > tmp/tmpFoldInput else echo -e $menuPrefixFileName" "${fileTable[$iterationTable]}"\u00a0:" > tmp/tmpFoldInput fi else if [ $menuFileSizeSuffix != "n" ] then echo -e ${fileTable[$iterationTable]}" "$size"\u00a0:" > tmp/tmpFoldInput else echo -e ${fileTable[$iterationTable]}"\u00a0:" > tmp/tmpFoldInput fi fi if [ $menuColorStyle == "y" ] then valueFold=$countCharacterPerLineStyleDisplay else valueFold=$countCharacterPerLineDisplay fi sed -i tmp/tmpFoldInput -e "s/ /"${patternBinaryTable[1]}"/g" -e "s/\\$/"${patternBinaryTable[2]}"/g" -e "s/\\&/"${patternBinaryTable[3]}"/g" -e "s/*/"${patternBinaryTable[4]}"/g" -e "s/\\./"${patternBinaryTable[5]}"/g" -e "s/\\//"${patternBinaryTable[6]}"/g" -e "s/\\[/"${patternBinaryTable[7]}"/g" -e "s/\\\/"${patternBinaryTable[8]}"/g" -e "s/\\^/"${patternBinaryTable[9]}"/g" while read lineAscii1Byte <&3 && read lineAscii2Byte <&4 do sed -i tmp/tmpFoldInput -e "s/"$lineAscii1Byte"/"$lineAscii2Byte"/g" done 3< tmp/tmpFoldAscii1Byte 4< tmp/tmpFoldAscii2Byte echo $(head -1 tmp/tmpFoldInput) | sed -e "s/"${patternBinaryTable[1]}"/ /g" -e "s/"${patternBinaryTable[2]}"/\\$/g" -e "s/"${patternBinaryTable[3]}"/\\&/g" -e "s/"${patternBinaryTable[4]}"/*/g" -e "s/"${patternBinaryTable[5]}"/\\./g" -e "s/"${patternBinaryTable[6]}"/\\//g" -e "s/"${patternBinaryTable[7]}"/\\[/g" -e "s/"${patternBinaryTable[8]}"/\\\/g" -e "s/"${patternBinaryTable[9]}"/\\^/g" | fold -s -w $((valueFold*2)) | sed -e "s/ /"${patternBinaryTable[1]}"/g" -e "s/\\$/"${patternBinaryTable[2]}"/g" -e "s/\\&/"${patternBinaryTable[3]}"/g" -e "s/*/"${patternBinaryTable[4]}"/g" -e "s/\\./"${patternBinaryTable[5]}"/g" -e "s/\\//"${patternBinaryTable[6]}"/g" -e "s/\\[/"${patternBinaryTable[7]}"/g" -e "s/\\\/"${patternBinaryTable[8]}"/g" -e "s/\\^/"${patternBinaryTable[9]}"/g" > tmp/tmpFoldOutput while read lineAscii1Byte <&3 && read lineAscii2Byte <&4 do sed -i tmp/tmpFoldOutput -e "s/"$lineAscii2Byte"/"$lineAscii1Byte"/g" done 3< tmp/tmpFoldAscii1Byte 4< tmp/tmpFoldAscii2Byte sed -i tmp/tmpFoldOutput -e "s/"${patternBinaryTable[1]}"/ /g" -e "s/"${patternBinaryTable[2]}"/\\$/g" -e "s/"${patternBinaryTable[3]}"/\\&/g" -e "s/"${patternBinaryTable[4]}"/*/g" -e "s/"${patternBinaryTable[5]}"/\\./g" -e "s/"${patternBinaryTable[6]}"/\\//g" -e "s/"${patternBinaryTable[7]}"/\\[/g" -e "s/"${patternBinaryTable[8]}"/\\\/g" -e "s/"${patternBinaryTable[9]}"/\\^/g" cat tmp/tmpFoldOutput >> tmp/tmp2 countLineStyleNext=$(($(wc -l < tmp/tmp2)+(($(wc -l < tmp/tmp2)/(countLinePerPageDisplay-2))*2))) if [ $menuColorStyle == "y" ] then for ((iterationLineStyle=countLineStylePrevious; $iterationLineStyle < $countLineStyleNext; iterationLineStyle++)) do if (($iterationLineStyle % $countLinePerPageDisplay < $countLinePerPageDisplay - 2)) then numberLineStyle[$countLineStyleTotal]=$((iterationLineStyle+1)) ((countLineStyleTotal++)) fi done fi quickSearchModulo=false resultSearchModulo=0 iterationSearchModulo=$countLineStylePrevious if [ $countLinePerPageDisplay == 3 ] then resultSearchModulo=0 elif (($countLineStyleNext - $countLineStylePrevious == 1)) then resultSearchModulo=1 else while [ $quickSearchModulo == false ] do if (($iterationSearchModulo <= $countLineStyleNext - 1)) then if (($resultSearchModulo == $countLinePerPageDisplay - 2)) then resultSearchModulo=0 else ((resultSearchModulo++)) fi ((iterationSearchModulo++)) else quickSearchModulo=true fi done fi if [ $resultSearchModulo != 0 ] then echo "" >> tmp/tmp2 fi cp "${fileTable[$iterationTable]}" tmp/tmp1 sed -i tmp/tmp1 -e "s/\t/"${patternBinaryTable[0]}"/g" -e "s/ /"${patternBinaryTable[1]}"/g" -e "s/\\$/"${patternBinaryTable[2]}"/g" -e "s/\\&/"${patternBinaryTable[3]}"/g" -e "s/*/"${patternBinaryTable[4]}"/g" -e "s/\\./"${patternBinaryTable[5]}"/g" -e "s/\\//"${patternBinaryTable[6]}"/g" -e "s/\\[/"${patternBinaryTable[7]}"/g" -e "s/\\\/"${patternBinaryTable[8]}"/g" -e "s/\\^/"${patternBinaryTable[9]}"/g" countTmpLine=$(wc -l < tmp/tmp1) iterationTmpLine=1 while read line do spacePrefixLine="" for ((iterationSpace=0; $iterationSpace < ${#countTmpLine} - ${#iterationTmpLine}; iterationSpace++)) do spacePrefixLine=$spacePrefixLine${patternBinaryTable[1]} done spacePrefixSubline="" for ((iterationSpace=0; $iterationSpace < ${#countTmpLine}; iterationSpace++)) do spacePrefixSubline=$spacePrefixSubline${patternBinaryTable[1]} done echo $line > tmp/tmpFoldInput if [ $menuLineNumbering == "y" ] then valueFold=$((countCharacterPerLineDisplay-(${#countTmpLine}+3))) else valueFold=$countCharacterPerLineDisplay fi while read lineAscii1Byte <&3 && read lineAscii2Byte <&4 do sed -i tmp/tmpFoldInput -e "s/"$lineAscii1Byte"/"$lineAscii2Byte"/g" done 3< tmp/tmpFoldAscii1Byte 4< tmp/tmpFoldAscii2Byte echo $(head -1 tmp/tmpFoldInput) | sed -e "s/"${patternBinaryTable[1]}"/ /g" -e "s/"${patternBinaryTable[0]}"/ /g" -e "s/"${patternBinaryTable[2]}"/\\$/g" -e "s/"${patternBinaryTable[3]}"/\\&/g" -e "s/"${patternBinaryTable[4]}"/*/g" -e "s/"${patternBinaryTable[5]}"/\\./g" -e "s/"${patternBinaryTable[6]}"/\\//g" -e "s/"${patternBinaryTable[7]}"/\\[/g" -e "s/"${patternBinaryTable[8]}"/\\\/g" -e "s/"${patternBinaryTable[9]}"/\\^/g" | fold -s -w $((valueFold*2)) | sed -e "s/ /"${patternBinaryTable[1]}"/g" -e "s/ /"${patternBinaryTable[0]}"/g" -e "s/\\$/"${patternBinaryTable[2]}"/g" -e "s/\\&/"${patternBinaryTable[3]}"/g" -e "s/*/"${patternBinaryTable[4]}"/g" -e "s/\\./"${patternBinaryTable[5]}"/g" -e "s/\\//"${patternBinaryTable[6]}"/g" -e "s/\\[/"${patternBinaryTable[7]}"/g" -e "s/\\\/"${patternBinaryTable[8]}"/g" -e "s/\\^/"${patternBinaryTable[9]}"/g" > tmp/tmpFoldOutput while read lineAscii1Byte <&3 && read lineAscii2Byte <&4 do sed -i tmp/tmpFoldOutput -e "s/"$lineAscii2Byte"/"$lineAscii1Byte"/g" done 3< tmp/tmpFoldAscii1Byte 4< tmp/tmpFoldAscii2Byte iterationTmpSubline=1 while read subline do if [ $menuLineNumbering == "y" ] then if [ $iterationTmpSubline == 1 ] then echo $spacePrefixLine$iterationTmpLine" : "$subline | sed -e "s/"${patternBinaryTable[1]}"/ /g" -e "s/"${patternBinaryTable[0]}"/ /g" -e "s/"${patternBinaryTable[2]}"/\\$/g" -e "s/"${patternBinaryTable[3]}"/\\&/g" -e "s/"${patternBinaryTable[4]}"/*/g" -e "s/"${patternBinaryTable[5]}"/\\./g" -e "s/"${patternBinaryTable[6]}"/\\//g" -e "s/"${patternBinaryTable[7]}"/\\[/g" -e "s/"${patternBinaryTable[8]}"/\\\/g" -e "s/"${patternBinaryTable[9]}"/\\^/g" >> tmp/tmp2 else echo $spacePrefixSubline" : "$subline | sed -e "s/"${patternBinaryTable[1]}"/ /g" -e "s/"${patternBinaryTable[0]}"/ /g" -e "s/"${patternBinaryTable[2]}"/\\$/g" -e "s/"${patternBinaryTable[3]}"/\\&/g" -e "s/"${patternBinaryTable[4]}"/*/g" -e "s/"${patternBinaryTable[5]}"/\\./g" -e "s/"${patternBinaryTable[6]}"/\\//g" -e "s/"${patternBinaryTable[7]}"/\\[/g" -e "s/"${patternBinaryTable[8]}"/\\\/g" -e "s/"${patternBinaryTable[9]}"/\\^/g" >> tmp/tmp2 fi else echo $subline | sed -e "s/"${patternBinaryTable[1]}"/ /g" -e "s/"${patternBinaryTable[0]}"/ /g" -e "s/"${patternBinaryTable[2]}"/\\$/g" -e "s/"${patternBinaryTable[3]}"/\\&/g" -e "s/"${patternBinaryTable[4]}"/*/g" -e "s/"${patternBinaryTable[5]}"/\\./g" -e "s/"${patternBinaryTable[6]}"/\\//g" -e "s/"${patternBinaryTable[7]}"/\\[/g" -e "s/"${patternBinaryTable[8]}"/\\\/g" -e "s/"${patternBinaryTable[9]}"/\\^/g" >> tmp/tmp2 fi ((iterationTmpSubline++)) done < tmp/tmpFoldOutput ((iterationTmpLine++)) done < tmp/tmp1 countLine=$(wc -l < tmp/tmp2) iterationLinePerPage=0 fillPage=$((countLinePerPageDisplay-2)) for ((iterationLine=0; $iterationLine < $countLine - 1; iterationLine++)) do if (($iterationLinePerPage == $countLinePerPageDisplay - 3)) then fillPage=$((fillPage+(countLinePerPageDisplay-2))) iterationLinePerPage=0 else ((iterationLinePerPage++)) fi done for ((iterationLine=0; $iterationLine < $fillPage - $countLine; iterationLine++)) do echo "" >> tmp/tmp2 done titlePageTable[$iterationTable]=${fileTable[$iterationTable]} if [ $countLineTotal == 0 ] then numberPageTable[$iterationTable]=1 else numberPageTable[$iterationTable]=$(((countLineTotal/(countLinePerPageDisplay-2))+1)) fi countLineTotal=$(wc -l < tmp/tmp2) done iterationLinePerPage=0 numberPageContent=1 flipFlop=false for ((iterationLine=0; $iterationLine < $countLineTotal; iterationLine++)) do if (($iterationLinePerPage == $countLinePerPageDisplay - 1)) then sed -i tmp/tmp2 -e $iterationLine"i\\\\" if [ $flipFlop == false ] then lenghtNumberPageContent=${#numberPageContent} fillSpace="" for ((iterationCharacter=0; $iterationCharacter < $countCharacterPerLineDisplay - $lenghtNumberPageContent; iterationCharacter++)) do fillSpace=$fillSpace${patternBinaryTable[1]} done sed -i tmp/tmp2 -e $((iterationLine+1))"i"$fillSpace$numberPageContent | sed -e "s/"${patternBinaryTable[1]}"/ /g" flipFlop=true else sed -i tmp/tmp2 -e $((iterationLine+1))"i"$numberPageContent flipFlop=false fi iterationLinePerPage=0 ((numberPageContent++)) clear progress=$(echo "25+(50/("$countLineTotal"/("$iterationLine"+1)))" | bc -l) progressDisplay=$(echo "scale=1;(("$progress"+0.05)*10)/10" | bc -l) echo "Progress = "$progressDisplay"%" else ((iterationLinePerPage++)) fi countLineTotal=$(wc -l < tmp/tmp2) done if [ $flipFlop == false ] then lenghtNumberPageContent=${#numberPageContent} fillSpace="" for ((iterationCharacter=0; $iterationCharacter < $countCharacterPerLineDisplay - $lenghtNumberPageContent; iterationCharacter++)) do fillSpace=$fillSpace${patternBinaryTable[1]} done echo -e "\n"$fillSpace$numberPageContent | sed -e "s/"${patternBinaryTable[1]}"/ /g" >> tmp/tmp2 else echo -e "\n"$numberPageContent >> tmp/tmp2 fi if [ $menuColorStyle == "y" ] then countLineStylePrevious=$(wc -l < tmp/tmp2) fi if [[ ! -z $menuTitleFileTable ]] then if [ $menuColorStyle == "y" ] then echo -e $menuTitleFileTable"\u00a0:" > tmp/tmpFoldInput else echo -e $menuTitleFileTable"\u00a0:" > tmp/tmpFoldInput fi else if [ $menuColorStyle == "y" ] then echo -e "File table\u00a0:" > tmp/tmpFoldInput else echo -e "File table\u00a0:" > tmp/tmpFoldInput fi fi if [ $menuColorStyle == "y" ] then valueFold=$countCharacterPerLineStyleDisplay else valueFold=$countCharacterPerLineDisplay fi sed -i tmp/tmpFoldInput -e "s/ /"${patternBinaryTable[1]}"/g" -e "s/\\$/"${patternBinaryTable[2]}"/g" -e "s/\\&/"${patternBinaryTable[3]}"/g" -e "s/*/"${patternBinaryTable[4]}"/g" -e "s/\\./"${patternBinaryTable[5]}"/g" -e "s/\\//"${patternBinaryTable[6]}"/g" -e "s/\\[/"${patternBinaryTable[7]}"/g" -e "s/\\\/"${patternBinaryTable[8]}"/g" -e "s/\\^/"${patternBinaryTable[9]}"/g" while read lineAscii1Byte <&3 && read lineAscii2Byte <&4 do sed -i tmp/tmpFoldInput -e "s/"$lineAscii1Byte"/"$lineAscii2Byte"/g" done 3< tmp/tmpFoldAscii1Byte 4< tmp/tmpFoldAscii2Byte echo $(head -1 tmp/tmpFoldInput) | sed -e "s/"${patternBinaryTable[1]}"/ /g" -e "s/"${patternBinaryTable[2]}"/\\$/g" -e "s/"${patternBinaryTable[3]}"/\\&/g" -e "s/"${patternBinaryTable[4]}"/*/g" -e "s/"${patternBinaryTable[5]}"/\\./g" -e "s/"${patternBinaryTable[6]}"/\\//g" -e "s/"${patternBinaryTable[7]}"/\\[/g" -e "s/"${patternBinaryTable[8]}"/\\\/g" -e "s/"${patternBinaryTable[9]}"/\\^/g" | fold -s -w $((valueFold*2)) | sed -e "s/ /"${patternBinaryTable[1]}"/g" -e "s/\\$/"${patternBinaryTable[2]}"/g" -e "s/\\&/"${patternBinaryTable[3]}"/g" -e "s/*/"${patternBinaryTable[4]}"/g" -e "s/\\./"${patternBinaryTable[5]}"/g" -e "s/\\//"${patternBinaryTable[6]}"/g" -e "s/\\[/"${patternBinaryTable[7]}"/g" -e "s/\\\/"${patternBinaryTable[8]}"/g" -e "s/\\^/"${patternBinaryTable[9]}"/g" > tmp/tmpFoldOutput while read lineAscii1Byte <&3 && read lineAscii2Byte <&4 do sed -i tmp/tmpFoldOutput -e "s/"$lineAscii2Byte"/"$lineAscii1Byte"/g" done 3< tmp/tmpFoldAscii1Byte 4< tmp/tmpFoldAscii2Byte sed -i tmp/tmpFoldOutput -e "s/"${patternBinaryTable[1]}"/ /g" -e "s/"${patternBinaryTable[2]}"/\\$/g" -e "s/"${patternBinaryTable[3]}"/\\&/g" -e "s/"${patternBinaryTable[4]}"/*/g" -e "s/"${patternBinaryTable[5]}"/\\./g" -e "s/"${patternBinaryTable[6]}"/\\//g" -e "s/"${patternBinaryTable[7]}"/\\[/g" -e "s/"${patternBinaryTable[8]}"/\\\/g" -e "s/"${patternBinaryTable[9]}"/\\^/g" cat tmp/tmpFoldOutput >> tmp/tmp2 countLineStyleNext=$(wc -l < tmp/tmp2) if [ $menuColorStyle == "y" ] then for ((iterationLineStyle=countLineStylePrevious; $iterationLineStyle < $countLineStyleNext; iterationLineStyle++)) do numberLineStyle[$countLineStyleTotal]=$((iterationLineStyle+1)) ((countLineStyleTotal++)) done fi if (($countLineStyleNext % $countLinePerPageDisplay != 0)) then echo "" >> tmp/tmp2 fi lenghtMaxTitlePageTable=$(((countCharacterPerLineDisplay-3)-${#numberPageTable[$((countTable-1))]})) for ((iterationTable=0; $iterationTable < $countTable; iterationTable++)) do echo ${titlePageTable[$iterationTable]} > tmp/tmpFoldInput valueFold=$lenghtMaxTitlePageTable sed -i tmp/tmpFoldInput -e "s/ /"${patternBinaryTable[1]}"/g" -e "s/\\$/"${patternBinaryTable[2]}"/g" -e "s/\\&/"${patternBinaryTable[3]}"/g" -e "s/*/"${patternBinaryTable[4]}"/g" -e "s/\\./"${patternBinaryTable[5]}"/g" -e "s/\\//"${patternBinaryTable[6]}"/g" -e "s/\\[/"${patternBinaryTable[7]}"/g" -e "s/\\\/"${patternBinaryTable[8]}"/g" -e "s/\\^/"${patternBinaryTable[9]}"/g" while read lineAscii1Byte <&3 && read lineAscii2Byte <&4 do sed -i tmp/tmpFoldInput -e "s/"$lineAscii1Byte"/"$lineAscii2Byte"/g" done 3< tmp/tmpFoldAscii1Byte 4< tmp/tmpFoldAscii2Byte echo $(head -1 tmp/tmpFoldInput) | sed -e "s/"${patternBinaryTable[1]}"/ /g" -e "s/"${patternBinaryTable[2]}"/\\$/g" -e "s/"${patternBinaryTable[3]}"/\\&/g" -e "s/"${patternBinaryTable[4]}"/*/g" -e "s/"${patternBinaryTable[5]}"/\\./g" -e "s/"${patternBinaryTable[6]}"/\\//g" -e "s/"${patternBinaryTable[7]}"/\\[/g" -e "s/"${patternBinaryTable[8]}"/\\\/g" -e "s/"${patternBinaryTable[9]}"/\\^/g" | fold -s -w $((valueFold*2)) | sed -e "s/ /"${patternBinaryTable[1]}"/g" -e "s/\\$/"${patternBinaryTable[2]}"/g" -e "s/\\&/"${patternBinaryTable[3]}"/g" -e "s/*/"${patternBinaryTable[4]}"/g" -e "s/\\./"${patternBinaryTable[5]}"/g" -e "s/\\//"${patternBinaryTable[6]}"/g" -e "s/\\[/"${patternBinaryTable[7]}"/g" -e "s/\\\/"${patternBinaryTable[8]}"/g" -e "s/\\^/"${patternBinaryTable[9]}"/g" > tmp/tmpFoldOutput while read lineAscii1Byte <&3 && read lineAscii2Byte <&4 do sed -i tmp/tmpFoldOutput -e "s/"$lineAscii2Byte"/"$lineAscii1Byte"/g" done 3< tmp/tmpFoldAscii1Byte 4< tmp/tmpFoldAscii2Byte sed -i tmp/tmpFoldOutput -e "s/"${patternBinaryTable[1]}"/ /g" -e "s/"${patternBinaryTable[2]}"/\\$/g" -e "s/"${patternBinaryTable[3]}"/\\&/g" -e "s/"${patternBinaryTable[4]}"/*/g" -e "s/"${patternBinaryTable[5]}"/\\./g" -e "s/"${patternBinaryTable[6]}"/\\//g" -e "s/"${patternBinaryTable[7]}"/\\[/g" -e "s/"${patternBinaryTable[8]}"/\\\/g" -e "s/"${patternBinaryTable[9]}"/\\^/g" cat tmp/tmpFoldOutput > tmp/tmp3 countTmpLine=$(wc -l < tmp/tmp3) iterationTmpLine=1 point="." while read line do if [ $iterationTmpLine != $countTmpLine ] then echo $line >> tmp/tmp2 else lenghtLastLine=$((${#line}+${#numberPageTable[$iterationTable]})) for ((iterationCharacter=0; $iterationCharacter < $countCharacterPerLineDisplay - ($lenghtLastLine + 3); iterationCharacter++)) do point=$point"." done echo $line" "$point" "${numberPageTable[$iterationTable]} >> tmp/tmp2 fi ((iterationTmpLine++)) done < tmp/tmp3 done countLineTotal=$(wc -l < tmp/tmp2) iterationLinePerPage=0 fillPage=$countLinePerPageDisplay for ((iterationLine=0; $iterationLine < $countLineTotal - 1; iterationLine++)) do if (($iterationLinePerPage == $countLinePerPageDisplay - 1)) then fillPage=$((fillPage+countLinePerPageDisplay)) iterationLinePerPage=0 else ((iterationLinePerPage++)) fi done for ((iterationLine=0; $iterationLine < $fillPage - $countLineTotal; iterationLine++)) do echo "" >> tmp/tmp2 done iterationLine=0 iterationPage=0 firstPage=false flipFlop=false countPageTotal=$(($(wc -l < tmp/tmp2)/countLinePerPageDisplay)) iterationLineStyle=0 iterationLineTotal=1 styleColor=false styleSize=false sed -i tmp/tmp2 -e "s/ /"${patternBinaryTable[1]}"/g" -e "s/\\$/"${patternBinaryTable[2]}"/g" -e "s/*/"${patternBinaryTable[4]}"/g" -e "s/\\./"${patternBinaryTable[5]}"/g" -e "s/\\//"${patternBinaryTable[6]}"/g" -e "s/\\[/"${patternBinaryTable[7]}"/g" -e "s/\\\/"${patternBinaryTable[8]}"/g" -e "s/\\^/"${patternBinaryTable[9]}"/g" while read line do if [ $iterationLine == 0 ] then echo "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" > tmp/tmp.svg echo "<svg width=\""$(echo "("$menuMarginCutter"*2)+"$menuWidthPage | bc -l)"mm\" height=\""$(echo "("$menuMarginCutter"*2)+"$menuHeightPage | bc -l)"mm\">" >> tmp/tmp.svg fi if (($iterationLineStyle < $countLineStyleTotal)) then if (($iterationLineStyle > 0)) then if (($iterationLine != 0 && ${numberLineStyle[$iterationLineStyle]} - 1 == ${numberLineStyle[$((iterationLineStyle-1))]})) then styleSize=true else styleSize=false fi fi if [ ${numberLineStyle[$iterationLineStyle]} == $iterationLineTotal ] then styleColor=true ((iterationLineStyle++)) else styleColor=false fi else styleColor=false fi if [ $flipFlop == false ] then if [ $styleColor == false ] then echo "<text x=\""$(echo $menuMarginCutter"+("$menuMarginGutter"+"$menuMarginPage")" | bc -l)"mm\" y=\""$(echo $menuMarginCutter"+("$menuMarginPage"+("$menuFontSize"*("$iterationLine"+1)))" | bc -l)"mm\" text-anchor=\"start\" font-family=\""$menuFontName"\" font-size=\""$menuFontSize"mm\" fill=\"#000000\" xml:space=\"preserve\">"$(echo $line | sed -e "s/&/&amp;/g" -e "s/</\&lt;/g" -e "s/>/\&gt;/g" -e "s/\"/\&quot;/g" -e "s/'/\&apos;/g")"</text>" | sed -e "s/"${patternBinaryTable[1]}"/ /g" -e "s/"${patternBinaryTable[2]}"/\\$/g" -e "s/"${patternBinaryTable[4]}"/*/g" -e "s/"${patternBinaryTable[5]}"/\\./g" -e "s/"${patternBinaryTable[6]}"/\\//g" -e "s/"${patternBinaryTable[7]}"/\\[/g" -e "s/"${patternBinaryTable[8]}"/\\\/g" -e "s/"${patternBinaryTable[9]}"/\\^/g" >> tmp/tmp.svg else if [ $styleSize == false ] then echo "<rect x=\""$(echo $menuMarginCutter"+("$menuMarginGutter"+"$menuMarginPage")" | bc -l)"mm\" y=\""$(echo $menuMarginCutter"+("$menuMarginPage"+("$menuFontSize"*"$iterationLine"))" | bc -l)"mm\" width=\""$(echo $menuWidthPage"-("$menuMarginGutter"+("$menuMarginPage"*2))" | bc -l)"mm\" height=\""$(echo $menuFontSize"+("$menuFontSize"/3)" | bc -l)"mm\" fill=\"#ff0000\"/>" >> tmp/tmp.svg else echo "<rect x=\""$(echo $menuMarginCutter"+("$menuMarginGutter"+"$menuMarginPage")" | bc -l)"mm\" y=\""$(echo "("$menuMarginCutter"+("$menuMarginPage"+("$menuFontSize"*"$iterationLine")))+("$menuFontSize"/3)" | bc -l)"mm\" width=\""$(echo $menuWidthPage"-("$menuMarginGutter"+("$menuMarginPage"*2))" | bc -l)"mm\" height=\""$menuFontSize"mm\" fill=\"#ff0000\"/>" >> tmp/tmp.svg fi echo "<text x=\""$(echo $menuMarginCutter"+(("$menuMarginGutter"+"$menuMarginPage")+("$menuFontSize"/2))" | bc -l)"mm\" y=\""$(echo $menuMarginCutter"+("$menuMarginPage"+("$menuFontSize"*("$iterationLine"+1)))" | bc -l)"mm\" text-anchor=\"start\" font-family=\""$menuFontName"\" font-size=\""$menuFontSize"mm\" fill=\"#ffffff\" xml:space=\"preserve\">"$(echo $line | sed -e "s/&/&amp;/g" -e "s/</\&lt;/g" -e "s/>/\&gt;/g" -e "s/\"/\&quot;/g" -e "s/'/\&apos;/g")"</text>" | sed -e "s/"${patternBinaryTable[1]}"/ /g" -e "s/"${patternBinaryTable[2]}"/\\$/g" -e "s/"${patternBinaryTable[4]}"/*/g" -e "s/"${patternBinaryTable[5]}"/\\./g" -e "s/"${patternBinaryTable[6]}"/\\//g" -e "s/"${patternBinaryTable[7]}"/\\[/g" -e "s/"${patternBinaryTable[8]}"/\\\/g" -e "s/"${patternBinaryTable[9]}"/\\^/g" >> tmp/tmp.svg fi else if [ $styleColor == false ] then echo "<text x=\""$(echo $menuMarginCutter"+"$menuMarginPage | bc -l)"mm\" y=\""$(echo $menuMarginCutter"+("$menuMarginPage"+("$menuFontSize"*("$iterationLine"+1)))" | bc -l)"mm\" text-anchor=\"start\" font-family=\""$menuFontName"\" font-size=\""$menuFontSize"mm\" fill=\"#000000\" xml:space=\"preserve\">"$(echo $line | sed -e "s/&/&amp;/g" -e "s/</\&lt;/g" -e "s/>/\&gt;/g" -e "s/\"/\&quot;/g" -e "s/'/\&apos;/g")"</text>" | sed -e "s/"${patternBinaryTable[1]}"/ /g" -e "s/"${patternBinaryTable[2]}"/\\$/g" -e "s/"${patternBinaryTable[4]}"/*/g" -e "s/"${patternBinaryTable[5]}"/\\./g" -e "s/"${patternBinaryTable[6]}"/\\//g" -e "s/"${patternBinaryTable[7]}"/\\[/g" -e "s/"${patternBinaryTable[8]}"/\\\/g" -e "s/"${patternBinaryTable[9]}"/\\^/g" >> tmp/tmp.svg else if [ $styleSize == false ] then echo "<rect x=\""$(echo $menuMarginCutter"+"$menuMarginPage | bc -l)"mm\" y=\""$(echo $menuMarginCutter"+("$menuMarginPage"+("$menuFontSize"*"$iterationLine"))" | bc -l)"mm\" width=\""$(echo $menuWidthPage"-("$menuMarginGutter"+("$menuMarginPage"*2))" | bc -l)"mm\" height=\""$(echo $menuFontSize"+("$menuFontSize"/3)" | bc -l)"mm\" fill=\"#ff0000\"/>" >> tmp/tmp.svg else echo "<rect x=\""$(echo $menuMarginCutter"+"$menuMarginPage | bc -l)"mm\" y=\""$(echo "("$menuMarginCutter"+("$menuMarginPage"+("$menuFontSize"*"$iterationLine")))+("$menuFontSize"/3)" | bc -l)"mm\" width=\""$(echo $menuWidthPage"-("$menuMarginGutter"+("$menuMarginPage"*2))" | bc -l)"mm\" height=\""$menuFontSize"mm\" fill=\"#ff0000\"/>" >> tmp/tmp.svg fi echo "<text x=\""$(echo $menuMarginCutter"+("$menuMarginPage"+("$menuFontSize"/2))" | bc -l)"mm\" y=\""$(echo $menuMarginCutter"+("$menuMarginPage"+("$menuFontSize"*("$iterationLine"+1)))" | bc -l)"mm\" text-anchor=\"start\" font-family=\""$menuFontName"\" font-size=\""$menuFontSize"mm\" fill=\"#ffffff\" xml:space=\"preserve\">"$(echo $line | sed -e "s/&/&amp;/g" -e "s/</\&lt;/g" -e "s/>/\&gt;/g" -e "s/\"/\&quot;/g" -e "s/'/\&apos;/g")"</text>" | sed -e "s/"${patternBinaryTable[1]}"/ /g" -e "s/"${patternBinaryTable[2]}"/\\$/g" -e "s/"${patternBinaryTable[4]}"/*/g" -e "s/"${patternBinaryTable[5]}"/\\./g" -e "s/"${patternBinaryTable[6]}"/\\//g" -e "s/"${patternBinaryTable[7]}"/\\[/g" -e "s/"${patternBinaryTable[8]}"/\\\/g" -e "s/"${patternBinaryTable[9]}"/\\^/g" >> tmp/tmp.svg fi fi if (($iterationLine == $countLinePerPageDisplay - 1)) then echo "<rect x=\"0mm\" y=\"0mm\" width=\""$(echo "("$menuMarginCutter"*2)+"$menuWidthPage | bc -l)"mm\" height=\""$(echo $menuMarginCutter"+"$menuMarginPage | bc -l)"mm\" fill=\"#ffffff\"/>" >> tmp/tmp.svg echo "<rect x=\"0mm\" y=\""$(echo $menuMarginCutter"+("$menuHeightPage"-"$menuMarginPage")" | bc -l)"mm\" width=\""$(echo "("$menuMarginCutter"*2)+"$menuWidthPage | bc -l)"mm\" height=\""$(echo $menuMarginCutter"+"$menuMarginPage | bc -l)"mm\" fill=\"#ffffff\"/>" >> tmp/tmp.svg echo "<rect x=\"0mm\" y=\""$(echo $menuMarginCutter"+"$menuMarginPage | bc -l)"mm\" width=\""$(echo $menuMarginCutter"+"$menuMarginPage | bc -l)"mm\" height=\""$(echo $menuHeightPage"-("$menuMarginPage"*2)" | bc -l)"mm\" fill=\"#ffffff\"/>" >> tmp/tmp.svg echo "<rect x=\""$(echo $menuMarginCutter"+("$menuWidthPage"-"$menuMarginPage")" | bc -l)"mm\" y=\""$(echo $menuMarginCutter"+"$menuMarginPage | bc -l)"mm\" width=\""$(echo $menuMarginCutter"+"$menuMarginPage | bc -l)"mm\" height=\""$(echo $menuHeightPage"-("$menuMarginPage"*2)" | bc -l)"mm\" fill=\"#ffffff\"/>" >> tmp/tmp.svg echo "</svg>" >> tmp/tmp.svg if [ $firstPage == false ] then rsvg-convert -f pdf -d 72 -p 72 tmp/tmp.svg -o tmp/tmp1.pdf firstPage=true else rsvg-convert -f pdf -d 72 -p 72 tmp/tmp.svg -o tmp/tmp2.pdf pdftk tmp/tmp1.pdf tmp/tmp2.pdf cat output tmp/tmp3.pdf mv tmp/tmp3.pdf tmp/tmp1.pdf fi if [ $flipFlop == false ] then flipFlop=true else flipFlop=false fi iterationLine=0 ((iterationPage++)) clear progress=$(echo "75+(25/("$countPageTotal"/"$iterationPage"))" | bc -l) progressDisplay=$(echo "scale=1;(("$progress"+0.05)*10)/10" | bc -l) echo "Progress = "$progressDisplay"%" else ((iterationLine++)) fi ((iterationLineTotal++)) done < tmp/tmp2 exiftool -q -m -all= tmp/tmp1.pdf mv tmp/tmp1.pdf "book content.pdf" rm tmp -r -f lenghtTotalCover=$(echo "(("$menuMarginCutter"*2)+("$menuWidthPage"*2))+("$countPageTotal"*0.06)" | bc -l) widthFrontBackCover=$(echo $menuMarginCutter"+"$menuWidthPage | bc -l) heightFrontBackCover=$(echo "("$menuMarginCutter"*2)+"$menuHeightPage | bc -l) widthSideCover=$(echo "("$countPageTotal"*0.06)" | bc -l) lenghtTotalCoverDisplay=$(echo "scale=3;(("$lenghtTotalCover"+0.0005)*10)/10" | bc -l) widthFrontBackCoverDisplay=$(echo "scale=3;(("$widthFrontBackCover"+0.0005)*10)/10" | bc -l) heightFrontBackCoverDisplay=$(echo "scale=3;(("$heightFrontBackCover"+0.0005)*10)/10" | bc -l) widthSideCoverDisplay=$(echo "scale=3;(("$widthSideCover"+0.0005)*10)/10" | bc -l) sizeRaw=0 for ((iterationTable=0; $iterationTable < $countTable; iterationTable++)) do sizeRaw=$((sizeRaw+$(stat -c "%s" "${fileTable[$iterationTable]}"))) done if [ $sizeRaw == 0 ] then size="0 byte" elif [ $sizeRaw == 1 ] then size="1 byte" elif (($sizeRaw < 1024)) then size=$sizeRaw" bytes" elif (($sizeRaw < 1048576)) then sizeInteger=$((sizeRaw/1024)) sizeDecimal=$(echo "("$sizeRaw"/1024)-"$((sizeRaw/1024)) | bc -l) sizeDecimalDisplay=$(echo "scale=1;("$sizeDecimal"*10)/10" | bc -l) sizeNumber=$(echo $sizeRaw"/1024" | bc -l) sizeNumberDisplay=$(echo "scale=1;("$sizeNumber"*10)/10" | bc -l) if [ $sizeDecimalDisplay == 0 ] then if (($(echo $sizeNumberDisplay" == "$sizeNumber | bc -l))) then size=$sizeRaw" bytes ("$sizeInteger"KiB)" else size=$sizeRaw" bytes (≈ "$sizeInteger"KiB)" fi else if (($(echo $sizeNumberDisplay" == "$sizeNumber | bc -l))) then size=$sizeRaw" bytes ("$sizeNumberDisplay"KiB)" else size=$sizeRaw" bytes (≈ "$sizeNumberDisplay"KiB)" fi fi elif (($sizeRaw < 1073741824)) then sizeInteger=$((sizeRaw/1048576)) sizeDecimal=$(echo "("$sizeRaw"/1048576)-"$((sizeRaw/1048576)) | bc -l) sizeDecimalDisplay=$(echo "scale=1;("$sizeDecimal"*10)/10" | bc -l) sizeNumber=$(echo $sizeRaw"/1048576" | bc -l) sizeNumberDisplay=$(echo "scale=1;("$sizeNumber"*10)/10" | bc -l) if [ $sizeDecimalDisplay == 0 ] then if (($(echo $sizeNumberDisplay" == "$sizeNumber | bc -l))) then size=$sizeRaw" bytes ("$sizeInteger"MiB)" else size=$sizeRaw" bytes (≈ "$sizeInteger"MiB)" fi else if (($(echo $sizeNumberDisplay" == "$sizeNumber | bc -l))) then size=$sizeRaw" bytes ("$sizeNumberDisplay"MiB)" else size=$sizeRaw" bytes (≈ "$sizeNumberOne"MiB)" fi fi fi clear echo "Book cover specifications for printing :" if ((${#lenghtTotalCoverDisplay} == 4)) then echo "Total lenght (front + side + back) = 0"$lenghtTotalCoverDisplay"mm" else echo "Total lenght (front + side + back) = "$lenghtTotalCoverDisplay"mm" fi if ((${#widthFrontBackCoverDisplay} == 4)) then echo "Front width = 0"$widthFrontBackCoverDisplay"mm" else echo "Front width = "$widthFrontBackCoverDisplay"mm" fi if ((${#heightFrontBackCoverDisplay} == 4)) then echo "Front height = 0"$heightFrontBackCoverDisplay"mm" else echo "Front height = "$heightFrontBackCoverDisplay"mm" fi if ((${#widthSideCoverDisplay} == 4)) then echo "Side width = 0"$widthSideCoverDisplay"mm" else echo "Side width = "$widthSideCoverDisplay"mm" fi if ((${#heightFrontBackCoverDisplay} == 4)) then echo "Side height = 0"$heightFrontBackCoverDisplay"mm" else echo "Side height = "$heightFrontBackCoverDisplay"mm" fi if ((${#widthFrontBackCoverDisplay} == 4)) then echo "Back width = 0"$widthFrontBackCoverDisplay"mm" else echo "Back width = "$widthFrontBackCoverDisplay"mm" fi if ((${#heightFrontBackCoverDisplay} == 4)) then echo "Back height = 0"$heightFrontBackCoverDisplay"mm" else echo "Back height = "$heightFrontBackCoverDisplay"mm" fi echo -e "\nBook content specifications for printing :" echo "Number of pages = "$countPageTotal if [ $countTable == 1 ] then echo "Total file size = "$size else echo "Total files size = "$size fi fi read exit 0 La routine présentée ci-dessus utilise les programmes (ou paquets) inkscape, librsvg2-bin, pdftk, et exiftool afin d'effectuer tous les traitements nécessaires. Il vous faut donc les installer à l'aide de la ligne de commande suivante (à écrire dans le terminal de Linux) : sudo apt-get install inkscape librsvg2-bin pdftk exiftool -y Une fois cette installation effectuée, lorsque vous exécutez la routine (.sh), se propose à vous dans l'ordre d'apparition les questions suivantes : - Page width in mm ? : largeur des pages (en millimètres).
- Page height in mm ? : hauteur des pages (en millimètres).
- Page margin in mm ? : dimensions des marges générales (en millimètres).
- Gutter margin in mm ? : dimension de la marge de reliure qui servira à positionner le texte en retrait par rapport à la reliure du livre afin de faciliter l'ergonomie de lecture (en millimètres).
- Font size in mm ? : taille des caractères du texte qui sera imprimé (en millimètres).
- Font name ? : police de caractère utilisée (elle doit être à espacement unique, par exemple "ubuntu mono").
- Cutter margin in mm ? : dimensions du fond perdu (en millimètres).
- File name prefix ? : préfixe qui sera visible avant le nom des fichiers (par exemple "Fichier monFichier.txt :").
- File size suffix ? : suffixe qui sera visible après le nom des fichiers indiquant la taille de ceux-ci en anglais ou en français (par exemple "myFile.txt (128 bytes) :" ou "monFichier.txt (128 octets) :").
- Line numbering ? : numérotation des lignes.
- File table title ? : titre de la table des fichiers (si omis, le titre "File table" sera affiché par défaut).
- Color style ? : surlignage en rouge des titres pour plus de visibilité (utile pour une impression couleur).
- Sort option ? : tri manuel de l'ordre d'apparition des fichiers dans le livre (intéressant si le tri alphanumérique par défaut n'est pas souhaité).
Si vous avez choisi l'option de tri "m" pour cette dernière question "Sort option ?", le menu "Manual sort :" (tri manuel) s'affiche à l'écran suivi de quelques commandes (détaillées ci-dessous), ainsi que l'arborescence des fichiers qui vont être inclus dans le livre, avec successivement le numéro d'apparition des fichiers et le chemin d'accès, c'est à ce moment que vous pouvez modifier l'ordre du tri. Voici ci-dessous le détail des commandes possibles : Détail des commandes du menu "Manual sort :" :
- e (pour "Exit" ou sortie) permet de sortir du menu et commencer la génération du livre.
- s (pour "Save" ou sauvegarde) permet de sauvegarder l'arborescence de fichiers dans un fichier nommé file.tree.
- l (pour "Load" ou chargement) permet de charger le fichier nommé file.tree contenant l'arborescence de fichiers.
- d (pour "Delete" ou suppression) permet de supprimer le fichier nommé file.tree contenant l'arborescence de fichiers.

Utilisez ces options pour sauvegarder l'arborescence avec la commande "s", la modifier en ouvrant manuellement le fichier file.tree avec un éditeur de texte (comme gedit par exemple). Puis rechargez cette arborescence modifiée avec la commande "l", vous verrez les modifications s'afficher dans le menu "File tree :".
Plus bas le menu "File tree :" est affiché, c'est l'arborescence de fichiers : La flèche orientée vers la gauche en suffixe des chemins d'accès aux fichiers indique la position de la destination d'un autre fichier source que vous pouvez choisir de déplacer. Validez pour décaler ce curseur vers une autre destination (c'est-à-dire vers le bas), ou écrivez un nombre, puis validez afin de changer la position dans l'arborescence (l'ordre de tri) du fichier indiqué en source (soit le nombre indiqué) vers la destination (soit le curseur en forme de flèche). Exemple :
- Le curseur est positionné sur le fichier numéro 3, c'est la destination.
- J'indique le numéro 10, c'est la source, puis je valide.
- Le fichier en position 10 (la source) prend la position 3 (la destination), et inversement, le 3 prend la position 10.
Lorsque l'ordre de tri des fichiers correspond à ce que vous souhaitez, indiquez la commande "e" puis validez pour sortir du menu et débuter la génération du livre. La génération du livre commence alors. Elle prend logiquement un temps proportionnel à la complexité de l'arborescence de fichiers utilisée comme source, ainsi que le nombre de lignes et de caractères dans la programmation et l'encodage de chaque fichiers. Une fois la génération du livre terminée, un fichier PDF nommé book content.pdf est constitué, et les spécifications utiles pour l'impression du livre sont affichées : - Book cover specifications for printing : caractéristiques de la couverture du livre pour l'impression.
- Total lenght (front + side + back) : longueur totale de la couverture (soit la somme des largeurs de la face avant, du dos, et de la face arrière).
- Front width : largeur de la face avant.
- Front height : hauteur de la face avant.
- Side width : largeur du dos.
- Side height : hauteur du dos.
- Back width : largeur de la face arrière.
- Back height : hauteur de la face arrière.

- Book content specifications for printing : caractéristiques du contenu du livre pour l'impression.
- Number of pages : nombre total de pages du contenu du livre.
- Total files size : taille totale des fichiers de votre arborescence faisant partie du contenu, ce qui correspond à la taille totale des fichiers inclus dans le livre, autrement dit, le contenu utile (cette taille exclue donc les titres et la numérotation des pages, de même que la table des fichiers à la toute fin du livre qui n'est là que pour faciliter la navigation dans l'ouvrage final imprimé).
Note importante : la largeur du dos du livre est calculée par rapport à un papier de 100g/m². Toutes ces caractéristiques vont vous permettre de créer la couverture du livre manuellement. Dans la continuité, la génération de la couverture aurait pu être également automatisée, mais je pense que c'est contre-artistique, ne laissant plus aucun libre cours à la création et l'imagination. C'est donc un choix mûrement réfléchit de ma part que de laisser la création de la couverture à la charge de l'auteur. Après avoir créé la couverture de votre livre à votre guise, il suffit simplement d'envoyer cette dernière ainsi que le fichier book content.pdf à un imprimeur ! Libre à vous de faire une utilisation de ce petit programme de génération automatique de contenu de livre, lorsque vous aurez besoin de sauvegarder vos fichiers sur un autre support que ceux habituellement utilisés dans le monde du numérique !