Hello,
I am trying to convert a Stream's value to a string, modify it, then assign the new string as the Stream's value, and save the Pdf.
I assumed it would be something like this:
Code:
PdfDictionary contentsDict = dictObj.Elements.GetValue("/Contents") as PdfDictionary;
if (contentsDict == null || contentsDict.Stream == null)
continue;
PdfString pdfString = new PdfString(contentsDict.Stream.ToString().Replace("141.12", "0"),PdfStringEncoding.StandardEncoding);
byte[] stringAsByteArray = //something like pdfString.ToByteArray, but that method does not exist
contentsDict.Stream.Value = stringAsByteArray;
but no ToByteArray method exists. The only reason I'm trying to use a PdfString here is because I could not find another way to use any of the PdfStringEncoding types.
How should I encode the modified string?
How do I assign it to the Stream I want to modify afterwards?