Exemplo n.º 1
0
        public static PdfFont AddFont(PdfBody body, string pdfFontID, WW.Pdf.Font.Font font)
        {
            PdfFont pdfFont;

            if (font is Class14)
            {
                Class14 base14 = (Class14)font;
                pdfFont = (PdfFont)PdfFontCreator.smethod_1(pdfFontID, base14);
            }
            else
            {
                IFontMetric fontMetric = PdfFontCreator.smethod_3(font);
                if (fontMetric is Class14)
                {
                    Class14 base14 = (Class14)fontMetric;
                    pdfFont = (PdfFont)PdfFontCreator.smethod_1(pdfFontID, base14);
                }
                else if (fontMetric is ns7.Class33)
                {
                    ns7.Class33 ttf = (ns7.Class33)fontMetric;
                    pdfFont = (PdfFont)PdfFontCreator.smethod_2(body, pdfFontID, font, ttf);
                }
                else
                {
                    ns0.Class30 cidFont = (ns0.Class30)fontMetric;
                    pdfFont = PdfFontCreator.smethod_0(body, pdfFontID, font, cidFont);
                }
            }
            if (pdfFont == null)
            {
                throw new Exception("Unable to create Pdf font object for " + pdfFontID);
            }
            body.Fonts.Add(pdfFont);
            return(pdfFont);
        }
Exemplo n.º 2
0
        private static PdfFont smethod_0(
            PdfBody body,
            string pdfFontID,
            WW.Pdf.Font.Font font,
            ns0.Class30 cidFont)
        {
            PdfIndirectObject <PdfFontFile> pdfIndirectObject1 = new PdfIndirectObject <PdfFontFile>(new PdfFontFile(font.Descriptor.FontData));
            Class40 class40 = PdfFontCreator.smethod_4(pdfFontID, (IFontMetric)cidFont);
            PdfIndirectObject <Class40> pdfIndirectObject2 = new PdfIndirectObject <Class40>(class40);

            class40.FontFile2 = pdfIndirectObject1;
            Class39 class39 = new Class39(cidFont.Registry, cidFont.Ordering, cidFont.Supplement);
            Class35 class35 = new Class35(PdfFontSubTypeEnum.CIDFontType2, font.FontName);

            class35.SystemInfo   = class39;
            class35.Descriptor   = pdfIndirectObject2;
            class35.DefaultWidth = cidFont.DefaultWidth;
            class35.Widths       = cidFont.WArray;
            PdfCMap pdfCmap = new PdfCMap();

            pdfCmap.AddFilter((IFilter) new FlateFilter());
            pdfCmap.SystemInfo = class39;
            pdfCmap.AddBfRanges(cidFont.CMapEntries);
            PdfIndirectObject <PdfCMap> pdfIndirectObject3 = new PdfIndirectObject <PdfCMap>(pdfCmap);
            Class36 class36 = new Class36(pdfFontID, font.FontName);

            class36.Encoding   = cidFont.Encoding;
            class36.Descendant = class35;
            class36.ToUnicode  = pdfIndirectObject3;
            body.IndirectObjects.Add((IPdfIndirectObject)pdfIndirectObject2);
            body.IndirectObjects.Add((IPdfIndirectObject)class35);
            body.IndirectObjects.Add((IPdfIndirectObject)pdfIndirectObject3);
            body.IndirectObjects.Add((IPdfIndirectObject)pdfIndirectObject1);
            return((PdfFont)class36);
        }
Exemplo n.º 3
0
        internal void method_2(PdfBody body)
        {
            IDictionary <string, IFontMetric> nameToFontMetric = this.pdfFontInfo_0.UsedNameToFontMetric;

            foreach (string key in (IEnumerable <string>)nameToFontMetric.Keys)
            {
                WW.Pdf.Font.Font font    = (WW.Pdf.Font.Font)nameToFontMetric[key];
                PdfFont          pdfFont = PdfFontCreator.AddFont(body, key, font);
                foreach (PdfReference kid in (ActiveList <IPdfObject>)body.Pages.Kids)
                {
                    PdfPage       referencedObject = (PdfPage)kid.ReferencedObject;
                    IPdfObject    pdfObject;
                    PdfDictionary pdfDictionary;
                    if (referencedObject.Resources.TryGetValue("Font", out pdfObject))
                    {
                        pdfDictionary = (PdfDictionary)pdfObject;
                    }
                    else
                    {
                        pdfDictionary = new PdfDictionary();
                        referencedObject.Resources.Add("Font", (IPdfObject)pdfDictionary);
                    }
                    if (!pdfDictionary.ContainsKey(key))
                    {
                        pdfDictionary.Add(key, (IPdfObject) new PdfReference((IPdfIndirectObject)pdfFont));
                    }
                }
            }
        }
Exemplo n.º 4
0
        private static Class38 smethod_2(
            PdfBody body,
            string pdfFontID,
            WW.Pdf.Font.Font font,
            ns7.Class33 ttf)
        {
            PdfIndirectObject <Class40> pdfIndirectObject = new PdfIndirectObject <Class40>(PdfFontCreator.smethod_4(pdfFontID, (IFontMetric)ttf));
            Class38 class38 = new Class38(pdfFontID, font.FontName);

            class38.Encoding   = "WinAnsiEncoding";
            class38.Descriptor = pdfIndirectObject;
            class38.FirstChar  = ttf.FirstChar;
            class38.LastChar   = ttf.LastChar;
            class38.Widths     = ttf.Array;
            body.IndirectObjects.Add((IPdfIndirectObject)pdfIndirectObject);
            return(class38);
        }