Developers / Export Reports / Export Page/RDLX Reports / PDF Export / ZUGFeRD/Factur-X Invoices
ZUGFeRD/Factur-X Invoices

ActiveReports provides a special API for performing additional manual steps, required for creating ZUGFeRD reports. For details about this extension, see FeRD website.

You should note the information below when working with a ZUGFeRD report:

Adding Metadata in PDFs

An example of adding metadescriptions

Metadata such as keywords, descriptions are used by the search engines to narrow down the searches. You can add a number of predefined accessors, such as title, contributors, creators, copyright, description, etc. using AdditionalMetadata property. The allowed namespaces are:

VB code. Paste INSIDE the Form Load event.
Copy Code
Dim rptPath As System.IO.FileInfo = New System.IO.FileInfo("..\..\PageReport1.rdlx")
Dim pageReport As GrapeCity.ActiveReports.PageReport = New GrapeCity.ActiveReports.PageReport(rptPath)
Dim outputDirectory As System.IO.DirectoryInfo = New System.IO.DirectoryInfo("C:\MyPDF")
outputDirectory.Create()
Dim pdfSetting = New GrapeCity.ActiveReports.Export.Pdf.Page.Settings()
'Imports GrapeCity.ActiveReports.Export.Pdf
pdfSetting.AdditionalMetadata.Add(New AdditionalMetadataInfo With {
        .[Namespace] = AdditionalMetadataNamespace.PurlOrg,
        .Key = "title",
        .Value = "Invoice"
    })

Dim pdfRenderingExtension As GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension = New GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension()
Dim outputProvider As GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider = New GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider(outputDirectory, System.IO.Path.GetFileNameWithoutExtension(outputDirectory.Name))
outputProvider.OverwriteOutputFile = True

pageReport.Document.Render(pdfRenderingExtension, outputProvider, pdfSetting)
C# code. Paste INSIDE the Form Load event.
Copy Code
// Provide the Page report you want to render.
System.IO.FileInfo rptPath = new System.IO.FileInfo(@"..\..\PageReport1.rdlx");
GrapeCity.ActiveReports.PageReport pageReport = new GrapeCity.ActiveReports.PageReport(rptPath);

// Create an output directory.
System.IO.DirectoryInfo outputDirectory = new System.IO.DirectoryInfo(@"C:\MyPDF");
outputDirectory.Create();

// Add meta data.
var pdfSetting = new GrapeCity.ActiveReports.Export.Pdf.Page.Settings();

// using GrapeCity.ActiveReports.Export.Pdf;
pdfSetting.AdditionalMetadata.Add(new AdditionalMetadataInfo
{
    Namespace = AdditionalMetadataNamespace.PurlOrg, // Dublin Core Properties
    Key = "title",
    Value = "Invoice"
});
GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension pdfRenderingExtension = new GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension();
GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider outputProvider = new GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider(outputDirectory, System.IO.Path.GetFileNameWithoutExtension(outputDirectory.Name));
outputProvider.OverwriteOutputFile = true;
pageReport.Document.Render(pdfRenderingExtension, outputProvider, pdfSetting);

Adding Attachment

An example of adding metadescriptions

You can include an attachment as metadata (such as invoices) to exported PDFs using Attachments property. This property allows attaching files such as a .xml or a .txt file in PDF. Below is the code example to export RDLX and Page reports to PDF and attach a file to the exported PDF.

VB code. Paste INSIDE the Form Load event.
Copy Code
' Provide the Page report you want to render.
Dim rptPath As System.IO.FileInfo = New System.IO.FileInfo("..\..\PageReport1.rdlx")
Dim pageReport As GrapeCity.ActiveReports.PageReport = New GrapeCity.ActiveReports.PageReport(rptPath)

' Create an output directory.
Dim outputDirectory As System.IO.DirectoryInfo = New System.IO.DirectoryInfo("C:\MyPDF")
outputDirectory.Create()

' Add attachment.
Dim pdfSetting = New GrapeCity.ActiveReports.Export.Pdf.Page.Settings()
pdfSetting.Attachments.Add(New AttachmentInfo With {
   .Name = "file.txt",
   .Content = System.IO.File.ReadAllBytes("D:\Reports\file.txt"),
   .Description = "attachment description" ' optional
})
Dim pdfRenderingExtension As GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension = New GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension()
Dim outputProvider As GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider = New GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider(outputDirectory, System.IO.Path.GetFileNameWithoutExtension(outputDirectory.Name))
outputProvider.OverwriteOutputFile = True
pageReport.Document.Render(pdfRenderingExtension, outputProvider, pdfSetting)
C# code. Paste INSIDE the Form Load event.
Copy Code
// Provide the Page report you want to render.
System.IO.FileInfo rptPath = new System.IO.FileInfo(@"..\..\PageReport1.rdlx");
GrapeCity.ActiveReports.PageReport pageReport = new GrapeCity.ActiveReports.PageReport(rptPath);

// Create an output directory.
System.IO.DirectoryInfo outputDirectory = new System.IO.DirectoryInfo(@"C:\MyPDF");
outputDirectory.Create();

// Add attachment.
var pdfSetting = new GrapeCity.ActiveReports.Export.Pdf.Page.Settings();
// using GrapeCity.ActiveReports.Export.Pdf;
pdfSetting.Attachments.Add(new AttachmentInfo
{
    Name = "file.txt",
    Content = System.IO.File.ReadAllBytes(@"D:\Reports\file.txt"),
    Description = "attachment description" // optional
});
// or
//{
//   Name = "file.xml",
//   Content = File.ReadAllBytes(Application.StartupPath + "\\file.xml")
//};
GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension pdfRenderingExtension = new GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension();
GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider outputProvider = new GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider(outputDirectory, System.IO.Path.GetFileNameWithoutExtension(outputDirectory.Name));
outputProvider.OverwriteOutputFile = true;
pageReport.Document.Render(pdfRenderingExtension, outputProvider, pdfSetting);

Open the exported PDF and you should see the attachment. Check the left sidebar in Adobe Acrobat Reader DC.

Note: Metadata in PDFs is part of the Professional Edition. It is supported with the PDF version PDF/A-3b (or higher).