Set Document Information for a PDF

The code below shows you how to set Document Information for a PDF file.

It is recommended that you have already reviewed the Getting Started sample, since that includes Licensing and Framework initialization code required to make this sample run.

 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
using System; using SolidFramework.Pdf; namespace CSharp_Tutorials { public static partial class Tutorials { public static bool EditDocumentProperties(string pdfPath, string outputPath) { // Create a PdfDocument and open the PDF file using (var document = new PdfDocument(pdfPath)) { document.Open(); // Modify the document info var documentInfo = document.Info; documentInfo.Title = "Modified Properties"; documentInfo.Subject = "PDF Manipulation"; documentInfo.Creator = "SolidFramework Samples"; documentInfo.Producer = "SolidFramework " + SolidFramework.Platform.Platform.GetFullVersion(); Console.WriteLine("Editing document properties for " + outputPath); // Save the modified pdf document.SaveAs(outputPath, SolidFramework.Plumbing.OverwriteMode.ForceOverwrite); } Console.WriteLine("Successfully edited document properties for " + outputPath); Console.WriteLine(); return true; } } }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
Imports System Imports SolidFramework.Pdf Namespace VBNet_Tutorials Partial Module Tutorials Function EditDocumentProperties(ByVal pdfPath As String, ByVal outputPath As String) As Boolean ' Create a PdfDocument And open the PDF file Using document As PdfDocument = New PdfDocument(pdfPath) document.Open() ' Modify the document info Dim documentInfo As Info = document.Info documentInfo.Title = "Modified Properties" documentInfo.Subject = "PDF Manipulation" documentInfo.Creator = "SolidFramework Samples" documentInfo.Producer = "SolidFramework " & SolidFramework.Platform.Platform.GetFullVersion() Console.WriteLine("Editing document properties for " & outputPath) ' Save the modified pdf document.SaveAs(outputPath, SolidFramework.Plumbing.OverwriteMode.ForceOverwrite) End Using Console.WriteLine("Successfully edited document properties for " & outputPath) Console.WriteLine() Return True End Function End Module End Namespace
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
#include "Tutorials.h" using namespace SolidFramework::Pdf; bool EditDocumentProperties(const wstring & pdfPath, const wstring & outputPath) { // Create a PdfDocument and open the PDF file auto document = make_shared<PdfDocument>(pdfPath); document->Open(); // Modify the document info auto documentInfo = document->GetInfo(); documentInfo->SetTitle(L"Modified Properties"); documentInfo->SetSubject(L"PDF Manipulation"); documentInfo->SetCreator(L"SolidFramework Samples"); documentInfo->SetProducer(L"SolidFramework " + SolidFramework::Platform::Platform::GetFullVersion()); wcout << L"Editing document properties for " << outputPath << endl; // Save the modified pdf document->SaveAs(outputPath, SolidFramework::Plumbing::OverwriteMode::ForceOverwrite); wcout << L"Successfully edited document properties for " << outputPath << endl << endl; return true; }

Previous sample Samples Next sample