summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexis de Lattre <alexis.delattre@akretion.com>2018-05-23 22:33:05 (GMT)
committerAlexis de Lattre <alexis.delattre@akretion.com>2018-05-23 22:33:05 (GMT)
commitdf78d61c36cdd757eeaed03bdfc933202dc7ae65 (patch)
tree0ef3a13777948189bd2eb78021f0f9bbad2efaff
parentce98ee9b52071101dc32362c9dded904a9eba8e8 (diff)
downloadfactur-x-df78d61c36cdd757eeaed03bdfc933202dc7ae65.zip
factur-x-df78d61c36cdd757eeaed03bdfc933202dc7ae65.tar.gz
factur-x-df78d61c36cdd757eeaed03bdfc933202dc7ae65.tar.bz2
[FIX] XMP structure under /x:xmpmeta/rdf:RDF/rdf:Description (use XML tags instead of XML attributes)
declare PDF-1.6 instead of PDF-1.3 (still declared by default by pyPDF2)
-rw-r--r--README.rst5
-rw-r--r--facturx/_version.py2
-rw-r--r--facturx/facturx.py19
3 files changed, 20 insertions, 6 deletions
diff --git a/README.rst b/README.rst
index 330fe48..325091c 100644
--- a/README.rst
+++ b/README.rst
@@ -56,6 +56,11 @@ Contributors
Changelog
=========
+* Version 0.7 dated 2018-05-24
+
+ * Fix XMP structure under /x:xmpmeta/rdf:RDF/rdf:Description (use XML tags instead of XML attributes)
+ * declare PDF-1.6 instead of PDF-1.3 (still declared by default by pyPDF2)
+
* Version 0.6 dated 2018-05-01
* Now fully PDF/A-3 compliant with additionnal attachments (tested with veraPDF)
diff --git a/facturx/_version.py b/facturx/_version.py
index 27fda16..e220fa9 100644
--- a/facturx/_version.py
+++ b/facturx/_version.py
@@ -1 +1 @@
-__version__ = '0.6'
+__version__ = '0.7'
diff --git a/facturx/facturx.py b/facturx/facturx.py
index c386d64..4314101 100644
--- a/facturx/facturx.py
+++ b/facturx/facturx.py
@@ -37,6 +37,7 @@ from datetime import datetime
from PyPDF2 import PdfFileWriter, PdfFileReader
from PyPDF2.generic import DictionaryObject, DecodedStreamObject,\
NameObject, createStringObject, ArrayObject
+from PyPDF2.utils import b_
from pkg_resources import resource_filename
import os.path
import mimetypes
@@ -299,11 +300,18 @@ def _prepare_pdf_metadata_xml(facturx_level, pdf_metadata):
facturx_desc = etree.SubElement(
rdf, ns_rdf + 'Description', nsmap=nsmap_fx)
facturx_desc.set(ns_rdf + 'about', '')
- facturx_desc.set(
- ns_fx + 'ConformanceLevel', FACTURX_LEVEL2xmp[facturx_level])
- facturx_desc.set(ns_fx + 'DocumentFileName', FACTURX_FILENAME)
- facturx_desc.set(ns_fx + 'DocumentType', 'INVOICE')
- facturx_desc.set(ns_fx + 'Version', '1.0')
+ fx_doc_type = etree.SubElement(
+ facturx_desc, ns_fx + 'DocumentType', nsmap=nsmap_fx)
+ fx_doc_type.text = 'INVOICE'
+ fx_doc_filename = etree.SubElement(
+ facturx_desc, ns_fx + 'DocumentFileName', nsmap=nsmap_fx)
+ fx_doc_filename.text = FACTURX_FILENAME
+ fx_doc_version = etree.SubElement(
+ facturx_desc, ns_fx + 'Version', nsmap=nsmap_fx)
+ fx_doc_version.text = '1.0'
+ fx_conformance_level = etree.SubElement(
+ facturx_desc, ns_fx + 'ConformanceLevel', nsmap=nsmap_fx)
+ fx_conformance_level.text = FACTURX_LEVEL2xmp[facturx_level]
# TODO: should be UTF-16be ??
xml_str = etree.tostring(
@@ -751,6 +759,7 @@ def generate_facturx_from_file(
# Extract /OutputIntents obj from original invoice
output_intents = _get_original_output_intents(original_pdf)
new_pdf_filestream = PdfFileWriter()
+ new_pdf_filestream._header = b_("%PDF-1.6")
new_pdf_filestream.appendPagesFromReader(original_pdf)
original_pdf_id = original_pdf.trailer.get('/ID')