HTMLDOC è un programma open source che può essere utilizzato per convertire file sorgente HTML e Markdown in file PostScript e PDF. Esistono due tipi di file HTML, 1) documenti strutturati con intestazioni come H1, H2, ecc. noti come libri e 2) documenti non strutturati senza intestazioni noti come pagine Web.
In questo tutorial, spiegheremo come installare HTMLDOC su Debian 10 e convertire un file HTML in pdf.
Requisiti
- Un server che esegue Debian 10.
- Sul tuo server è configurata una password di root.
Per iniziare
Innanzitutto, aggiorna il tuo sistema con l'ultima versione eseguendo il comando seguente:
apt-get update -y
apt-get upgrade -y
Una volta aggiornato il sistema, riavvialo per applicare le modifiche alla configurazione.
Installa HTMLDOC
Per impostazione predefinita, HTMLDOC è disponibile nel repository predefinito di Debian 10. Puoi installarlo semplicemente eseguendo il seguente comando:
apt-get install htmldoc -y
Dopo aver installato HTMLDOC, puoi elencare tutte le opzioni disponibili con HTMLDOC con il seguente comando:
htmldoc --help
Crea il tuo primo PDF da HTML
Innanzitutto, crea un file test.html con il seguente comando:
nano test.html
Aggiungi il seguente codice:
<html> <head> <title>This is my first PDF</title> </head> <body> This is the body of my first PDF. </body> </html>
Salva e chiudi il file, quando hai finito.
Ora, esegui il seguente comando per convertire test.html in test.pdf con il seguente comando:
htmldoc --webpage -f test.pdf test.html
Il comando precedente genererà un nuovo file pdf denominato test.pdf.
Congratulazioni! hai installato con successo HTMLDOC sul server Debian 10.