Example #1
0
        public void AddText(string text, int x, int y, Font font, int fontSize, Color color)
        {
            Type1Font    t1  = font as Type1Font;
            TrueTypeFont ttf = font as TrueTypeFont;

            if (t1 != null)
            {
                AddText(text, x, y, t1, fontSize, color);
            }
            else if (ttf != null)
            {
                AddText(text, x, y, ttf, fontSize, color);
            }
        }
Example #2
0
        private void WriteFonts(Stream stream)
        {
            foreach (Font font in _fonts.Fonts)
            {
                //	Write the True Type or Type 1 font
                font.Write(stream, this);

                //	If it's a True Type font then write its CID and Type0 fonts
                TrueTypeFont ttf = font as TrueTypeFont;
                if (ttf != null)
                {
                    ttf.RootFont.Write(stream, this);
                }
            }
        }
Example #3
0
        private void WriteResources(Stream file, Document doc)
        {
            Document.WriteData(file, "/Resources\r\n<<\r\n");
            _procSet.Write(file);

            //	Font references. The fonts themselves are written directly by the generator.
            if (_fonts.Fonts.Count > 0)
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("/Font <<");
                foreach (Font font in _fonts.Fonts)
                {
                    FontReference fontref = new FontReference(doc.GetReference(font));
                    sb.Append(fontref.AliasReference);
                    sb.Append(" ");

                    TrueTypeFont ttf = font as TrueTypeFont;
                    if (ttf != null)
                    {
                        fontref = new FontReference(doc.GetReference(ttf.RootFont));
                        sb.Append(fontref.AliasReference);
                        sb.Append(" ");
                    }
                }
                sb.Append(">>\r\n");
                Document.WriteData(file, sb.ToString());
            }

            //	Image references. The images themselves are written elsewhere.
            if (_images.Count > 0)
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("/XObject << ");
                foreach (Image img in _images)
                {
                    ObjectReference imgRef = doc.GetReference(img);
                    sb.Append("/");
                    sb.Append(img.Name);
                    sb.Append(" ");
                    sb.Append(imgRef.Reference);
                    sb.Append(" ");
                }
                sb.Append(">>\r\n");
                Document.WriteData(file, sb.ToString());
            }

            Document.WriteData(file, ">>\r\n");
        }
Example #4
0
        public void AliasFonts()
        {
            //	Alias the PDF fonts and add them to the PDF font cache
            int nextAlias = 1;

            foreach (Demon.PDF.Font font in _pdfFonts)
            {
                font.Alias = "F" + nextAlias++;

                //	If it's a True Type font then add the Type 0 font wrapper. When we
                //	write the page we'll add both fonts as page resources.
                TrueTypeFont ttf = font as TrueTypeFont;
                if (ttf != null)
                {
                    ttf.RootFont.Alias = "F" + nextAlias++;
                }
            }
        }
Example #5
0
        public void AddText(
            string text, int x, int y,
            string fontFamily, bool bold, bool italic, int fontSize,
            Color color)
        {
            Font         font = _fonts.GetFont(fontFamily, bold, italic);
            Type1Font    t1   = font as Type1Font;
            TrueTypeFont ttf  = font as TrueTypeFont;

            if (t1 != null)
            {
                AddText(text, x, y, t1, fontSize, color);
            }
            else if (ttf != null)
            {
                AddText(text, x, y, ttf, fontSize, color);
            }
        }
Example #6
0
 public Type0Font(TrueTypeFont descendant)
 {
     _descendant = descendant;
     _cidFont    = new CIDFont(_descendant);
 }
Example #7
0
 public CIDFont(TrueTypeFont realfont)
 {
     _realFont = realfont;
 }
Example #8
0
        private void AddText(string text, int x, int y, TrueTypeFont font, int fontSize, Color color)
        {
            Text t = new Text(text, x, y, font.RootFont, fontSize, color);

            _content.Add(t);
        }