Sign In  Sign Up Live-Chat

Multiple Fonts in 1 cell

Last post 05-16-2008, 11:35 AM by shanesur. 11 replies.
Sort Posts: Previous Next
  •  05-13-2008, 2:56 PM 126770

    Multiple Fonts in 1 cell

    Is it possible to have part of the text in a cell in bold and the other part non-bold?

    Thanks in advance....

     
  •  05-13-2008, 7:11 PM 126792 in reply to 126770

    Re: Multiple Fonts in 1 cell

    Hi,

    Thank you for considering Aspose.

    Sure it is possible. You can use multiple segments with different format. Please refer to Working with Text.


    Tommy Wang
    Lead Developer
    Aspose Changsha Team
    About Us
    Contact Us
     
  •  05-14-2008, 2:34 AM 126835 in reply to 126770

    Re: Multiple Fonts in 1 cell

    Hi,

    Thnak you for considering Aspose.Pdf

    Yes it is possible to change the text property and its all done through Aspose.Pdf.TextInfo class and is done very easily through TextInfo.IsTrueTypeFontBold = true; function call.

    Using this class all the text parameters like setting Alignment, FontName, FontSize and many more can be Set or Get. for more details on all the class members visit

    http://www.aspose.com/documentation/file-format-components/aspose.pdf-for-.net-and-java/aspose.pdf.textinfomembers.html

    It's a common practice to use Text.TextInfo property to modify text format settings of any Section , Text paragraph or Segment . Kindly visit the link given below that can be helpful in this regard.

    http://www.aspose.com/documentation/file-format-components/aspose.pdf-for-.net-and-java/aspose.pdf.textinfo.html


     


    Nayyer Shahbaz
    Support Developer
    Aspose Changsha Team
    About Us
    Contact Us
     
  •  05-14-2008, 4:07 AM 126853 in reply to 126835

    Re: Multiple Fonts in 1 cell

    I have the same Problem and its not possible for only one or few words in a cell.

    My Code in Aspose PDF Java:
    Table table = new Table(sec1);
               
                table.setColumnWidths("150 150");
               
                //add a row
                Row row1 = new Row(table);
                table.getRows().add(row1);
               
                Cell cell11 = new Cell(table, "some text");
               
                Text t1 = new Text(sec1);
                Segment s1 = new Segment(t1);
                s1.setContent("RED TEXT");
                s1.getTextInfo().setTextColor(Color.Red);
                t1.getSegments().add(s1);

                cell11.getParagraphs().add(t1);
               
                row1.getCells().add(cell11);
               
                Cell cell12 = new Cell(table,"some more text");
                row1.getCells().add(cell12);
               
                //add another row
                Row row2 = new Row(table);
                table.getRows().add(row2);
               
                Cell cell21 = new Cell(table,"another some text");
                row2.getCells().add(cell21);
               
                Cell cell22 = new Cell(table,"another some more text");
                row2.getCells().add(cell22);
               
                //add table to sec1
                sec1.getParagraphs().add(table);

    I only can set the TextInfo for the complete cell as setDefaultCellTextInfo but i want only some words of the Cell in red.
    Can anyone help me plz?

    Thanks for help
    vland
     
  •  05-14-2008, 3:23 PM 127011 in reply to 126853

    Re: Multiple Fonts in 1 cell

    Hi,

    I have tested the code and was able to reproduce the error. I have logged this as PDFJAVA-5134 in our issue tracking system. We will try our best to resolve this as soon as possible.

    Thanks.

     
  •  05-14-2008, 8:50 PM 127055 in reply to 127011

    Re: Multiple Fonts in 1 cell

    Attachment: Present (inaccessible)
    Hi, we have already solved this bug in the latest hotfix. You can get the hotfix in the attachment. We will release this hotfix soon. Thank you for considering our product.
    Sandy.Zhang
    Product Developer
    Aspose Changsha Team
    About Us
    Contact Us
     
  •  05-15-2008, 1:26 AM 127091 in reply to 127055

    Re: Multiple Fonts in 1 cell

    Thanks for replaying and fixing it so fast.
    vland
     
  •  05-15-2008, 12:52 PM 127270 in reply to 127011

    Re: Multiple Fonts in 1 cell

    Is this hotfix fixing the issue when using .Net.  I've dowloaded the hotfix, but still have the same problem.

    Thanks in advance

     
  •  05-15-2008, 2:49 PM 127303 in reply to 127270

    Re: Multiple Fonts in 1 cell

    Hi,

    This hotfix is for the Java version only. Can you please provide us with the .NET that you are using so that we can test it.

    Thanks.

     
  •  05-15-2008, 3:19 PM 127310 in reply to 127303

    Re: Multiple Fonts in 1 cell

    Here is the test code i'm using in .Net

     

    private void TestBold()

       Pdf pdf1 = new Pdf();

       Aspose.Pdf.License license = new Aspose.Pdf.License();
       license.SetLicense("Aspose.Total.lic");

       MarginInfo mi = new MarginInfo();
       mi.Left=50;
       mi.Top=20;
       mi.Right=10;
       mi.Bottom=50;

       TextInfo ti = new TextInfo();
       ti.Alignment=AlignmentType.Left;
       ti.FontSize=12;
       ti.TruetypeFontFileName="Arial";

       TextInfo tiB = new TextInfo();
       tiB.Alignment=AlignmentType.Left;
       tiB.FontSize=12;
       tiB.TruetypeFontFileName="Arial";
       tiB.IsTrueTypeFontBold=true;

       Text hfTextTest = new Text();
       Text hfTextTest2 = new Text();

       Section sec1 = pdf1.Sections.Add();
       sec1.IsNewPage=false;
       sec1.PageInfo.Margin = mi;
       sec1.IsPageNumberRestarted=true;
       sec1.StartingPageNumber=1;

       Aspose.Pdf.Table tab1 = new Aspose.Pdf.Table();
       tab1.Alignment=AlignmentType.Left;
       sec1.Paragraphs.Add(tab1);
       tab1.ColumnWidths = "150";
          
       Row rowTest = tab1.Rows.Add();
       
       Segment segmentTest = new Segment(hfTextTest);
       hfTextTest.Segments.Add(segmentTest);
       hfTextTest.TextInfo = tiB;
       segmentTest.Content = "Test Date: ";                                                                                                               
       segmentTest.TextInfo  = tiB;

       Segment segmentTest2 = new Segment(hfTextTest2);
       hfTextTest2.Segments.Add(segmentTest2);
       hfTextTest2.TextInfo = ti;
       segmentTest2.Content = "5/13/2008";                                                                                                               
       segmentTest2.TextInfo  = ti;

       rowTest.Cells.Add(segmentTest.Content + segmentTest2.Content);

       pdf1.Save("TestRpt.pdf", SaveType.OpenInBrowser, Response);
      }

     

    Thanks in advance.

     
  •  05-15-2008, 8:55 PM 127341 in reply to 127310

    Re: Multiple Fonts in 1 cell

    Hi,

    Please modify your code like the following:

       TextInfo ti = new TextInfo();
       ti.Alignment=AlignmentType.Left;
       ti.FontSize=12;
       ti.FontName="Arial";

       TextInfo tiB = new TextInfo();
       tiB.Alignment=AlignmentType.Left;
       tiB.FontSize=12;
       tiB.FontName="Arial";
       tiB.IsTrueTypeFontBold=true;

       Text hfTextTest = new Text();

       Section sec1 = pdf1.Sections.Add();
       sec1.IsNewPage=false;
       sec1.PageInfo.Margin = mi;
       sec1.IsPageNumberRestarted=true;
       sec1.StartingPageNumber=1;

       Aspose.Pdf.Table tab1 = new Aspose.Pdf.Table();
       tab1.Alignment=AlignmentType.Left;
       sec1.Paragraphs.Add(tab1);
       tab1.ColumnWidths = "150";
         
       Row rowTest = tab1.Rows.Add();
      
       Segment segmentTest = new Segment(hfTextTest);
       hfTextTest.Segments.Add(segmentTest);
       hfTextTest.TextInfo = tiB;
       segmentTest.Content = "Test Date: ";                                                                                                               
       segmentTest.TextInfo  = tiB;

       Segment segmentTest2 = new Segment(hfTextTest);
       hfTextTest.Segments.Add(segmentTest2);
       segmentTest2.Content = "5/13/2008";                                                                                                               
       segmentTest2.TextInfo  = ti;

       Cell cell1 = rowTest.Cells.Add();
       cell1.Paragraphs.Add(hfTextTest);


    Tommy Wang
    Lead Developer
    Aspose Changsha Team
    About Us
    Contact Us
     
  •  05-16-2008, 11:35 AM 127477 in reply to 127341

    Re: Multiple Fonts in 1 cell

    Works correct now, I really appreciate the quick response.

    Thanks....

     
View as RSS news feed in XML