aeroo / aeroo_docs

Aeroo DOCS - a document conversion service
GNU General Public License v3.0
10 stars 29 forks source link

Patch: PDF/A instead of "normal PDF" #13

Open RolfWojtech opened 8 years ago

RolfWojtech commented 8 years ago

Today one of our customers rejected our invoice and demanded on in PDF/A form ( https://en.wikipedia.org/wiki/PDF/A )

So I took the time to figure out how to output PDF/A in aeroo docs by passing the SelectPdfVersion=1 to OpenOffice/Libreoffice.. The result is the following patch:

--- /srv/odoo/aeroo_docs/DocumentConverter.py.org       2015-07-31 15:39:20.300000000 +0200
+++ /srv/odoo/aeroo_docs/DocumentConverter.py   2015-07-31 15:39:38.188000000 +0200
@@ -195,6 +195,8 @@
         if filter_name == 'Text - txt - csv (StarCalc)':
             properties.update({"FilterOptions": CSVFilterOptions})
         props = self._toProperties(**properties)
+        if filter_name == 'writer_pdf_Export':
+            props += ( PropertyValue( "FilterData", 0, uno.Any("[]com.sun.star.beans.PropertyValue", self._toProperties(SelectPdfVersion = 1), ), 0 ), )
         try:
             #url = uno.systemPathToFileUrl(path) #when storing to filesystem
             self.document.storeToURL('private:stream', props)

A similar patch works for report_aeroo_ooo/DocumentConverter.py

155a156,161
>         outputproperties = self._toProperties(OutputStream = outputStream, FilterName = filter_name, FilterOptions=CSVFilterOptions)
>         if filter_name == 'writer_pdf_Export':
>             outputproperties += ( PropertyValue( "FilterData", 0, uno.Any("[]com.sun.star.beans.PropertyValue", self._toProperties(SelectPdfVersion = 1), ), 0 ), )
157c163
<             self.document.storeToURL('private:stream', self._toProperties(OutputStream = outputStream, FilterName = filter_name, FilterOptions=CSVFilterOptions))

---
>             self.document.storeToURL('private:stream', outputproperties)
163a170
>

I am not sure if I will find the time for a proper pull request for this feature, especially because Aeroo Docs as a generic server cannot really output PDF/A by default. However for use in conjunction with OpenERP/Odoo, PDF/A clearly makes more sense and I wanted to share this in case somebody else needs it or maybe alistek wants to include the idea one way or another