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

Free Support Forum - aspose.com

Cannot write to Keywords section in PDF Document Properties

I cannot seem to write any properties to the Keywords section of a pdf Document Properties using any aspose pdf library after version 18.8.

Sample code to save Keywords:

using (var pdfDocument = new Document(stream))
{
pdfDocument.Info.Keywords = “Sample Keyword”;
pdfDocument.Save(stream);
}

@TATitus

Thanks for your inquiry.

We have tested the scenario using Aspose.PDF for .NET 19.1 and were unable to notice any issue. Would you please try using latest version of the API and in case you still face any issue, please share our input PDF document with us. We will test the scenario in our environment and address it accordingly.

0.AcroX.pdf (77.0 KB)

@TATitus

Thanks for sharing sample PDF document.

We have tested the scenario in our environment using your document with Aspose.PDF for .NET 19.1 and were still unable to notice any issue. For you kind reference, a resultant PDF is also attached.

editkeyword.pdf (74.7 KB)

Would you please make sure if you are using latest version of the API. In case issue still persists, please share a sample console application which is able to reproduce the issue. We will again test the scenario in our environment and address it accordingly.

I am using the latest version of Aspose.PDF for .NET 19.1.

I can still reproduce the issue. Here is some sample code:

using System;
using System.IO;
using Aspose.Pdf;

namespace AsposePDFsample
{
public class Program
{

	public static Stream CreateStream(string path, FileAccess fileAccess)
	{
		return new FileStream(path, FileMode.Open, fileAccess, fileAccess == FileAccess.Read ? FileShare.ReadWrite : FileShare.None);
	}
	
	public static void Main(string[] args)
	{
		Console.WriteLine("Please enter the path of the PDF document!");
		string path = Console.ReadLine();


		using (var stream = CreateStream(path, FileAccess.ReadWrite))
		{
			using (var pdfDocument = new Document(stream))
			{
				pdfDocument.Info.Keywords = "Sample Keyword";
				pdfDocument.Save(stream);
			}
		}
		
		Console.ReadKey();
	}
}

}

@TATitus

Thanks for writing back.

The issue is occurring due to usage of same stream object for both loading and saving the document. In case you need to save document using Streams, please try using following code snippet which creates correct output:

using (var stream = CreateStream(dataDir + "0.AcroX.pdf", FileAccess.ReadWrite))
{
 using (var fstream = new FileStream(dataDir + "outputuptu.pdf", FileMode.Create))
 {
  using (var pdfDocument = new Document(stream))
  {
   pdfDocument.Info.Keywords = "Sample Keyword";
   pdfDocument.Save(fstream);
  }
 }
} 

outputuptu.pdf (76.5 KB)

Thank you for your response.

Shouldn’t I be able to load a pdf document and update it in the same using statement?
I’m not trying to create a new pdf document.

@TATitus

Thanks for writing back.

In that case you can use Document.Save() method without any argument to save PDF. We have tested the scenario using this method and noticed that PDF document was not getting updated. Therefore, we have logged an issue as PDFNET-45965 in our issue tracking system for correction. We will further look into details of the issue and keep you posted with the status of its correction. Please be patient and spare us little time.

We are sorry for the inconvenience.

Many thanks!

Hello!

Just wanted to check and get a status on PDFNET-45965 for the PDF keywords issue.
Any ETA?

Thanks!

@TATitus

Thanks for your inquiry.

We regret to share that earlier logged ticket is not yet resolved due to other high priority issues in the queue. However, we have recorded your concerns and will definitely consider them during investigation of the issue. As soon as some significant updates are available, we will share with you. Please spare us little time.

We are sorry for the inconvenience.