Create PDF Form

Help
Dusko
2012-11-08
2013-01-26
  • Dusko
    Dusko
    2012-11-08

    Hi,

    I am trying to create PDF Form according your example. But using existing PDF document. Here is the sample code:

    File pdfFile = new File(currentDir + "\\" + "test.pdf");
                Document document = pdfFile.Document;
                Populate(document);
    ….

            public void Populate(Document document)
            {
                // 1. Define the form fields collection!
                Form form = new Form(document);
                document.Form = form;
                Fields fields = form.Fields;

                // 2. Define the page where to place the fields!
                Page page = new Page(document);
                document.Pages.Add(page);

                // 3. Define the appearance style to apply to the fields!
                DefaultStyle fieldStyle = new DefaultStyle();
                fieldStyle.FontSize = 12;
                fieldStyle.GraphicsVisibile = true;

                PrimitiveComposer composer = new PrimitiveComposer(page);
                StandardType1Font sf = new StandardType1Font(document, StandardType1Font.FamilyEnum.Helvetica, true, false);
                composer.SetFont(sf, 14);

    }

    I get an error on composer.SetFont(sf, 14);  in PrimitiveComposer.cs in GetFontName.

    Something about NullReference exception in scanner.ContentContext.Resources;

    Can you please tell me what could be the problem, I will provide more details if needed. Is it possible to generate Form from existing pdf document.

    BR.

     
  • Hi,

    apparently the resources dictionary was not defined; you should open a bug report  and attach as much information as possible (the full stack trace, for example) so I can reproduce your issuee.

    thank you!
    Stefano

    http://sourceforge.net/tracker/?group_id=176158&atid=876123