Hi,
thanks for the fast reply.
For the first part we got the pdf and xml I uploaded with the path of xml in xInvoiceFile and a filehandler pdf filehandler and the related pdf
If System.IO.File.Exists(xInvoiceFile) Then
Dim fSpecDict As System.Collections.Generic.Dictionary<String, String> = New System.Collections.Generic.Dictionary<String, String>()
fSpecDict.Add("AFRelationship", "Alternative")
Dim fh As FileHandler = FileHandler.GetFileHandler(xInvoiceFile)
pdfFileHandler.AddAttachment(fh, fSpecDict)
For the second part we have the AddAttachment(…) method:
using (Document document = HasDataStream ? new Document(DataStream) : new Document(Filename))
{
FileSpecification fspec = new FileSpecification(addFileHandler.Filename);
fspec.Encoding = FileEncoding.None;
if (!string.IsNullOrEmpty(addFileHandler.Filename))
{
fspec.Description = Res.GetString(new CultureInfo("de-DE"), "ZUGFeRD Filedescription");
fspec.MIMEType = SBW.IO.MimeType.GetMimeType(addFileHandler.Filename).Value;
}
else
{
if (addFileHandler.MimeType != null)
fspec.MIMEType = addFileHandler.MimeType.Value;
}
document.EmbeddedFiles.Add(Path.GetFileName(addFileHandler.Filename), fspec);
FileParams fparams = new FileParams(fspec);
fparams.CreationDate = DateTime.Now;
fparams.ModDate = DateTime.Now;
fspec.Params = fparams;
document.Convert(new MemoryStream(), document.PdfFormat, ConvertErrorAction.Delete);
if (fileSpecificationDict != null)
{
foreach (KeyValuePair<string, string> kvp in fileSpecificationDict)
fspec.SetValue(kvp.Key, kvp.Value);
}
document.Save(Filename);
I also tried setting all fspec properties except params before adding it to the document with no success.
sourcefiles.zip (68.4 KB)