コード例 #1
0
ファイル: test.aspx.cs プロジェクト: NGB97/ChuMuoi
    protected void Button1_Click(object sender, EventArgs e)
    {
        System.IO.StringWriter stringWrite = new System.IO.StringWriter();
        string fileName = " EmployeeTranferReport.pdf";

        Response.AppendHeader("Content-Type", "application/pdf");
        Response.AppendHeader("Content-disposition", "attachment; filename=" + fileName);
        Response.Cache.SetCacheability(HttpCacheability.NoCache);

        stringWrite.WriteLine("<html><body encoding=" + BaseFont.IDENTITY_H + " style='font-family:Arial Unicode MS;font-size:12;'> <table style='width:100%'><tr><td align='center'><b>Vãi nồi</b></td></tr><tr><td align='center'>अगरतला</td></tr></table> </body></html>");

        HtmlTextWriter hw         = new HtmlTextWriter(stringWrite);
        StringReader   sr         = new StringReader(stringWrite.ToString());
        Document       pdfDoc     = new Document(PageSize.A4, 20f, 10f, 10f, 0f);
        HTMLWorker     htmlparser = new HTMLWorker(pdfDoc);
        PdfWriter      wi         = PdfWriter.GetInstance(pdfDoc, Response.OutputStream);

        pdfDoc.Open();

        string fontpath = Environment.GetFolderPath(Environment.SpecialFolder.Fonts) + "\\ARIALUNI.TTF";        //  "ARIALUNI.TTF" file copied from fonts folder and placed in the folder

        BaseFont bf = BaseFont.CreateFont(fontpath, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);

        FontFactory.RegisterDirectory(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), true);
        FontFactory.Register(fontpath, "Arial Unicode MS");
        //FontFactory.RegisterFamily("Arial Unicode MS", "Arial Unicode MS", fontpath);
        htmlparser.Parse(sr);
        pdfDoc.Close();
        Response.Write(pdfDoc);
        Response.End();
    }
コード例 #2
0
        public string Html2PDF(string html, string PathTarget, string fontPath)
        {
            try
            {
                if (String.IsNullOrEmpty(fontPath))
                {
                    fontPath = "c:/windows/fonts/ARIALUNI.TTF";
                }

                FontFactory.Register(fontPath);
                StyleSheet style = new StyleSheet();
                style.LoadTagStyle("body", "face", "Arial Unicode MS");
                style.LoadTagStyle("body", "encoding", BaseFont.IDENTITY_H);
                Document document = new Document();
                Stream   file     = new System.IO.FileStream(PathTarget, System.IO.FileMode.Create);
                PdfWriter.GetInstance(document, file);
                document.Open();
                List <IElement> elements = HTMLWorker.ParseToList(new StringReader(html), style);
                foreach (IElement el in elements)
                {
                    document.Add(el);
                }
                document.Close();
                file.Close();
                return("");
            }
            catch (Exception e)
            {
                return(e.Message);
            }
        }
コード例 #3
0
ファイル: PdfRenderer.cs プロジェクト: trailmax/Homoiconicity
        public override MemoryStream CreateDocument(IEnumerable <IResumeSection> resumeSections, ResumeData data)
        {
            byte[] resultBytes;

            FontFactory.RegisterDirectories();

            var fontPath = mapperPathMapper.MapPath(InconsolataTtf);

            FontFactory.Register(fontPath, PdfConverter.Verdana);

            var pdfOutputStream = new MemoryStream();

            document = new Document(PageSize.A4);
            document.SetMargins(20, 20, 20, 20);



            PdfWriter.GetInstance(document, pdfOutputStream);

            document.AddTitle(data.DocumentTitle);
            document.Open();

            base.RenderElements(resumeSections, data);

            document.Close();
            resultBytes = pdfOutputStream.ToArray();
            pdfOutputStream.Close();
            pdfOutputStream.Dispose();
            return(new MemoryStream(resultBytes));
        }
コード例 #4
0
        private Document MakeReportHeader(string filename, string title)
        {
            int    highlightSize = 15;
            int    textSize      = 12;
            string arialuniTff   = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "ARIALUNI.TTF");

            FontFactory.Register(arialuniTff);
            BaseFont baseFont = BaseFont.CreateFont(arialuniTff, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);

            highlightFont = new Font(baseFont, highlightSize, iTextSharp.text.Font.BOLD, BaseColor.BLACK);
            textFont      = new Font(baseFont, textSize, iTextSharp.text.Font.NORMAL, BaseColor.BLACK);

            Document document = new Document();

            PdfWriter.GetInstance(document, new FileStream(filename, FileMode.Create));
            document.Open();

            Paragraph par = new Paragraph();

            par.Add(new Chunk(title + "\n\n", highlightFont));
            par.Alignment = Element.ALIGN_CENTER;
            document.Add(par);

            return(document);
        }
