Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Wed Jan 06, 2016 9:21 pm

Hello
when i try chnage the title of table to hebrew, or when i have any cell with hebrew data i got the following exception
"Couldn't find information about the character. Unicode is not supported by this font"

here is the code that i use

PdfTable table = new PdfTable();
table.Style.CellPadding = 2;
table.Style.HeaderSource = PdfHeaderSource.ColumnCaptions;
table.Style.HeaderRowCount = 1;
table.Style.ShowHeader = true;
table.Style.BorderPen = new PdfPen(PdfBrushes.LightBlue, 0.5F);
table.Style.DefaultStyle.BackgroundBrush = PdfBrushes.LightYellow;
table.Style.DefaultStyle.Font = new PdfTrueTypeFont(new Font("Arial", 8.5F));
table.DataSource = mydataTable;
table.DataSourceType = PdfTableDataSourceType.TableDirect;
table.Style.HeaderStyle.Font = new PdfTrueTypeFont(new Font("Arial", 11f, FontStyle.Bold));
table.Style.HeaderStyle.StringFormat = new PdfStringFormat(PdfTextAlignment.Center);
table.Style.ShowHeader = true;
foreach (PdfColumn column in table.Columns)
column.StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);

this row make exception
table.Columns[0].ColumnName = Properties.Resources.remarks;// hebrew text

PdfTableLayoutFormat tableLayout = new PdfTableLayoutFormat();
tableLayout.Break = PdfLayoutBreakType.FitElement;
tableLayout.Layout = PdfLayoutType.Paginate;
PdfLayoutResult tableDrowResult =table.Draw(page, new PointF(0, 50), tableLayout);






//also i got same exception if any cell on the datatable have hebrew txt
here is my email [email protected]




Exception stack Trace
. at sprἿ.ᜃ(Char A_0) at sprἿ.ᜂ(String A_0) at Spire.Pdf.Graphics.PdfTrueTypeFont.GetLineWidth(String line, PdfStringFormat format) at Spire.Pdf.Graphics.PdfStringLayouter.ᜀ(String A_0) at Spire.Pdf.Graphics.PdfStringLayouter.ᜀ(String A_0, Single A_1) at Spire.Pdf.Graphics.PdfStringLayouter.ᜃ() at Spire.Pdf.Graphics.PdfStringLayouter.Layout(String text, PdfFontBase font, PdfStringFormat format, SizeF size) at spr᫴.ᜀ(PdfLayoutParams A_0, Int32 A_1, String[] A_2, RectangleF A_3, PdfStringLayoutResult[]& A_4, PdfCellStyle A_5) at spr᫴.ᜀ(PdfLayoutParams A_0, Int32& A_1, String[] A_2, RectangleF A_3, Single& A_4, Boolean A_5, Boolean& A_6) at spr᫴.ᜀ(Int32 A_0, PdfLayoutParams A_1, Boolean A_2) at spr᫴.ᜀ(PdfLayoutParams A_0) at sprᜳ.ᜃ(PdfLayoutParams A_0) at Spire.Pdf.Tables.PdfTable.Layout(PdfLayoutParams param) at Spire.Pdf.Graphics.PdfLayoutWidget.Draw(PdfPageBase page, RectangleF layoutRectangle, PdfTextLayout format) at Spire.Pdf.Graphics.PdfLayoutWidget.Draw(PdfPageBase page, Single x, Single y, PdfTextLayout format) at Spire.Pdf.Graphics.PdfLayoutWidget.Draw(PdfPageBase page, PointF location, PdfTextLayout format) at CyberGreenApp.Classes.CreateReports_BL.buildingApprovalUseTable(String contractId) in C:\Work\Cyber Green\EcoProject\App_Web\Classes\CreateReports_BL.cs:line 409 at CyberGreenApp.CreatePDF.DownloadPDF(String docName, String key1, String key2, String key3, String userId) in C:\Work\Cyber Green\EcoProject\App_Web\CreatePDF.aspx.cs:line 68

jamalsleman
 
Posts: 2
Joined: Tue Nov 03, 2015 10:54 am

Thu Jan 07, 2016 2:53 am

Hi,

Thanks for your posting and using our Spire.PDF.
I did some modification on StringFormat and Font of your code about HeaderStyle. I were using Spire.PDF Pack(Hot Fix) Version:3.6.20 for .NET4.0, and attached my testing code. Please check the changes.
Code: Select all
            PdfDocument doc = new PdfDocument();
            PdfPageBase page = doc.Pages.Add();
            PdfTable table = new PdfTable();
            table.Style.CellPadding = 2;
            table.Style.HeaderSource = PdfHeaderSource.ColumnCaptions;
            table.Style.HeaderRowCount = 1;
            table.Style.ShowHeader = true;
            table.Style.BorderPen = new PdfPen(PdfBrushes.LightBlue, 0.5F);
            table.Style.DefaultStyle.BackgroundBrush = PdfBrushes.LightYellow;
            table.Style.DefaultStyle.Font = new PdfTrueTypeFont(new Font("Arial", 8.5F));
            table.DataSource = GetDataTable();
            table.DataSourceType = PdfTableDataSourceType.TableDirect;
            table.Style.HeaderStyle.Font = new PdfTrueTypeFont(new Font(@"..\\..\\Alef-Regular.ttf", 16f, FontStyle.Bold), true);
            table.Style.HeaderStyle.StringFormat = new PdfStringFormat() { RightToLeft = true, Alignment= PdfTextAlignment.Center };
            table.Style.ShowHeader = true;
            foreach (PdfColumn column in table.Columns)
            column.StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);

             string value = "זהו חוט בדיקה";
            table.Columns[0].ColumnName = value;// hebrew text

            PdfTableLayoutFormat tableLayout = new PdfTableLayoutFormat();
            tableLayout.Break = PdfLayoutBreakType.FitElement;
            tableLayout.Layout = PdfLayoutType.Paginate;
            PdfLayoutResult tableDrowResult = table.Draw(page, new PointF(0, 50), tableLayout);
            doc.SaveToFile("result.pdf");
       


Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 3011
Joined: Wed Jun 27, 2012 8:50 am

Thu Jan 07, 2016 10:49 pm

Many Thanks for You it is Work For me.

1 more Question how i can change the width of the column.
i use this code
table.Columns[0].Width = 70;
...
table.Columns[4].Width = 60;

but it is make table width incorrect, first column width become too large and all other become very very small not like i write.

jamalsleman
 
Posts: 2
Joined: Tue Nov 03, 2015 10:54 am

Fri Jan 08, 2016 2:59 am

Hi,

Thanks for your feedback and further inquiry.
Please try the following way to set columns width.
Code: Select all
float width = page.Canvas.ClientSize.Width - (table.Columns.Count + 1) * table.Style.BorderPen.Width;
            table.Columns[0].Width = width * 0.2f;
            table.Columns[1].Width = width * 0.1f;
            table.Columns[2].Width = width * 0.1f;
            table.Columns[3].Width = width * 0.1f;
            table.Columns[4].Width = width * 0.1f;


Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 3011
Joined: Wed Jun 27, 2012 8:50 am

Thu Jan 14, 2016 8:42 am

Hi,

Has your issue been resolved?
Thanks for your feedback.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 3011
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.PDF