akretion/factur-x

Bad type for check_xsd argument

cef-informatique opened this issue · 2 comments

Hi,

I'm trying to use the extract xml function in this script :

from facturx import get_xml_from_pdf

pdf_filename = r"C:\Users\user\...\tmp\TEST_006251.pdf"
xml_filename = r"C:\Users\user\...\tmp\factur-x.xml"

check_xsd = False

get_xml_from_pdf(pdf_filename, xml_filename, check_xsd)

but it returns the following error :

Traceback (most recent call last):
  File "c:\Users\user\...\script\script.py", line 8, in <module>
    get_xml_from_pdf(pdf_filename, xml_filename, check_xsd)
  File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\facturx\facturx.py", line 292, in get_xml_from_pdf
    raise ValueError('Bad type for check_xsd argument')
ValueError: Bad type for check_xsd argument

I gather it's expecting a boolean value for check_xsd and somehow doesn't get it.

If I try :

check_xsd = False

get_xml_from_pdf(pdf_filename, xml_filename, check_xsd=check_xsd)

I get :

Traceback (most recent call last):
  File "c:\Users\user\...\script\script.py", line 8, in <module>
    get_xml_from_pdf(pdf_filename, xml_filename, check_xsd=check_xsd0)
TypeError: get_xml_from_pdf() got multiple values for argument 'check_xsd'

Solved it using this formatting :

pdf_filename = "myinvoice.pdf"
file = open(pdf_filename, 'rb')
facture = file.read()
filename, xml = get_xml_from_pdf(facture)