コード例 #5
0
        private void Init(PDFOptions Options)
        {
            this.Options = Options;

            FontFactory.Register(@"RaviPrakash.ttf");
            FontFactory.Register(@"Ponnala.ttf");
            FontFactory.Register(@"RamaneeyaWin.ttf");
            FontFactory.Register("seguisym.ttf");

            //BaseFont bf = BaseFont.CreateFont ( BaseFont.SYMBOL , BaseFont.CP1252 , BaseFont.EMBEDDED);

            ST = new StyleSheet();

            ST.LoadTagStyle(HtmlTags.BODY, HtmlTags.FACE, "RamaneeyaWin");
            ST.LoadTagStyle(HtmlTags.BODY, HtmlTags.ENCODING, BaseFont.IDENTITY_H);

            ST.LoadTagStyle(HtmlTags.H1, HtmlTags.FACE, "RaviPrakash");
            ST.LoadTagStyle(HtmlTags.H2, HtmlTags.FACE, "Ponnala");
            ST.LoadTagStyle(HtmlTags.TH, HtmlTags.FACE, "RaviPrakash");

            ST.LoadStyle("symbol", HtmlTags.FACE, "Segoe UI Symbol");

            ST.LoadTagStyle(HtmlTags.TH, HtmlTags.BGCOLOR, "#EEEEEE");
            ST.LoadStyle("th", HtmlTags.BGCOLOR, "#EEEEEE");
        }
コード例 #6
0
 /// <summary>
 /// Displaying the current cell's data as a Wingdings symbol.
 /// </summary>
 public WingdingsSymbolField()
 {
     if (!FontFactory.IsRegistered(WingdingsFontPath))
     {
         FontFactory.Register(WingdingsFontPath);
     }
 }
コード例 #7
0
        public void PaintText(string textColor, string fontPath, float fontSize, float textLeading, float textSpacing, string textContent, float textX, float textY, bool isH)
        {
            CMYK_Color cmyk_titleColor = new CMYK_Color().GetCMYK_Color(textColor);

            FontFactory.Register(fontPath);
            BaseFont bfChinese = BaseFont.CreateFont(fontPath, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);

            PdfContentByte contentByte = pdfWriter.DirectContent;

            contentByte.BeginText();
            contentByte.SetCMYKColorFill(cmyk_titleColor.C, cmyk_titleColor.M, cmyk_titleColor.Y, cmyk_titleColor.K);
            contentByte.SetCMYKColorStroke(cmyk_titleColor.C, cmyk_titleColor.M, cmyk_titleColor.Y, cmyk_titleColor.K);
            contentByte.SetFontAndSize(bfChinese, fontSize);
            contentByte.SetLeading(textLeading);
            contentByte.SetCharacterSpacing(textSpacing);
            //contentByte.SetTextMatrix(textX, textY);
            string p1 = "^[]】}》>))』@[{}【{《<((『‖︱ ︳♀♂]$";

            for (int i = 0; i < textContent.Length; i++)
            {
                contentByte.SetTextMatrix(textX, textY - (10f * i));
                if (Regex.IsMatch(textContent[i].ToString(), p1))
                {
                    contentByte.ShowTextAligned(Element.ALIGN_CENTER, textContent[i].ToString(), textX + 1f, textY - (10f * i), -90);
                }
                else
                {
                    contentByte.ShowText(textContent[i].ToString());
                }

                contentByte.NewlineText();
            }
            contentByte.Stroke();
            contentByte.EndText();
        }
コード例 #8
0
ファイル: PaintTools.cs プロジェクト: jeryhu/bk
        /// <summary>
        /// 计算单行文本的宽度
        /// </summary>
        /// <param name="content"></param>
        /// <param name="fontFilePath"></param>
        /// <param name="space"></param>
        /// <param name="pt"></param>
        /// <returns></returns>
        public static float CalculateWidth(string content, string fontFilePath, float space, float pt)
        {
            //这里引用itextsharp的字体,是为了计算空格的大小,因为GDI+对空格的宽度统一为0
            FontFactory.Register(fontFilePath);
            BaseFont bfChinese = BaseFont.CreateFont(fontFilePath, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);

            return(CalculateWidth(content, bfChinese, space, pt));
        }
