FontSize in TextSegment ignored?

Hello,

i have a TextSegment for which i have set a fontSize.
I then add this TextSegment to a TextFragment.
This TextFragment is added to a cell in a table, which i then finally add to the page.
But the TextSize is ignored.
Why is this?

@schiepe

Thanks for posting your inquiry.

Would you kindly share your complete sample code snippet with us which are using at your end. We will test the scenario in our environment and share our feedback accordingly.

I’m experiencing this as well. Is this issue being addressed?
I have an example project I can send you if needed.

@jnixon

Thanks for contacting support.

Sure, please send your sample project along with sample input/output PDF document. We will test the scenario in our environment and address it accordingly.

How do I send you a private message?
The project has my license, I will not make the link public.

While I wait for a response here is how I reproduced this issue:

  1. Create a C# console application

  2. Add Aspose.Pdf using the NuGet Package manager

  3. Add my license as an embedded resource

  4. Add this code to the Main function in the Program.cs file:
    TextFragment textFragment = null;
    Row curRow = null;
    Cell curCell = null;

         Aspose.Pdf.License asposeLicense = new License();
         asposeLicense.SetLicense("AsposeTableTFTest.Aspose.Pdf.lic");
    
         var document = new Aspose.Pdf.Document();
         Aspose.Pdf.Page page = document.Pages.Add();
         document.PageInfo.Height = Aspose.Pdf.PageSize.PageLetter.Height;
         document.PageInfo.Width = Aspose.Pdf.PageSize.PageLetter.Width;
         document.PageInfo.Margin.Top = 20;
         document.PageInfo.Margin.Right = 30;
         document.PageInfo.Margin.Bottom = 20;
         document.PageInfo.Margin.Left = 30;
    
         Table headerTable = new Table
         {
             //DefaultCellBorder = new BorderInfo(BorderSide.All, 0.1F),
             DefaultCellPadding = new MarginInfo() { Top = 4f, Left = 2f, Bottom = 10f, Right = 2f },
             ColumnWidths = "50%",
             DefaultCellTextState = new TextState() { Font = FontRepository.FindFont("Arial"), FontSize = 7F },
             RepeatingRowsCount = 1
         };
         curRow = headerTable.Rows.Add();
         curCell = curRow.Cells.Add();
    
         textFragment = new TextFragment("Some Text that is bold and size 30");
         textFragment.TextState.FontStyle = FontStyles.Bold;
         textFragment.TextState.FontSize = 30;
         textFragment.Margin.Bottom = 8;
         curCell.Paragraphs.Add(textFragment);
    
         textFragment = new TextFragment("Some Text that is size 7");
         curCell.Paragraphs.Add(textFragment);
    
         page.Paragraphs.Add(headerTable);
    
         document.Save(Path.GetTempPath() + "\\test.pdf");
    
  5. Run the program

  6. Open File Explorer and navigate to %TEMP%

  7. Open the file named test.pdf (I’ve attached my copy of the file)

You can see to lines, one is bold and the other is normal weight, the bold line should be font size 30.

test.pdf (58.0 KB)

@jnixon

Thanks for sharing sample code snippet.

We have tested the scenario in our environment and observed that you are setting DefaultCellTextState of Table which is overriding the latter setting of size of text fragment. As DefaultCellTextState settings will be applied to whole table, you can remove it and desired output will be generated. For your kind reference, we have attached an output which was generated in our environment after removing mentioned line of code.

testSizeIssue.pdf (2.3 KB)

In case of any further assistance, please feel free to let us know.

Thanks for your your quick reply.
And for fixing my understanding of the use of your product.

It does work as designed.

@jnixon

Thanks for your kind feedback.

Please keep using our API and in case of any further assistance, please feel free to contact us.