Remove Metadata from PDF in .NET SDK
Delete a metadata from a PDF document using Aspose.PDF Cloud .NET API
Get StartedHow to Delete Metadata in PDF Document using Cloud .NET SDK
In order to remove Metadata via Cloud .NET SDK , we’ll use
Aspose.PDF Cloud .NET SDK
This Cloud SDK allows you to easily build cloud-based PDF creator, editor & converter apps in C#, ASP.NET, or other .NET languages for various cloud platforms. Open
NuGet
package manager, search for
Aspose.PDF Cloud
and install. You may also use the following command from the Package Manager Console: PM> Install-Package Aspose.Pdf-Cloud
Steps to remove Metadata via .NET SDK
Aspose.PDF Cloud developers can easily load & delete Metadata in PDF in just a few lines of code.
- Create a new Configuration object with your Application Secret and Key
- Create an object to connect to the Cloud API
- Upload your document file
- Delete all properties using DeleteProperty
- Download the result if needed
This sample code shows removing Metadata in PDF documents
public static void DeleteMetadata()
{
const string localPdfFileName = @"C:\Samples\sample.pdf";
const string storageFileName = "sample.pdf";
const string localFolder = @"C:\Samples";
const string resultFileName = "output_del_metadata.pdf";
const string storageTempFolder = "YourTempFolder";
const string propertyName = "xmp:ArchiveDate";
// Get your AppSid and AppSecret https://dashboard.aspose.cloud (free registration required).
var pdfApi = new PdfApi(AppSecret, AppSid);
var filesOnStorage = pdfApi.GetFilesList(storageTempFolder);
if (filesOnStorage.Value.All(f => f.Name != storageFileName))
{
using var file = File.OpenRead(localPdfFileName);
var uploadResult = pdfApi.UploadFile(Path.Combine(storageTempFolder, storageFileName), file);
Console.WriteLine(uploadResult.Uploaded[0]);
}
var response = pdfApi.GetDocumentProperty(storageFileName, propertyName, folder: storageTempFolder);
if (response.DocumentProperty.Value != null && !response.DocumentProperty.Value.StartsWith("Aspose"))
{
var responseSet = pdfApi.DeleteProperty(storageFileName, propertyName, folder: storageTempFolder);
Console.WriteLine(responseSet.Status);
using Stream downloadStream = pdfApi.DownloadFile(Path.Combine(storageTempFolder, storageFileName));
using FileStream localStream = File.Create(Path.Combine(localFolder, resultFileName));
downloadStream.CopyTo(localStream);
Console.WriteLine("DeleteMetadata(): new property successfully added to document '{0}' file.", resultFileName);
}
}
- Learning Resources
- Documentation
- Source Code
- API References
- Product Support
- Free Support
- Paid Support
- Blog
- Why Aspose.PDF Cloud for .NET?
- Customers List
- Security