PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Tue May 22, 2018 11:20 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Wed Jan 31, 2018 3:27 pm 
Offline

Joined: Wed Jan 31, 2018 3:19 pm
Posts: 4
Hi
Im trying to fill a acrobat document form field with a multiline text and hav no success.

Im using:
Code:
PdfTextField _f = (PdfTextField)(form.Fields[name]);
_f.MultiLine = true;         
_f.Text = value;

And
Code:
        PdfSharp.Pdf.AcroForms.PdfAcroField fieldLocation = form.Fields["address"];
        PdfSharp.Pdf.AcroForms.PdfTextField txtFieldLocation;
        if ((txtFieldLocation = fieldLocation as PdfSharp.Pdf.AcroForms.PdfTextField) != null)
        {
            txtFieldLocation.MultiLine = true;
            var sb = new System.Text.StringBuilder();
            sb.AppendLine("John Doe123");
            sb.AppendLine("Text from new line1");
            sb.AppendLine("Text from new line2");
            sb.AppendLine("Text from new line3");
            txtFieldLocation.Text = sb.ToString();
        }


And have tried all kind of linebreaks, stringbuilder with AddLine, html br \r \n \r\n
The source document has the field marked as multiline but i can only get the text on one line.

Any ideas?


Top
 Profile  
Reply with quote  
PostPosted: Thu Feb 01, 2018 8:13 am 
Offline

Joined: Wed Jan 31, 2018 3:19 pm
Posts: 4
Hi
I have now tried alla i can think of so this must be a bug.

I hav e a document with multiple form-fields.
One is a multiline box that i want to fill.

Sending in a text with newline is not shown as seperate lines in box, just one long line.
I have tired alla kind of newline i can think of , stringbuilder addline, enviroment.newline, \r \n \r\n \n\r ,vbcrlf

Im using 1.50.4740-beta5

And code:
Code:
PdfTextField _f = (PdfTextField)(form.Fields["olle"]);
_f.MultiLine = true;
_f.Value = new PdfString("firstline\nnextline");

and
Code:
PdfSharp.Pdf.AcroForms.PdfAcroField fieldLocation = form.Fields["olle"];
        PdfSharp.Pdf.AcroForms.PdfTextField txtFieldLocation;
        if ((txtFieldLocation = fieldLocation as PdfSharp.Pdf.AcroForms.PdfTextField) != null)
        {
            var sb = new System.Text.StringBuilder();
            sb.AppendLine("Text from new line1");
            sb.AppendLine("Text from new line2");
            txtFieldLocation.MultiLine = true;
            txtFieldLocation.Value = new PdfString(sb.ToString(), PdfStringEncoding.Unicode);
        }


Top
 Profile  
Reply with quote  
PostPosted: Thu Feb 01, 2018 10:05 am 
Offline
empira Employee
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 2813
Location: Cologne, Germany
Hi!
looc wrote:
I have a document with multiple form-fields.
One is a multiline box that i want to fill.
You have a document, I don't.
Please use the Issue Submission Template if you think there is a bug.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Thu Feb 01, 2018 5:40 pm 
Offline

Joined: Wed Jan 31, 2018 3:19 pm
Posts: 4
Ok, sorry about that.

I now got it to work, sort of...
The problem is firefox, i was testing in firefox built in pdf-reader and it seeams like it cant handle forms in pdf properly.
Running in Edge or chrome shows the line breaks.

//b.


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

All times are UTC


Who is online

Users browsing this forum: Baidu [Spider], Google [Bot] and 4 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:  
cron
Powered by phpBB® Forum Software © phpBB Group