Answered by:
pdf file generated byiText7 does not show Chinese characters.

Question
-
Hi team,
I am using iText7 to generate a pdf file, and there are 2 issues i am not able to figure out:
1. I am using below code to generate the pdf file that contains Chinese characters, while i am getting below link that looks like addressing the similar issue: https://social.msdn.microsoft.com/Forums/vstudio/en-US/0aba545a-c8ba-4389-9439-fcad416ee60d/display-chinesejapanese-characters-in-pdf-in-itextsharp-in-c?forum=csharpgeneral
but unfornaturely it was in old version of iText and the current version iText7 has lots of difference, below are the code i used generate pdf file, and it is not able to show any Chinese characters
string pdfFilePath = @"D:\temp\test.pdf"; if (dgvFeedbackDetails.Rows.Count > 0) { Table pdfTable = new Table(dgvFeedbackDetails.Columns.Count - 1); pdfTable.SetPadding(3); pdfTable.SetBorder(Border.NO_BORDER); pdfTable.SetWidth(UnitValue.CreatePercentValue(100)); pdfTable.SetHorizontalAlignment(iText.Layout.Properties.HorizontalAlignment.LEFT); for (int i = 0; i < dgvFeedbackDetails.Columns.Count -1; i++) { Cell cell = new Cell().Add(new Paragraph(dgvFeedbackDetails.Columns[i].HeaderText)); cell.SetBorderTop(new SolidBorder(ColorConstants.RED, 1)); cell.SetBorderBottom(new SolidBorder(ColorConstants.BLUE, 1)); pdfTable.AddCell(cell); } foreach (DataGridViewRow dr in dgvFeedbackDetails.Rows) { pdfTable.AddCell(dr.Cells[0].Value.ToString()); pdfTable.AddCell(dr.Cells[1].Value.ToString()); pdfTable.AddCell(dr.Cells[2].Value.ToString()); pdfTable.AddCell(dr.Cells[3].Value.ToString()); pdfTable.AddCell(dr.Cells[4].Value.ToString()); pdfTable.AddCell(dr.Cells[5].Value.ToString()); } PdfWriter writer = new PdfWriter(pdfFilePath); PdfDocument pdfDoc = new PdfDocument(writer); Document doc = new Document(pdfDoc, PageSize.A4); doc.Add(new Paragraph("学生详情: " + txtTesterDetails.Text)); doc.Add(new Paragraph("测试问题数:" + txtTotalQuiz.Text + ". 答对问题数:" + txtCorrectAns.Text + ". 答错问题数:" + txtIncorrectAns.Text + ". 学生分数:" + txtScore.Text)); doc.Add(new Paragraph("开始时间:" + txtStartTime.Text + ". 结束时间:" + txtFinishTime.Text + ". 用时:" + txtDuration.Text)); doc.Add(new Paragraph()); doc.Add(pdfTable); doc.Close(); MessageBox.Show("Opening test report now...", "Test Report", MessageBoxButtons.OK, MessageBoxIcon.Information); Process.Start(pdfFilePath); }
2. I have a blank pdf file that has company title, and i would like to merge the data into the pdf file with company title, i tried to search such scenario but with no luck, is there anyone in here had the similar scenario done?
- Moved by CoolDadTx Friday, June 5, 2020 1:17 PM Third Party Product
Friday, June 5, 2020 10:48 AM
Answers
-
I can confirm that I have finally resolved this issue, but since this forum is for c# rather than iText7, so plz ping me if anyone else come across this issue and I am more than happier to help.
- Marked as answer by AndieDu Thursday, June 18, 2020 6:58 AM
Thursday, June 18, 2020 6:55 AM
All replies
-
This forum is for C#-specific questions only. We do not provide support for third party libraries like iText. Please post your question in their forums.
Michael Taylor http://www.michaeltaylorp3.net
Friday, June 5, 2020 1:17 PM -
ok, thanks for the advise.
I have seen the previous post (the link) has been asking for the similar thing and got answered, hence i posted in here.
Will post on the forum you mentioned.
Saturday, June 6, 2020 7:31 AM -
I can confirm that I have finally resolved this issue, but since this forum is for c# rather than iText7, so plz ping me if anyone else come across this issue and I am more than happier to help.
- Marked as answer by AndieDu Thursday, June 18, 2020 6:58 AM
Thursday, June 18, 2020 6:55 AM