Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add xml info to pdf metadata2 #15

Merged
merged 22 commits into from
Mar 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
ca88132
Bump to 2.3.0
raphaelm May 2, 2023
a512671
PR #7 Include XML information in PDF metadata (cmcproject)
MAKOMO Jan 6, 2024
e7f4cb7
update mustang validator
MAKOMO Jan 6, 2024
0e762bd
fixes fx:DocumentFileName / fx:DocumentType order
MAKOMO Jan 6, 2024
29a209c
remove `schemas/ZUGFeRD2p2_extension_schema.xmp` (replaced by `xmp_sc…
MAKOMO Jan 6, 2024
7a6486e
removes date and seller from pdf metadata subject to simplify the cod…
MAKOMO Jan 6, 2024
9eb05e0
removes doc type date and seller from pdf metadata subject (incl. the…
MAKOMO Jan 6, 2024
75b0588
remove unused (now) unused constant INVOICE_TYPE_CODE and avoid the u…
MAKOMO Jan 6, 2024
30565e0
removes failing "Invalid doc type! XML value for TypeCode shall be 38…
MAKOMO Jan 6, 2024
5b2cabf
allows to supply explicit profile level and extends profile auto dete…
MAKOMO Jan 6, 2024
e95c830
minor code style improvements like lazy % formatting in logging funct…
MAKOMO Jan 6, 2024
6e961ca
fixes style (black)
MAKOMO Jan 6, 2024
f4d2a12
tests of auto detecting a XRechnung v2 and v3 profiles
MAKOMO Jan 6, 2024
cf8af74
blacking again
MAKOMO Jan 6, 2024
2510362
tests for en16931 auto profile recognition and auto profile recogniti…
MAKOMO Jan 6, 2024
0637c19
black again
MAKOMO Jan 6, 2024
84973c2
typo
MAKOMO Jan 20, 2024
50d8fd0
allow users to set custom pdf metadata and the PDF language identifie…
MAKOMO Jan 28, 2024
41af560
black
MAKOMO Jan 29, 2024
aac0ad2
spelling
MAKOMO Jan 29, 2024
2fb3a1c
Update drafthorse/pdf.py
raphaelm Mar 10, 2024
6ad2822
Run black
raphaelm Mar 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ further abstractions or simplifications. You can set and parse all parameters de
All output is validated against the official XSDs, but no validation of profile levels
(basic, comfort, extended) is performed.

The profile level is detected automatically based on the XML data and added to the PDF metadata.

Usage
-----

Expand Down Expand Up @@ -112,7 +114,7 @@ Generating::
# Note that the existing PDF should be compliant to PDF/A-3!
# You can validate this here: https://www.pdf-online.com/osa/validate.aspx
with open("input.pdf", "rb") as original_file:
new_pdf_bytes = attach_xml(original_file.read(), xml, 'EXTENDED')
new_pdf_bytes = attach_xml(original_file.read(), xml)

with open("output.pdf", "wb") as f:
f.write(new_pdf_bytes)
Expand All @@ -135,9 +137,9 @@ To validate files using mustang::

git clone https://github.com/ZUGFeRD/mustangproject.git
cd mustangproject
git checkout core-2.5.1
git checkout core-2.9.0
./mvnw clean package
java -jar Mustang-CLI/target/Mustang-CLI-2.5.1-SNAPSHOT.jar --action validate --source invoice.pdf
java -jar Mustang-CLI/target/Mustang-CLI-2.7.4-SNAPSHOT.jar --action validate --source invoice.pdf


Credits and License
Expand Down
2 changes: 1 addition & 1 deletion drafthorse/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = "2.2.2"
version = "2.3.0"
7 changes: 4 additions & 3 deletions drafthorse/models/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
class BaseElementMeta(type):
@classmethod
def __prepare__(self, name, bases):
del name, bases
return collections.OrderedDict()

def __new__(mcls, name, bases, attrs):
Expand Down Expand Up @@ -50,7 +51,7 @@

def to_etree(self):
node = self._etree_node()
for k, v in self._data.items():
for _, v in self._data.items():
if v is not None:
v.append_to(node)
return node
Expand Down Expand Up @@ -309,7 +310,7 @@
self._text = root.text
try:
self._scheme_id = root.attrib["schemeID"]
except:
except Exception:
root.attrib["schemeID"] = ""
self._scheme_id = root.attrib["schemeID"]
self._set_on_input = True
Expand Down Expand Up @@ -386,7 +387,7 @@
def from_etree(self, root):
try:
self._value = datetime.strptime(root.text, "%Y-%m-%dT%H:%M:%S").date()
except:
except Exception:

Check warning on line 390 in drafthorse/models/elements.py

View check run for this annotation

Codecov / codecov/patch

drafthorse/models/elements.py#L390

Added line #L390 was not covered by tests
self._value = ""
self._set_on_input = True
return self
Expand Down
Loading
Loading