I am using Chinese character including html tag like this “政府关系”
am not using Arial Unicode MS, please suggest me how it will take font automatically in aspose Pdf genrator.
I am also tried …
it support only Arial Unicode MS font in aspose Pdf genrator. I would not prefer to use font name but it will automatically take font .
please provide any solution…
I have observed the code shared by you and have noticed that you are using Generator approach, which is an old model and is going to be obsolete soon. The advanced and enhanced approach to work with Aspose.Pdf API is Document Object Model (DOM) approach, using which a correct output can be achieved as per your requirements.
With latest version of Aspose.Pdf, i.e Aspose.Pdf for .NET 17.11, while using DOM approach, you do not need to specify fonts. Instead, Aspose.Pdf API automatically loads all the fonts installed on a system. Please try using below code sample which adds Chinese text as well as HTML text in a table cell.
// Load source PDF document
Aspose.Pdf.Document doc = new Aspose.Pdf.Document();
//Add a page to PDF document
doc.Pages.Add();
// Initializes a new instance of the Table
Aspose.Pdf.Table table = new Aspose.Pdf.Table();
// Set the table border color as LightGray
table.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .5f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray));
// Set the border for table cells
table.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .5f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray));
// Create a loop to add 10 rows
for (int row_count = 1; row_count <= 5; row_count++)
{
// Add row to table
Aspose.Pdf.Row row = table.Rows.Add();
// Add table cells
row.Cells.Add("Column (" + row_count + ", 1)");
row.Cells.Add("Column (" + row_count + ", 2)");
}
//Adding text to a table
TextFragment text = new TextFragment("政府关系");
text.TextState.ForegroundColor = Color.Red;
table.Rows[1].Cells[1].Paragraphs.Clear();
table.Rows[1].Cells[1].Paragraphs.Add(text);
//Adding HTML text in table
HtmlFragment title = new HtmlFragment("<fontsize=10><b><i>HTML Test</i></b></fontsize>");
table.Rows[4].Cells[0].Paragraphs.Clear();
table.Rows[4].Cells[0].Paragraphs.Add(title);
// Add table object to first page of input document
doc.Pages[1].Paragraphs.Add(table);
dataDir = dataDir + "Table_DOM.pdf";
// Save updated document containing table object
doc.Save(dataDir);
I have attached generated output file for your kind reference Table_DOM.pdf. For further information on working with tables, you may visit this documentation article.
In case you face any issue, please share your source files and a code snippet reproducing the issue. We will be pleased to help.
It is good to know that your problem has been resolved by suggested approach. Please keep using our API and in event of any other query, feel free to ask.
my apologies for reviving an old thread, but I’m struggling with showing chinese characters as well.
could you try “入能加团动队” as the text in the above example and confirm that the last 3 are blank squares? I’m willing to create a new thread if that’s proper procedure.
Would you please make sure to use a licensed version of the API or please apply for a free 30-days temporary license in order to evaluate the API. Furthermore, also check if all windows essential fonts are present/installed in your system. In case issue still persists, please share complete environment details where you are facing it. We will further proceed to assist you accordingly.
attached is the resultant pdf from the code snippet. I did set the license (no watermark) that we have and tried to run it again, but am still getting the 3 blank tiles.
any other ideas or solutions would be appreciated.
Please try to install Arial Unicode MS Font in your system and run the code again. This MS Font contains maximum support for non-English language characters.
I have been troubleshooting issues in aspose.pdf html to pdf conversion in different languages this past week and I have ultimately determined that our issue is due to Arial Unicode MS not being installed and no longer being included on Windows machines. It seems like aspose is highly reliant on this font to find all characters within the Chinese language…
My question is, are there alternative fonts that your team would recommend using? non-proprietary fonts would be great.
Also, instead of having to manually install this unicode font on each machine where our application runs, is there a way to include this font within the application and have aspose reference the font at runtime/document generation?
We recommend installing all MS Core Fonts in the system while working with the Aspose.PDF. Furthermore, there are no such recommendations or specifications for non-proprietary fonts as you can use any custom font as per your choice. You can surely distribute the fonts along with your application. You would need to set the font directory for the API so that it can use and search the required fonts. You can set the font directory like below:
FolderFontSource fs = new FolderFontSource(@"path\to\my\folder");
FontRepository.Sources.Add(fs);
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
Enables storage, such as cookies, related to analytics.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.