PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Tue Mar 19, 2024 6:39 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Fri Apr 20, 2018 6:33 pm 
Offline

Joined: Wed Apr 18, 2018 7:17 pm
Posts: 6
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?


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 46 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group