Click here to Skip to main content
15,883,889 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi All,
I need a solution for converting a simple PDF to PDF A/3 format with xml file embedded by adding an image or icon before converting to a/3 format with any open source. Please help

Thanks in advance

What I have tried:

byte[] doc_bytes_invoice_added = null;
                string input = @"C':\test\";
                using (PDFDoc in_doc = new PDFDoc(input + "output.pdf"))
                {
                    in_doc.InitSecurityHandler();
                    NameTree files = NameTree.Create(in_doc, "EmbeddedFiles");
                    FileSpec fs = FileSpec.Create(in_doc, input + "ZUGFeRD-invoice.xml", true);
                    byte[] file1_name = System.Text.Encoding.UTF8.GetBytes("ZUGFeRD-invoice.xml");
                    files.Put(file1_name, fs.GetSDFObj());
                    fs.GetSDFObj().PutText("Desc", "ZUGFeRD Rechnung");
                    fs.GetSDFObj().PutName("AFRelationship", "Alternative");
                    fs.GetSDFObj().PutText("F", "ZUGFeRD-invoice.xml");
                    fs.GetSDFObj().PutText("UF", "ZUGFeRD-invoice.xml");
                    Obj collection = in_doc.GetRoot().FindObj("Collection");
                    if (collection == null) collection = in_doc.GetRoot().PutDict("Collection");
                    collection.PutName("View", "T");
                    doc_bytes_invoice_added = in_doc.Save(SDFDoc.SaveOptions.e_incremental);
                }
Posted
Updated 6-Oct-22 2:31am
v3

1 solution

Take a look at this CodeProject PDF library:
PDF File Writer C# Class Library (Version 2.0.0)[^]
 
Share this answer
 
Comments
runtime_terror 5-Oct-22 3:52am    
HI Rick, Thanks for the answer. Let me try the solution and keep you posted
runtime_terror 5-Oct-22 12:36pm    
Hi This doesn't have an xml embedded. And I need PDF-A/3 format specifically
RickZeeland 5-Oct-22 13:16pm    
Well in the article it says:
"Clicking anywhere within the cell's area will cause the PDF reader to activate the document link, web link, video, audio or embedded file."
RickZeeland 5-Oct-22 13:19pm    
And also:
"The PdfFileWriter supports embedding data files in the PDF document. Full example of embedding file is given in the page 7 of OtherExample.cs"
runtime_terror 6-Oct-22 4:27am    
Thanks Rick. I have updated the question. Can you please provide a solution for the same?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900