diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php
index b0cda2ecd6a..30d6b82bb21 100644
--- a/htdocs/core/lib/pdf.lib.php
+++ b/htdocs/core/lib/pdf.lib.php
@@ -129,8 +129,11 @@ function pdf_getInstance($format='',$metric='mm',$pagetype='P')
//$format=array($arrayformat['width'],$arrayformat['height']);
//$metric=$arrayformat['unit'];
- if (class_exists('TCPDI')) $pdf = new TCPDI($pagetype,$metric,$format);
- else $pdf = new TCPDF($pagetype,$metric,$format);
+ $pdfa=false; // PDF-1.3
+ if (! empty($conf->global->PDF_USE_1A)) $pdfa=true; // PDF1/A
+
+ if (class_exists('TCPDI')) $pdf = new TCPDI($pagetype,$metric,$format,true,'UTF-8',false,$pdfa);
+ else $pdf = new TCPDF($pagetype,$metric,$format,true,'UTF-8',false,$pdfa);
// Protection and encryption of pdf
if (! empty($conf->global->PDF_SECURITY_ENCRYPTION))
diff --git a/htdocs/includes/tcpdi/tcpdi.php b/htdocs/includes/tcpdi/tcpdi.php
index 999ff99ea5b..675e2226b4a 100644
--- a/htdocs/includes/tcpdi/tcpdi.php
+++ b/htdocs/includes/tcpdi/tcpdi.php
@@ -135,7 +135,7 @@ class TCPDI extends FPDF_TPL {
*
* @return string
*/
- function setPDFVersion($version = '1.3') {
+ function setPDFVersion($version = '1.7') {
$this->PDFVersion = $version;
}
diff --git a/htdocs/website/index.php b/htdocs/website/index.php
index 89528c10b91..8d8a7bfea36 100644
--- a/htdocs/website/index.php
+++ b/htdocs/website/index.php
@@ -2076,14 +2076,14 @@ if ($action == 'editmeta' || $action == 'createcontainer')
print '
| ';
print $langs->trans('WEBSITE_TITLE');
print ' | ';
- print '';
+ print '';
print ' |
';
// Alias
print '| ';
print $langs->trans('WEBSITE_PAGENAME');
print ' | ';
- print '';
+ print '';
print ' |
';
print '| ';
@@ -2138,7 +2138,6 @@ if ($action == 'editmeta' || $action == 'createcontainer')
print ' |
';
print '';
-
if ($action == 'createcontainer')
{
print '';
@@ -2149,7 +2148,26 @@ if ($action == 'editmeta' || $action == 'createcontainer')
print '
';
}
-
+ if ($action == 'createcontainer')
+ {
+ print '';
+ }
//print '';
//dol_fiche_end();
diff --git a/scripts/invoices/facturex-pdfextractxml.py b/scripts/invoices/facturex-pdfextractxml.py
new file mode 100755
index 00000000000..fe1e96ccadd
--- /dev/null
+++ b/scripts/invoices/facturex-pdfextractxml.py
@@ -0,0 +1,97 @@
+#! /usr/bin/python
+# -*- coding: utf-8 -*-
+# © 2017 Alexis de Lattre
+
+from optparse import OptionParser
+import sys
+from facturx import get_facturx_xml_from_pdf
+from facturx.facturx import logger
+import logging
+from os.path import isfile, isdir
+
+__author__ = "Alexis de Lattre "
+__date__ = "August 2017"
+__version__ = "0.1"
+
+options = [
+ {'names': ('-l', '--log-level'), 'dest': 'log_level',
+ 'action': 'store', 'default': 'info',
+ 'help': "Set log level. Possible values: debug, info, warn, error. "
+ "Default value: info."},
+ {'names': ('-d', '--disable-xsd-check'), 'dest': 'disable_xsd_check',
+ 'action': 'store_true', 'default': False,
+ 'help': "De-activate XML Schema Definition check on Factur-X XML file "
+ "(the check is enabled by default)"},
+ ]
+
+
+def main(options, arguments):
+ if options.log_level:
+ log_level = options.log_level.lower()
+ log_map = {
+ 'debug': logging.DEBUG,
+ 'info': logging.INFO,
+ 'warn': logging.WARN,
+ 'error': logging.ERROR,
+ }
+ if log_level in log_map:
+ logger.setLevel(log_map[log_level])
+ else:
+ logger.error(
+ 'Wrong value for log level (%s). Possible values: %s',
+ log_level, ', '.join(log_map.keys()))
+ sys.exit(1)
+
+ if len(arguments) != 2:
+ logger.error(
+ 'This command requires 2 arguments (%d used). '
+ 'Use --help to get the details.', len(arguments))
+ sys.exit(1)
+ pdf_filename = arguments[0]
+ out_xml_filename = arguments[1]
+ if not isfile(pdf_filename):
+ logger.error('Argument %s is not a filename', pdf_filename)
+ sys.exit(1)
+ if isdir(out_xml_filename):
+ logger.error(
+ '2nd argument %s is a directory name (should be a the '
+ 'output XML filename)', out_xml_filename)
+ sys.exit(1)
+ pdf_file = open(pdf_filename)
+ check_xsd = True
+ if options.disable_xsd_check:
+ check_xsd = False
+ # The important line of code is below !
+ try:
+ (xml_filename, xml_string) = get_facturx_xml_from_pdf(
+ pdf_file, check_xsd=check_xsd)
+ except Exception as e:
+ logger.error(e)
+ sys.exit(1)
+ if xml_filename and xml_string:
+ if isfile(out_xml_filename):
+ logger.warn(
+ 'File %s already exists. Overwriting it!', out_xml_filename)
+ xml_file = open(out_xml_filename, 'w')
+ xml_file.write(xml_string)
+ xml_file.close()
+ logger.info('File %s generated', out_xml_filename)
+ else:
+ logger.warn('File %s has not been created', out_xml_filename)
+ sys.exit(1)
+
+
+if __name__ == '__main__':
+ usage = "Usage: facturx-pdfextractxml "
+ epilog = "Author: %s\n\nVersion: %s" % (__author__, __version__)
+ description = "This extracts the XML file from a Factur-X invoice."
+ parser = OptionParser(usage=usage, epilog=epilog, description=description)
+ for option in options:
+ param = option['names']
+ del option['names']
+ parser.add_option(*param, **option)
+ options, arguments = parser.parse_args()
+ sys.argv[:] = arguments
+ main(options, arguments)
+
+
\ No newline at end of file