Document Solutions for Excel, .NET Edition | Document Solutions
File Operations / Export to PDF / Support Document Properties
In This Topic
    Support Document Properties
    In This Topic

    DsExcel provides support for document properties while saving Excel spreadsheets to PDF documents. The document properties contain the basic information about a document, such as title, author, creation date, subject, creator, version etc. You can store such useful information in the exported PDF document. 

    The DocumentProperties class contains the properties such as PdfVersion, EmbedStandardWindowsFonts, Title, Author, Subject, Keywords, Creator, Producer, CreationDate and ModifyDate.

    Using Code

    Refer to the following example code to add document properties in a PDF document.

    C#
    Copy Code
    //create a pdf file stream
    FileStream outputStream = new FileStream("setdocumentpropertiestopdf.pdf", FileMode.Create);
    
    //create a new workbook
    var workbook = new GrapeCity.Documents.Excel.Workbook();
    
    IWorksheet worksheet = workbook.Worksheets[0];
    worksheet.Range["A1"].Value = "Documents for Excel";
    worksheet.Range["A1"].Font.Size = 25;
    
    DocumentProperties documentProperties = new DocumentProperties
    {
        //Sets the name of the person that created the PDF document.
        Author = "Jaime Smith",
        //Sets the title of the  PDF document.
        Title = "GcPdf Document Info Sample",
        //Do not embed a font.
        EmbedStandardWindowsFonts = false,
        //Set the PDF version.
        PdfVersion = 1.5f,
        //Set the subject of the PDF document.
        Subject = "GcPdfDocument.DocumentInfo",
        //Set the keyword associated with the PDF document.
        Keywords = "Keyword1",
        //Set the creation date and time of the PDF document.
        CreationDate = DateTime.Now.AddYears(10),
        //Set the date and time the PDF document was most recently modified.
        ModifyDate = DateTime.Now.AddYears(11),
        //Set the name of the application that created the original PDF document.
        Creator = "GcPdfWeb Creator",
        //Set the name of the application that created the PDF document.
        Producer = "GcPdfWeb Producer"
    };
    
    PdfSaveOptions pdfSaveOptions = new PdfSaveOptions
    {
        //Sets the document properties of the pdf.
        DocumentProperties = documentProperties
    };
    
    //Save the workbook into pdf file.
    workbook.Save(outputStream, pdfSaveOptions);
            
    //close the pdf stream
    outputStream.Close();