# ZUGFeRD/Factur-X Invoices

ActiveReports provides a special API for performing additional manual steps, required for creating ZUGFeRD reports.

## Content

ActiveReports provides a special API for performing additional manual steps, required for creating ZUGFeRD reports. For details about this extension, see [FeRD](https://www.ferd-net.de/en/standards/zugferd/factur-x) website.

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

* It should have the PDF/A-3 format.
* It should have the ZUGFeRD-invoice.xml attachment. We suggest to use the **Data Excel** export or **CSV**/**XML**/**JSON** exports to obtain data. We also suggest to use this [library](https://www.nuget.org/packages/ZUGFeRD-csharp) to generate ZUGFeRD-invoice.xml (for ZUGFeRD 1.0) or zugferd-invoice.xml (for ZUGFeRD 2.0) or factur-x.xml (for ZUGFeRD 2.1 and Factur-X).
* It should have additional XMP metadata.

### Adding Metadata in PDFs

![An example of adding metadescriptions](https://cdn.mescius.io/document-site-files/images/b298aea2-8cb8-4a0f-be88-4f54aa263ebd/images/export/additionalmetadata.png)

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](/activereportsnet/api/v20.1/MESCIUS.ActiveReports.Export.Pdf/GrapeCity.ActiveReports.Export.Pdf.Page.Settings.AdditionalMetadata.html) property. The allowed namespaces are:

* [Dublin Core Properties](https://www.dublincore.org/specifications/dublin-core/dcmi-terms/)
* [XMP Core Properties](https://helpx.adobe.com/in/audition/using/viewing-editing-xmp-metadata.html)
* [PDF Properties](https://helpx.adobe.com/acrobat/using/pdf-properties-metadata.html)

```vbnet
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)
```

```csharp
// 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](https://cdn.mescius.io/document-site-files/images/b298aea2-8cb8-4a0f-be88-4f54aa263ebd/images/export/attachmentinfo.png)

You can include an attachment as metadata (such as invoices) to exported PDFs using [Attachments](/activereportsnet/api/v20.1/MESCIUS.ActiveReports.Export.Pdf/GrapeCity.ActiveReports.Export.Pdf.Page.Settings.html) 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.

```vbnet
' 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)
```

```csharp
// 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.

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