コード例 #9
0
 public static void Register(string name)
 {
     if (!FontFactory.IsRegistered(name))
     {
         var path = $"{Environment.GetFolderPath(Environment.SpecialFolder.Windows)}\\Fonts\\{name}.tff";
         FontFactory.Register(path);
     }
 }
コード例 #10
0
        public void Verify_Html_To_Pdf_With_colspan_CanBeCreated()
        {
            var pdfFilePath = TestUtils.GetOutputFileName();
            var stream      = new FileStream(pdfFilePath, FileMode.Create);

            // create a StyleSheet
            var styles = new StyleSheet();

            // set the default font's properties
            styles.LoadTagStyle(HtmlTags.BODY, "encoding", "Identity-H");
            styles.LoadTagStyle(HtmlTags.BODY, HtmlTags.FONT, "Tahoma");
            styles.LoadTagStyle(HtmlTags.BODY, "size", "16pt");

            FontFactory.Register(TestUtils.GetTahomaFontPath());

            var unicodeFontProvider = FontFactoryImp.Instance;

            unicodeFontProvider.DefaultEmbedding = BaseFont.EMBEDDED;
            unicodeFontProvider.DefaultEncoding  = BaseFont.IDENTITY_H;

            var props = new Hashtable
            {
                { "font_factory", unicodeFontProvider }
            };

            var document = new Document();

            PdfWriter.GetInstance(document, stream);
            document.AddAuthor(TestUtils.Author);
            document.Open();
            var objects = HtmlWorker.ParseToList(
                new StringReader(@"<table style='width: 100%;font-size:9pt;font-family:Tahoma;'>
 <tr>
    <td align='center' bgcolor='#00FF00' colspan='2'>Hello</td>
 </tr>
 <tr>
    <td align = 'right'> Month </td>
    <td align = 'right'> Savings </td>
 </tr>
 <tr>
   <td align = 'right'> January </td>
   <td align = 'right'>$100 </td>
 </tr>
</table>"),
                styles,
                props
                );

            foreach (IElement element in objects)
            {
                document.Add(element);
            }

            document.Close();
            stream.Dispose();

            TestUtils.VerifyPdfFileIsReadable(pdfFilePath);
        }
コード例 #11
0
 public static iTextSharp.text.Font GetFont(string FontName, string FontPath, bool IsFullPath = false)
 {
     if (!FontFactory.IsRegistered(FontName))
     {
         var fontPath = IsFullPath ? FontPath : Environment.GetEnvironmentVariable("SystemRoot") + "\\fonts\\" + FontPath;
         FontFactory.Register(fontPath);
     }
     return(FontFactory.GetFont(FontName, BaseFont.IDENTITY_H, BaseFont.EMBEDDED));
 }
コード例 #12
0
        static UnicodeFontProvider()
        {
            // روش صحيح تعريف فونت
            var systemRoot = Environment.GetEnvironmentVariable("SystemRoot");

            FontFactory.Register(Path.Combine(systemRoot, "fonts\\tahoma.ttf"));
            // ثبت ساير فونت‌ها در اينجا
            //FontFactory.Register(Path.Combine(Environment.CurrentDirectory, "fonts\\irsans.ttf"));
        }
コード例 #13
0
ファイル: ReportController.cs プロジェクト: Irfan2k19/CIS
 private static Font GetFont(string fontName, string filename)
 {
     if (!FontFactory.IsRegistered(fontName))
     {
         var fontPath = Environment.GetEnvironmentVariable("SystemRoot") + "\\fonts\\" + filename;
         FontFactory.Register(fontPath);
     }
     return(FontFactory.GetFont(fontName, BaseFont.IDENTITY_H, BaseFont.EMBEDDED));
 }
コード例 #14
0
ファイル: cPDF.cs プロジェクト: jrosalesmeza/FCDisenoNervios
 private static Font RegistrerFont(string fontname, float Size, int Style, BaseColor Color)
 {
     if (!FontFactory.IsRegistered(fontname))
     {
         string fontPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), $"{fontname.ToLower()}.ttf");
         FontFactory.Register(fontPath);
     }
     return(FontFactory.GetFont(fontname, Size, Style, Color));
 }
