PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sat Jan 16, 2021 2:28 pm

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 

Joined: Wed Apr 18, 2018 7:17 pm
Posts: 6

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:

               PdfDictionary contentsDict = dictObj.Elements.GetValue("/Contents") as PdfDictionary;
               if (contentsDict == null || contentsDict.Stream == null)

               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?

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: Google [Bot] and 12 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