Below is the code I am using to modify pdf metadata. The code works fine but I have one issue - instead of modifying the source file, it creates a new file in a different directory. My question is - is there a way to modify source document instead of creating a new document with necessary changes?
If File.Exists(strSource) Then
Dim pdfFileReader As New PdfReader(strSource)
psStamp = New PdfStamper(pdfFileReader, New FileStream(strDest, FileMode.Create))
Dim inf As New SortedDictionary(Of String, String)(StringComparer.Ordinal)
inf.Add("Title", "Modifying metadata")
inf.Add("Company", "My Company")
inf.Add("Author", "myself")
psStamp.MoreInfo = inf
psStamp.Close()
End If
I have tried modifying the line below:
psStamp = New PdfStamper(pdfFileReader, New FileStream(strDest, FileMode.Create))
to point to the source file but then I get an error because file is in use. Can anyone help?
I'd like to modify the current document without creating a new one. One way to do that would be create a new doc in a different directory, then delete the source doc and then save the newly created doc with the old doc's name but I wanted to see if there is a more elegant solution. Would appreciate any help