We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to change PDF Metadata

I need to change the generated PDF meta data after stamping it

this is the code

string dataDir = @“D:\folder”;

// Open document
string filename = “file”;
Document pdfDocument = new Document(dataDir + filename + “.pdf”);

// Create text stamp
TextStamp textStamp = new TextStamp(“Test Text”);
// Set whether stamp is background
textStamp.Background = true;
// Set origin
textStamp.XIndent = 40;
textStamp.YIndent = 150;
// Rotate stamp
textStamp.RotateAngle = 45;
// Set text properties
textStamp.TextState.Font = FontRepository.FindFont(“MyriadPro-Bold”);
textStamp.TextState.FontSize = 130;
textStamp.TextState.ForegroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray);
// iterate through all pages of PDF file
for (int Page_counter = 1; Page_counter < pdfDocument.Pages.Count; Page_counter++)
{
//add stamp to all pages of PDF file
pdfDocument.Pages[Page_counter].AddStamp(textStamp);
}
string data = pdfDocument.Info.Creator;
Console.WriteLine(data);
dataDir = dataDir + “out.pdf”;
// Save output document
pdfDocument.Save(dataDir);

Hi Mohamed,


Thanks for using our API’s.

As per my understanding, you want to change meta data for the generated output file. Please see below sample code for this.

C#
// Open document
string filename = “Blank”;
Document pdfDocument = new Document(dataDir + filename + “.pdf”);
// Create text stamp
TextStamp textStamp = new TextStamp(“Test Text”);
// Set whether stamp is background
textStamp.Background = true;
// Set origin
textStamp.XIndent = 40;
textStamp.YIndent = 150;
// Rotate stamp
textStamp.RotateAngle = 45;
// Set text properties
textStamp.TextState.Font = FontRepository.FindFont(“Arial”);
textStamp.TextState.FontSize = 130;
textStamp.TextState.ForegroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray);
// iterate through all pages of PDF file
for (int Page_counter = 1; Page_counter < pdfDocument.Pages.Count; Page_counter++)
{
//add stamp to all pages of PDF file
pdfDocument.Pages[Page_counter].AddStamp(textStamp);
}

pdfDocument.Info.Author = “Aspose”;
pdfDocument.Info.CreationDate = DateTime.Now;
pdfDocument.Info.Keywords = “Aspose.Pdf, DOM, API”;
pdfDocument.Info.ModDate = DateTime.Now;
pdfDocument.Info.Subject = “PDF Info”;


string data = pdfDocument.Info.Creator;
Console.WriteLine(data);
dataDir = dataDir + “out.pdf”;
// Save output document
pdfDocument.Save(dataDir);

Moreover, Please note that Creator field is marked as Read Only in Aspose.Pdf for .NET and you cannot modify it. If you still face any issue, please feel free to contact us.

Best Regards,