How To Add/Edit Matadata in PDF File using PDF Mosaic .NET Library

This sample shows how to change metadata of a PDF document (properties such as "Author", "Title") using PDFDocumentInformation class. To access metadata of a PDF document, use PDFDocument.DocumentInfo property.

 

using PDFMosaic;
using System;

namespace DocumentInfo
{
    class DocumentInfo
    {
        static void Main()
        {
            PDFDocument document = new PDFDocument();

            document.DocumentInfo.Subject = "Document Info";
            document.DocumentInfo.Title = "Custom title";
            document.DocumentInfo.Keywords = "pdf, PDFMosaic";
            document.DocumentInfo.Author = "PDF Mosaic";

            PDFPage page = new PDFPage(PDFPaperFormat.A4);
            PDFFont font = new PDFFont(PDFStandardFont.Helvetica, 16);
            PDFBrush brush = new PDFSolidBrush();
            page.Canvas.DrawString("Check document properties", font, brush, 100, 100);

            document.Pages.Add(page);

            document.Save("DocumentInfo.pdf", true);
        }
    }
}