HI
I use the RadPdfProcessing API to generate Pdf document and preview the pdf file in WinForm App.
The pdf previewed by Acrobat Reader then the chinese char displayed normally,
but not works for Telerik.WinControls.UI.RadPdfViewer in WinForm
(same as http://www.telerik.com/clientsfiles/445045_Wrong.jpg?sfvrsn=0)
Generate pdf file c:\Hello1.pdf :
// Reference :
//
// FontsRepository.RegisterFont data Parameter
Telerik.Windows.Documents.Fixed.Model.Fonts.FontsRepository.RegisterFont(new FontFamily("標楷體"),
System.Windows.FontStyles.Normal,
System.Windows.FontWeights.Normal,
File.ReadAllBytes("C:\\Windows\\Fonts\\kaiu.ttf"));
Telerik.Windows.Documents.Fixed.Model.Fonts.FontBase NewCreateFont;
Telerik.Windows.Documents.Fixed.Model.Fonts.FontsRepository.TryCreateFont(
new FontFamily("標楷體"),
System.Windows.FontStyles.Normal,
System.Windows.FontWeights.Normal,
out NewCreateFont);
// Reference :
//
// CREATING A PDF DOCUMENT
Telerik.Windows.Documents.Fixed.Model.RadFixedDocument document2 = new Telerik.Windows.Documents.Fixed.Model.RadFixedDocument();
Telerik.Windows.Documents.Fixed.Model.RadFixedPage page2 = document2.Pages.AddPage();
Telerik.Windows.Documents.Fixed.Model.Editing.FixedContentEditor editor = new Telerik.Windows.Documents.Fixed.Model.Editing.FixedContentEditor(page2);
editor.Position.Translate(50, 50);
Telerik.Windows.Documents.Fixed.Model.Editing.Block block = new Telerik.Windows.Documents.Fixed.Model.Editing.Block();
block.GraphicProperties.FillColor = Telerik.Windows.Documents.Fixed.Model.ColorSpaces.RgbColors.Black;
block.HorizontalAlignment = Telerik.Windows.Documents.Fixed.Model.Editing.Flow.HorizontalAlignment.Left;
block.TextProperties.Font = Telerik.Windows.Documents.Fixed.Model.Fonts.FontsRepository.HelveticaBoldOblique;
block.TextProperties.FontSize = 40;
block.InsertText("RadPdfProcessing");
block.TextProperties.Font = NewCreateFont; // Telerik.Windows.Documents.Fixed.Model.Fonts.FontsRepository.Helvetica;
block.TextProperties.FontSize = 12;
block.InsertText(" 中文字 is a document processing library that enables your application to " +
"import and export files to and from PDF format. The document model is " +
"entirely independent from UI and allows you to generate sleek documents " +
"with differently formatted text, images, shapes and more.");
editor.DrawBlock(block, new System.Windows.Size(500, double.PositiveInfinity));
Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider provider2 = new Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider();
using (Stream output2 = File.OpenWrite("c:\\Hello1.pdf"))
{
provider2.Export(document2, output2);
}
Preview the pdf file c:\Hello1.pdf :
private void button1_Click(object sender, EventArgs e)
{
radPdfViewer1.LoadDocument("c:\\Hello1.pdf");
}
I have reference the forums and posts then embed the fonts into pdf file but the code still not works :
Chinese characters support ?
http://www.telerik.com/forums/chinese-characters-support#bA9YpXuJGk6Fz9yDbs8wmA
How can I generate and preview pdf file normally in WinForm App?
Tools :
Telerik DevCraft Q1 2016 SP1
Windows 7
Visual Studio 2015 Ultimate and .NET Framework 4.0
Best regards
Chris