コード例 #15
0
 public iTextSharp.text.Font getFont(string fontName)
 {
     if (!FontFactory.IsRegistered(fontName))
     {
         var fontPath = "fonts\\" + fontName;
         FontFactory.Register(fontPath);
     }
     return(FontFactory.GetFont(fontName, BaseFont.IDENTITY_H, BaseFont.EMBEDDED));
 }
コード例 #16
0
 public static Font GetUnicodeFont(
     string fontName, string fontFilePath, float size, int style, BaseColor color)
 {
     if (!FontFactory.IsRegistered(fontName))
     {
         FontFactory.Register(fontFilePath);
     }
     return(FontFactory.GetFont(fontName, BaseFont.IDENTITY_H, BaseFont.EMBEDDED, size, style, color));
 }
コード例 #17
0
        public static Font GetFont()
        {
            if (!FontFactory.IsRegistered(FontName))
            {
                FontFactory.Register(PublicMethods.map_path(FontAddress));
            }

            return(FontFactory.GetFont(FontName, BaseFont.IDENTITY_H, BaseFont.EMBEDDED));
        }
コード例 #18
0
        protected PDFGeneratorBase()
        {
            //FontFactory.Register("c:\\windows\\fonts\\ARIALUNI.TTF");

            //fontNote = FontFactory.GetFont("");

            // string strFontpath = System.Configuration.ConfigurationSettings.AppSettings["FileFontCh"].ToString().Trim();
            string strFontpath     = "";
            string strFontpathThai = "";

            if (System.Web.HttpContext.Current.Session["ClientCSS"] != null && !string.IsNullOrEmpty(System.Web.HttpContext.Current.Session["ClientCSS"].ToString()))
            {
                strFontpath     = HttpContext.Current.Server.MapPath("~/" + System.Web.HttpContext.Current.Session["ClientCSS"] + "/Fonts/wt011.ttf");
                strFontpathThai = HttpContext.Current.Server.MapPath("~/" + System.Web.HttpContext.Current.Session["ClientCSS"] + "/Fonts/Kinnari.ttf");
            }
            else
            {
                strFontpath     = HttpContext.Current.Server.MapPath("~/PurpleBlueGray/Fonts/wt011.ttf");
                strFontpathThai = HttpContext.Current.Server.MapPath("~/PurpleBlueGray/Fonts/Kinnari.ttf");
            }
            FontFactory.Register(strFontpath);
            FontFactory.Register(strFontpathThai);
            BaseFont basefont     = BaseFont.CreateFont(strFontpath.ToString().Trim(), BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
            BaseFont basefontThai = BaseFont.CreateFont(strFontpathThai.ToString().Trim(), BaseFont.IDENTITY_H, BaseFont.EMBEDDED);

            fontDocHdrBold = FontFactory.GetFont("Arial Unicode MS", 18, Font.BOLD);
            //fontDocHdrBoldCh = FontFactory.GetFont("Arial Unicode MS", 18, Font.BOLD);
            fontDocHdrBoldCh = new  Font(basefont, 18, Font.BOLD);
            fontNote         = FontFactory.GetFont("Arial Unicode MS", 10, Font.NORMAL);
            // fontNoteCh = FontFactory.GetFont("Arial Unicode MS", 10, Font.NORMAL);
            fontNoteCh   = new Font(basefont, 10, Font.NORMAL);
            fontNoteBold = FontFactory.GetFont("Arial Unicode MS", 10, Font.BOLD);
            //fontNoteBoldCh = FontFactory.GetFont("Arial Unicode MS", 10, Font.BOLD);
            fontNoteBoldCh    = new Font(basefont, 10, Font.BOLD);
            fontNoteUnderline = FontFactory.GetFont("Arial Unicode MS", 9, Font.UNDERLINE);
            //fontNoteUnderlineCh = FontFactory.GetFont("Arial Unicode MS", 9, Font.UNDERLINE);
            fontNoteUnderlineCh = new Font(basefont, 9, Font.UNDERLINE);
            fontDocContent      = FontFactory.GetFont("Arial Unicode MS", 9, Font.NORMAL);
            //fontDocContentCh = FontFactory.GetFont("Arial Unicode MS", 9, Font.NORMAL);
            fontDocContentCh = new Font(basefont, 9, Font.NORMAL);

            fontDocContentUnderline = FontFactory.GetFont("Arial Unicode MS", 10, Font.NORMAL);
            //fontDocContentUnderlineCh = FontFactory.GetFont("Arial Unicode MS", 10, Font.NORMAL);
            fontDocContentUnderlineCh = new Font(basefont, 10, Font.NORMAL);

            fontDocContentUnderline.SetStyle(Font.UNDERLINE);

            fontDocContentBoldUnderline   = FontFactory.GetFont("Arial Unicode MS", 10, Font.BOLD);
            fontDocContentBoldUnderlineCh = FontFactory.GetFont("Arial Unicode MS", 10, Font.BOLD);
            //fontDocContentBoldUnderlineCh = new Font(basefont, 10, Font.BOLD);

            fontDocContentBoldUnderline.SetStyle(Font.UNDERLINE);

            fontThai      = new Font(basefontThai, 8, Font.NORMAL);
            fontThaiSmall = new Font(basefontThai, 5.5f, Font.NORMAL);
        }
コード例 #19
0
        public iTextSharp.text.Font GetTextFont()
        {
            var fontName = "Ubuntu";

            if (!FontFactory.IsRegistered(fontName))
            {
                var fontPath = Server.MapPath("~") + "images\\fonts\\Ubuntu-Regular.ttf";
                FontFactory.Register(fontPath);
            }
            return(FontFactory.GetFont(fontName, BaseFont.IDENTITY_H, BaseFont.EMBEDDED));
        }
コード例 #20
0
        public Font GetTHSarabunNew()
        {
            var fontName = "THSarabunNew";

            if (!FontFactory.IsRegistered(fontName))
            {
                var fontPath = this.path + "\\Fonts\\THSarabunNew.ttf";
                FontFactory.Register(fontPath);
            }
            return(FontFactory.GetFont(fontName, BaseFont.IDENTITY_H, BaseFont.EMBEDDED));
        }
コード例 #21
0
        public iTextSharp.text.Font GetZHFont()                 // chinese font
        {
            var fontName = "simhei";

            if (!FontFactory.IsRegistered(fontName))
            {
                var fontPath = Server.MapPath("~") + "images\\fonts\\simhei.ttf";
                FontFactory.Register(fontPath);
            }
            return(FontFactory.GetFont(fontName, BaseFont.IDENTITY_H, BaseFont.EMBEDDED));
        }
コード例 #22
0
        public static iTextSharp.text.Font GetTahoma()
        {
            var fontName = "Tahoma";

            if (!FontFactory.IsRegistered(fontName))
            {
                var fontPath = Environment.GetEnvironmentVariable("SystemRoot") + "\\fonts\\tahoma.ttf";
                FontFactory.Register(fontPath);
            }
            return(FontFactory.GetFont(fontName, BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 22f, Font.BOLD));
        }
コード例 #23
0
        public static Font GetTahomaFont()
        {
            const string fontName = "Tahoma";

            if (!FontFactory.IsRegistered(fontName))
            {
                var fontPath = Environment.GetEnvironmentVariable("SystemRoot") + "\\fonts\\tahoma.ttf";
                FontFactory.Register(fontPath);
            }
            return(FontFactory.GetFont(fontName, BaseFont.IDENTITY_H, BaseFont.EMBEDDED));
        }
コード例 #24
0
ファイル: InsertPDF.cs プロジェクト: Freshivoje/Freshivoje
        public static Font GetTahoma()
        {
            var fontName = "Tahoma";

            if (!FontFactory.IsRegistered(fontName))
            {
                var fontPath = Environment.GetEnvironmentVariable("SystemRoot") + "\\fonts\\tahoma.ttf";
                FontFactory.Register(fontPath);
            }
            return(FontFactory.GetFont(fontName, BaseFont.CP1250, 8, Font.NORMAL));
        }
        F GetVerdana(float taille, int style = F.NORMAL, BaseColor color = null)
        {
            color = color ?? new BaseColor(111, 111, 111);
            var fontName = "Verdana";

            if (!FontFactory.IsRegistered(fontName) && File.Exists(_fontFilePath))
            {
                FontFactory.Register(_fontFilePath);
            }
            return(FontFactory.GetFont(fontName, BaseFont.IDENTITY_H, BaseFont.EMBEDDED, taille, style, color));
        }
コード例 #26
0
ファイル: Form1.cs プロジェクト: agaheman/UsefullCodes
        private static iTextSharp.text.Font GetFont(string fontName, int fontSize)
        {
            if (!FontFactory.IsRegistered(fontName))

            {
                FontFactory.Register(Environment.GetEnvironmentVariable("SystemRoot") + "\\fonts\\" + fontName +
                                     ".ttf");
            }

            return(FontFactory.GetFont(fontName, BaseFont.IDENTITY_H, BaseFont.EMBEDDED, fontSize));
        }
コード例 #27
0
ファイル: Program.cs プロジェクト: Sathyaish/NOWReport
        static void Main(string[] args)
        {
            try
            {
                FontFactory.Register("C:\\Windows\\Fonts\\segoeuil.ttf", "Segoe UI Light");

                using (var document = new Document(PageSize.A4, 72, 72, 72, 72))
                {
                    using (var writer = PdfWriter.GetInstance(document, new FileStream("C:\\temp\\Foo.pdf", FileMode.Create)))
                    {
                        writer.PageEvent = new PageEventHandler();

                        document.Open();

                        document.AddHeader("defaultHeader", "This is the header of this document.");

                        document.AddTitle("This is the document title");

                        var headingFont     = FontFactory.GetFont("Segoe UI Light", 20f, BaseColor.GREEN);
                        var runningTextFont = FontFactory.GetFont("Segoe UI Light", 11f, BaseColor.DARK_GRAY);

                        var text = File.ReadAllText("C:\\temp\\source.txt");

                        document.Add(new Paragraph("This is a paragraph.", headingFont));

                        FontFactory.Register("C:\\Windows\\Fonts\\georgia.ttf", "Georgia");
                        var georgia = FontFactory.GetFont("Georgia", 20f);

                        var chunk = new Chunk("This is a chunk", georgia);
                        chunk.SetBackground(BaseColor.GREEN);
                        // chunk.SetHorizontalScaling(0.7f);
                        chunk.setLineHeight(2f);
                        // chunk.SetSkew(0f, 10f);
                        // chunk.SetTextRenderMode(1, 0.5f, BaseColor.BLUE);
                        chunk.SetTextRise(5f);
                        chunk.SetWordSpacing(1f);
                        document.Add(chunk);

                        document.Add(new Paragraph(text, runningTextFont));

                        document.Close();
                    }
                }

                var process = Process.Start(new ProcessStartInfo("C:\\temp\\Foo.pdf"));
                process.Close();
            }
            catch (Exception ex)
            {
                Debugger.Break();

                Debug.Print(ex.ToString());
            }
        }
コード例 #28
0
        private static void registerFonts(string mainFontPath, string defaultFontPath)
        {
            if (!FontFactory.IsRegistered(mainFontPath))
            {
                FontFactory.Register(mainFontPath);
            }

            if (!FontFactory.IsRegistered(defaultFontPath))
            {
                FontFactory.Register(defaultFontPath);
            }
        }
コード例 #29
0
ファイル: Config.cs プロジェクト: JenwitPen/PackingApi
        public BaseFont getTHSarabun()
        {
            string fontName = "THSarabunNew";

            if (!FontFactory.IsRegistered(fontName))
            {
                var fontPath = _hostingEnvironment.ContentRootPath + "\\Fonts\\THSarabunNew.ttf";
                FontFactory.Register(fontPath);
            }
            FontFactory.GetFont(fontName, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
            return(BaseFont.CreateFont(fontName, BaseFont.IDENTITY_H, BaseFont.EMBEDDED));;
        }
コード例 #30
0
ファイル: PdfHelper.cs プロジェクト: srdjan-drca/HomeBudget
        private static void RegisterFonts()
        {
            string rootPath         = Path.Combine(TryGetSolutionDirectoryInfo().FullName, "HomeBudget.Report\\Resources\\");
            string frutigerLt45Path = Path.Combine(rootPath, "LTe50327.ttf");
            string frutigerLt65Path = Path.Combine(rootPath, "lte50329.ttf");

            // Load from win fonts directory, but those ttf will be included in project and will be read from resources
            FontFactory.Register(frutigerLt45Path, "frutiger lt 45 light");
            FontFactory.Register(frutigerLt65Path, "frutiger lt 65 bold");

            frutigerLight5 = FontFactory.GetFont("frutiger lt 45 light", BaseFont.WINANSI, BaseFont.EMBEDDED, 5, Font.NORMAL, BaseColor.RED);
        }