Skip to content

ZUGFeRDExporterFromA3 -> setXML removes existing Metadata fields like title #966

@thomass4t

Description

@thomass4t

We have a PDF file which contains XMP metadata like title, creator etc.
When attaching ZUGFeRD as XML, the XMP metadata gets lost.

Sample code:

        try (ZUGFeRDExporterFromA3 zea3 = new ZUGFeRDExporterFromA3().set)
        {
            zea3.load(pdfFile.getAbsolutePath());
            zea3.setXML(xml);

Going through the code, the Metadata gets lost during this code in ZUGFeRDExporterFromA3

	protected void prepareDocument() throws IOException {

		PDDocumentCatalog cat = doc.getDocumentCatalog();
		metadata = new PDMetadata(doc);
		cat.setMetadata(metadata);

		removeCidSet(doc);
		xmp = getXmpMetadata();

The line "cat.setMetadata" overwrites the existing metadata with an empty MetaData Object.

Unfortunately, I can't tell why these two lines exist and what the purpose is.

With ZUGFeRDExporterFromA3 I can only set producer and creator, but all existing MetaData like title are lost.
It would be great if somebody with experience could take a look at this part.
Maybe it would be enough to use the existing metadata (if present) instead of always setting a complete new metadata object.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions