Probably the best way to automate any complex task is through Linux and Bash scripts. I was able to successfully do this (with much help from https://stackoverflow.):

I created a script that, when exporting my html invoice to a specific folder, it would

1) Find all the <table> tags and add a unique 'class' to each
2) Inject a CSS tag in the header to stylize each table and manipulate the layout
3) Export the html file to another folder as a pdf document

So as soon as the file is saved as html, the pdf is ready to print or email. The main purpose was to transform the default, and painfully plain, invoice into my own branded beauty; as I had it with Quickbooks.

Here are my notes:

-Programs installed:

    incron (monitors folders and files for changes)
    wkhtmltopdf (converts html files to pdf [MUST use the vesion with patches])

-To monitor the folder:

    incrontab -e

    /home/me/business/clients/invoices/process IN_CREATE,IN_MOVED_TO /home/me/business/clients/invoices/makeinvoice.sh


-The script makeinvoice.sh:

    #!/bin/bash
    rootdir=/home/alan/business/clients/invoices
    getfile=$(ls -Art $rootdir/process/*.html | tail -1)
    filename=$(basename "$getfile")
    extension="${filename##*.}"
    filename="${filename%.*}"
    awk '/<table/{sub(/<table/, "<table class=\"table"++i"\"")} 1' $rootdir/process/$filename.html > $rootdir/html/$filename.html &&     sed -i '/<head>/a <link rel="stylesheet" type="text/css" href="../css/custom.css">' $rootdir/html/$filename.html &&
    rm $rootdir/process/*.html
    $rootdir/wkhtmltox/bin/wkhtmltopdf $rootdir/html/$filename.html $rootdir/pdf/$filename.pdf &&
    exit

-The custom.css file:

* html,
body * {
  font-family: "times new roman", serif !important;
  font-size: 12pt !important;
}

a {  font-size: inherit !important; font-style: italic;  }
body, p, table, tr, td { text-align: left;  font-size: inherit !important;  }
tr.alternate-row { background: #ffffff }
th.column-heading-left { text-align: left;  font-size: inherit !important;  } th.column-heading-center { text-align: center;  font-size: inherit !important;  } th.column-heading-right { text-align: right;  font-size: inherit !important;  }
td.neg { color: red;  }
td.number-cell, td.total-number-cell { text-align: right; white-space: nowrap; }
td.date-cell { white-space: nowrap; }
td.anchor-cell { white-space: nowrap;  font-size: inherit !important;  }
td.number-cell {  font-size: inherit !important;  }
td.number-header { text-align: right;  font-size: inherit !important;  }
td.text-cell {  font-size: inherit !important;  }
td.total-number-cell {  font-size: inherit !important; font-weight: normal !important;  } td.total-label-cell {  font-size: inherit !important; font-weight: normal !important;  } td.centered-label-cell { text-align: center;  font-size: inherit !important; font-weight: bold;  }

table,
tbody,
tr,
td {
  display: inline-block;
}

.table1 {
  position: relative;
  width:780px;
}

.table1 h3 {
    font-size: 20pt !important;
}

.table1 > tbody > tr:nth-child(3),
.table1 > tbody > tr:nth-child(3) > td:first-child {
    width: 780px;
    max-width: 780px;
}

.table1 > tbody > tr:nth-child(2) {
  clear: both;
  float: left;
  width: 100%;
  border-top: 1px solid #333;
  text-align: right;
  margin-top: 15px;
}

.table1 > tbody > tr:nth-child(1) {
  display: block;
  width: 50%;
  float: left;
}

.table2 tbody>tr:nth-child(1) {
  display: none !important;
}

.table2 tr:nth-child(3) {
  display: none;
}

.table2 {
  position: absolute;
  left: 395px;
  top: 80px;
}

.table2 td {
    text-align: right;
}

.table2 tr td::before {
    content: 'http://visualiswebdesign.com (562) 305-2862  ';
    display: block;
    float: left;
    margin-right: 10px;
    position: relative;
    max-width: 185px;
    height: 35px;
    border-right: 1px solid #555;
    padding-right: 1em;
}

.table2 tbody tr:nth-child(2) {
  border-top: none;
  float: none;
  width: auto;
  clear: inherit;
}

.table3 {
    position: absolute;
    left: 617px;
    text-align: right;
    max-width: 180px;
}

.table3 + br,
.table3 + br + br {
    display: none;
}

.table3 > tbody > tr:nth-child(1) {
  display: flex;
}

.table3 > tbody > tr:nth-child(1) td,
.table3 > tbody > tr:nth-child(2) td{
    width: auto;
}

.table4 {
    position: relative;
    top: -35px;
}

.table5 {
  display: table;
  width: 100%;
  border-collapse: collapse;
  border: none;
}

.table5 tbody {
  display: table;
  width: 100%;
}

.table5 th {
    border: none;
    text-align: center;
    font-family: arial, helvetica, sans-serif !important;
    font-size: 8pt !important;
    text-transform: uppercase;
    color: #444;
}

.table5 tr {
  display: table-row !important;
  width: 100% !important;
  float: none !important;
}

.table5 td {
  display: table-cell;
  border: 1px solid #444;
}

.table5 > tbody > tr > th:nth-child(1) {
  width: 90px;
}

.table5 > tbody > tr > th:nth-child(3) {
  width: 55px;
}

.table5 > tbody > tr > th:nth-child(4),
.table5 > tbody > tr > th:nth-child(5) {
  width: 65px;
}

.table5 > tbody > tr:nth-child(2) td {
    height: 25px;
}

.table5 > tbody > tr:nth-child(3) td {

}

.table5 > tbody > tr:last-child > td {
    font-weight: bold !important;
}

.table6 tbody tr,
.table6 tbody tr td {
    border: none !important;
}


Hope this helps.

On 01/30/2018 11:59 PM, bob_summers wrote:
Hi, I've been using GnuCash for a few years in my business, a language
academy, and it does everything I need it to, which is; generate invoices,
track their payment, and send a few reports every tax quarter.  I send
around 80 invoices on the first of the month, generally all for the same
amount (some get family discounts).

My current workflow is:
1. Raise 80 invoices,
2. Generate easy-invoice reports for each,
3. Save these reports to .pdf
4. Mail out the reports (Thunderbird).

All of this is done one by one, takes a few hours, and is prone to errors.
If anyone has an idea how to automate any of the steps, especially the last
three, I'd love to hear about it.

Cheers!



--
Sent from: http://gnucash.1415818.n4.nabble.com/GnuCash-User-f1415819.html
_______________________________________________
gnucash-user mailing list
gnucash-user@gnucash.org
To update your subscription preferences or to unsubscribe:
https://lists.gnucash.org/mailman/listinfo/gnucash-user
If you are using Nabble or Gmane, please see 
https://wiki.gnucash.org/wiki/Mailing_Lists for more information.
-----
Please remember to CC this list on all your replies.
You can do this by using Reply-To-List or Reply-All.


_______________________________________________
gnucash-user mailing list
gnucash-user@gnucash.org
To update your subscription preferences or to unsubscribe:
https://lists.gnucash.org/mailman/listinfo/gnucash-user
If you are using Nabble or Gmane, please see 
https://wiki.gnucash.org/wiki/Mailing_Lists for more information.
-----
Please remember to CC this list on all your replies.
You can do this by using Reply-To-List or Reply-All.

Reply via email to