Beispiel #1
0
        /**
         * Closes the AcroForm.
         */

        public bool IsValid()
        {
            if (documentFields.Size == 0)
            {
                return(false);
            }
            Put(PdfName.FIELDS, documentFields);
            if (sigFlags != 0)
            {
                Put(PdfName.SIGFLAGS, new PdfNumber(sigFlags));
            }
            if (calculationOrder.Size > 0)
            {
                Put(PdfName.CO, calculationOrder);
            }
            if (fieldTemplates.Count == 0)
            {
                return(true);
            }
            PdfDictionary dic = new PdfDictionary();

            foreach (PdfTemplate template in fieldTemplates.Keys)
            {
                PdfFormField.MergeResources(dic, (PdfDictionary)template.Resources);
            }
            Put(PdfName.DR, dic);
            Put(PdfName.DA, new PdfString("/Helv 0 Tf 0 g "));
            PdfDictionary fonts = (PdfDictionary)dic.Get(PdfName.FONT);

            if (fonts != null)
            {
                writer.EliminateFontSubset(fonts);
            }
            return(true);
        }
Beispiel #2
0
        private void AddFieldResources(PdfDictionary catalog)
        {
            if (fieldArray == null)
            {
                return;
            }
            PdfDictionary acroForm = new PdfDictionary();

            catalog.Put(PdfName.ACROFORM, acroForm);
            acroForm.Put(PdfName.FIELDS, fieldArray);
            acroForm.Put(PdfName.DA, new PdfString("/Helv 0 Tf 0 g "));
            if (fieldTemplates.Count == 0)
            {
                return;
            }
            PdfDictionary dr = new PdfDictionary();

            acroForm.Put(PdfName.DR, dr);
            foreach (PdfTemplate template in fieldTemplates.Keys)
            {
                PdfFormField.MergeResources(dr, (PdfDictionary)template.Resources);
            }
            PdfDictionary fonts = dr.GetAsDict(PdfName.FONT);

            if (fonts == null)
            {
                fonts = new PdfDictionary();
                dr.Put(PdfName.FONT, fonts);
            }
            if (!fonts.Contains(PdfName.HELV))
            {
                PdfDictionary dic = new PdfDictionary(PdfName.FONT);
                dic.Put(PdfName.BASEFONT, PdfName.HELVETICA);
                dic.Put(PdfName.ENCODING, PdfName.WIN_ANSI_ENCODING);
                dic.Put(PdfName.NAME, PdfName.HELV);
                dic.Put(PdfName.SUBTYPE, PdfName.TYPE1);
                fonts.Put(PdfName.HELV, AddToBody(dic).IndirectReference);
            }
            if (!fonts.Contains(PdfName.ZADB))
            {
                PdfDictionary dic = new PdfDictionary(PdfName.FONT);
                dic.Put(PdfName.BASEFONT, PdfName.ZAPFDINGBATS);
                dic.Put(PdfName.NAME, PdfName.ZADB);
                dic.Put(PdfName.SUBTYPE, PdfName.TYPE1);
                fonts.Put(PdfName.ZADB, AddToBody(dic).IndirectReference);
            }
        }
Beispiel #3
0
 internal void CreateWidgets(ArrayList list, AcroFields.Item item)
 {
     for (int k = 0; k < item.Size; ++k)
     {
         list.Add(item.GetPage(k));
         PdfDictionary merged = item.GetMerged(k);
         PdfObject     dr     = merged.Get(PdfName.DR);
         if (dr != null)
         {
             PdfFormField.MergeResources(resources, (PdfDictionary)PdfReader.GetPdfObject(dr));
         }
         PdfDictionary widget = new PdfDictionary();
         foreach (PdfName key in merged.Keys)
         {
             if (widgetKeys.ContainsKey(key))
             {
                 widget.Put(key, merged.Get(key));
             }
         }
         widget.Put(iTextTag, new PdfNumber(item.GetTabOrder(k) + 1));
         list.Add(widget);
     }
 }