PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Mar 28, 2024 8:13 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: Tue Nov 12, 2013 6:58 am 
Offline

Joined: Tue Nov 12, 2013 6:31 am
Posts: 1
Hello,

I Want to Fill a pdf form. the pdf-document is from an external sources, so have no influence of the design.

I have extracted a PdfTextfield.
But Wenn I Set the Font and save the document it has no effect

wenn I step through the code after setting the Font to the PdfTextField it shows the right Values but in the generated document the text has a other Fontname/size.

What am I doing wrong?

(I've tried it with Version 1.3 pdfsharp and pdfsharp-wpf)

Code:

        PdfDocument document = PdfReader.Open(@"D:\Testzeugs\Test_doc.pdf", PdfDocumentOpenMode.Modify);

        PdfTextField currentField = (PdfTextField)(document.AcroForm.Fields["SOMEFIELD"]);

        //This section makes the text visible
        if (document.AcroForm.Elements.ContainsKey("/NeedAppearances"))
        {
          document.AcroForm.Elements["/NeedAppearances"] = new PdfBoolean(true);
        }
        else
        {
          document.AcroForm.Elements.Add("/NeedAppearances", new PdfBoolean(true));
        }

        //test
        string caseName = "Hallo Welt";
        PdfString caseNamePdfStr = new PdfString(caseName);
        currentField.Font = new XFont("Arial", 8);

        //set the value of this field
        currentField.Value = caseNamePdfStr;

        // Save the document...
        document.Save(@"D:\Testzeugs\test.pdf");


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