PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Mon Oct 26, 2020 8:52 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Tue Dec 20, 2016 7:19 am 
Offline

Joined: Tue Dec 06, 2016 8:37 am
Posts: 1
I am trying to edit the a PDF But This has China as default value and when I try to set the selected index and save the file China is shown as value,
Also for a file if it doesn't have any default value it always shows empty value.
Below is my code


PdfDocument pd = PdfReader.Open(sourceFilePath, PdfDocumentOpenMode.Modify);

var pdfFields = pd.AcroForm.Fields;

((PdfComboBoxField)pdfFields[i]).SelectedIndex = 0;
//i is index generated when we iterate pdfFields.

Can anyone please try to edit some PDF using PDF sharp in Code and let me know what am I dping wrong.
I have generated editable PDF from http://www.pdfescape.com


Top
 Profile  
Reply with quote  
PostPosted: Tue Oct 13, 2020 5:00 pm 
Offline

Joined: Tue Oct 13, 2020 4:55 pm
Posts: 1
Had the same issue, this ultimately worked for me:

Code:
var comboBox = field as PdfComboBoxField;
PdfArray indexElement = (PdfArray)comboBox.Elements["/I"];
indexElement.Elements[0] = new PdfInteger(4);
comboBox.Value = new PdfString("Five");


This will set the value properly for display in Acrobat itself. For some reason, just setting Value normally would work but only in less exacting viewers like Chrome or Edge.


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 26 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