locked
iTextSharp Font RRS feed

  • Question

  • User-1103262355 posted

    Hi ALL,

    I am trying to add the fonts in Ielement but it gives error.

    for (int k = 0; k < htmlarraylist.Count; k++)
                    {
                        BaseFont bf = BaseFont.CreateFont("D:\\Windows\\Fonts\\arabtype.ttf", BaseFont.IDENTITY_H, true);
                        Phrase myPhrase = new Phrase((IElement)htmlarraylist[k], new Font(bf, 20, Font.BOLD));
                        
                        document.Add(myPhrase);
    
                        //document.Add((IElement)htmlarraylist[k]);
                    }

    Error:

    The best overloaded method match for 'iTextSharp.text.Phrase.Phrase(float, iTextSharp.text.Chunk)' has some invalid arguments

    Wednesday, March 2, 2011 2:17 AM

Answers

  • User814673218 posted

    Actually no overload methods is avilable for Phrase which have IElement parsing and Font as second parameter.

    Below should work.

     Phrase myPhrase = new Phrase(htmlarraylist[k].ToString(), new Font(bf, 20, Font.BOLD));

    I have verified it with iTextsharp DLL version 3.1

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, March 4, 2011 8:47 AM

All replies

  • User814673218 posted

    Hi go4voip,

    I am not sure regarding it, but could you try with virtual path instead of physical path.

    BaseFont bf = BaseFont.CreateFont("localhost://yoursite.com/Font/fontname", BaseFont.IDENTITY_H, true);            
    Hope it helps.

    Wednesday, March 2, 2011 3:17 AM
  • User-1103262355 posted

    The issue is not in Path. But it is when i am calling (IElement)htmlarraylist[k] inside the Phrase.

    For the example:

    Phrase myPhrase = new Phrase("<div align=right>Date</div>", new Font(bf, 20, Font.BOLD));  'WORKING FINE

    Phrase myPhrase = new Phrase((IElement)htmlarraylist[k], new Font(bf, 20, Font.BOLD));  'ERROR

    Wednesday, March 2, 2011 3:33 AM
  • User814673218 posted

    What is the type of "htmlarraylist" ?

    Share it.

    Friday, March 4, 2011 3:20 AM
  • User-1103262355 posted

    It is arraylist.

    ArrayList htmlarraylist = iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(new StringReader(htmlText), null);

    Friday, March 4, 2011 8:33 AM
  • User814673218 posted

    Actually no overload methods is avilable for Phrase which have IElement parsing and Font as second parameter.

    Below should work.

     Phrase myPhrase = new Phrase(htmlarraylist[k].ToString(), new Font(bf, 20, Font.BOLD));

    I have verified it with iTextsharp DLL version 3.1

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, March 4, 2011 8:47 AM