-
Notifications
You must be signed in to change notification settings - Fork 188
do not replace existing XMP metadata if any #44
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
base: master
Are you sure you want to change the base?
do not replace existing XMP metadata if any #44
Conversation
we should not simply replace and lose existing XMP metadata if any already set
I'm afraid it is not that simple. |
XMP metadata can already be filled by the dev which is generating a new document from scratch. Either case it is bad to just replace as it's currently done. Until a proper PdfMetadata implementation (which means access properties individually, not setting a plain text XMP XML), we should not simply replace. Why don't you want to keep old metadata? At least dev should have control of how metadata is handled, it should not be just lost. |
Another solution would be to add a document option in PdfDocumentOptions => XmpMetadata, which would have 2 values: auto/manual. |
in order to have full control
I updated my pull request. The behavior is now depending on PdfDocumentOptions.ManualXmpGeneration: The value is false by default, which means by default XMP metadata will be generated by PdfSharp and attached to the document silently. This will allow devs who want to build their own XMP metadata to do so, without it being overriden by PdfSharp. |
As a developer, who reported this issue I would say thank you for fixing it. The flag will be enough for us to keeping PdfSharp. Maybe just rename it to "PreserveMetadata". As an architect... well. It depends what do you want to achieve. If you just want to write properties like ProducerTool and ModDate, then overwriting the whole metadata is just not right. The metadata might contain information critical for the document. For example - it might contain some PDF/A conformance info. Also keep in mind that Metadata may appear in /Page objects. Some devices require it for batch printing. I'm modifying it by combination of PdfSharp and XmpCore. It works pretty well. |
Totally agree, PdfSharp should not brutally overwrite existing metadata set by developer or existing on third party pdf.
To give an example, in my company, we even want to have control on the ModifyDate in Xmp's metadata. |
XmpCore has BSD license, so maybe the source code can be copied to PdfSharp, without making strong DLL/nuget dependency: "arbitrary decide which metadata is overwritten? and on what schemas (dublin core, xmp 1.0, etc.)?" - derive it from original document, if possible. For new documents it should be allowed to specify the schema (via enum etc.). "IMO developer should always have control on what is the output. Metadata should not be added at PreSave time without any chance to modify what has been silently changed." - Yes. In my opinion it also applies to ProducerTool. From my perspective I would like to avoid exposing information about our software externally. This is rather security consideration. |
Totally agree, overwriting existing metadata is not good. |
Partial update of XMP data is a bit of a work... NB: this feature is available in PDFsharp-extended nuget package |
@ThomasHoevel : is there an update on this? For https://github.com/stephanstapel/ZUGFeRD-csharp, we also need to be able to write custom xmp data. |
Hi, I've been looking into @stephanstapel 's ZUGFeRD-csharp library (thanks @stephanstapel! ) for the last few days wondering why the validation was failing after adding my own Metadata, ultimately to track down the same "feature" in the public master branch which lead me to this PR, so wanted to add a +1 to this request. Update: Just to add a bit of clarity to my comments above, I took ZUGFeRD-csharp and re-pointed it to the master branch version of PDFSharp (also cloned locally) and stepped through the code in Visual Studio.
And I continue to add my own Metadata, then I can generate a PDF file that passes ZUGFeRD validation. |
How come this is closed? We would also want this feature. It is present in other libraries some PdfSharp-Extended. But we don't want to mix libraries. We love this one :) |
It would be very helpfull if this is fixed! |
This is not closed.
We have it on our list. We want a clean solution, not a quick hack that solves one issue, but leads to other issues. |
Hi @ThomasHoevel , that is great to hear, thanks a lot for your answer. Is there anything I/ we can do to support you? |
Any updates on this one? It'd be really helpful. Is there any way I can support? |
we should not simply replace and lose existing XMP metadata if any already set
NB: this feature is available in PDFsharp-extended nuget package