This sample project uses the PdfDocument.CustomProperties property to obtain the collection of document's custom properties. You can add and delete custom properties or change associated names or values.
[!Important]
The Universal Subscription or an additional Office File API Subscription is required to use this example in production code. For pricing information, please refer to the DevExpress Subscription page.
Files to Review
C# | Visual Basic |
---|---|
Program.cs | Program.vb |
Does this example address your development requirements/objectives?
(you will be redirected to DevExpress.com to submit your response)
Example Code
C#using DevExpress.Pdf;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace pdf_custom_properties
{
class Program
{
static void Main(string[] args)
{
using (PdfDocumentProcessor pdfProcessor = new PdfDocumentProcessor())
{
pdfProcessor.LoadDocument("PageDeletion.pdf");
ModifyCustomProperties(pdfProcessor.Document);
pdfProcessor.SaveDocument("Result.pdf");
Process.Start(new ProcessStartInfo("Result.pdf") { UseShellExecute = true });
}
}
private static void ModifyCustomProperties(PdfDocument document)
{
//Add new property
document.CustomProperties.Add("NumberOfCopies", "3");
//Modify the CompanyEmail property value:
if (document.CustomProperties.ContainsKey("CompanyEmail"))
document.CustomProperties["CompanyEmail"] = "clientservices@devexpress.com";
//Remove the HasImages property:
document.CustomProperties.Remove("HasImages");
}
}
}