I am using DynamicPDF to generate a PDF file with some Korean text. I'm using the PDF system fonts for CJK characters and am not getting the dreaded squares, I'm just getting... blankness.
The characters take up space and adding latin characters afterwards do show up in the position you'd expect them. Selecting the blank space and right clicking or copying it shows the proper expected characters so they exist.
My system does render Korean text, showing it in a HTML page in chrome works while the PDF in chrome doesn't.
Here is a minimal sample with (working) Japanese text to compare.
ceTe.DynamicPDF.Document document = new ceTe.DynamicPDF.Document();
ceTe.DynamicPDF.Page page = new ceTe.DynamicPDF.Page(PageSize.Letter, PageOrientation.Portrait, 54.0f);
// Create a Label to add to the page
var testString = "Korean: 안녕하세요 세계 </korean>";
page.Elements.Add(new Label(testString, 0, 0, 504, 100, Font.SinoTypeSongLight, 18, TextAlign.Center));
page.Elements.Add(new Label(testString, 0, 100, 504, 100, Font.HanyangSystemsGothicMedium, 18, TextAlign.Center));
page.Elements.Add(new Label(testString, 0, 200, 504, 100, Font.HanyangSystemsShinMyeongJoMedium, 18, TextAlign.Center));
testString = "Japan: こんにちは世界 </japan>";
page.Elements.Add(new Label(testString, 0, 300, 504, 100, Font.SinoTypeSongLight, 18, TextAlign.Center));
// Add page to document
document.Pages.Add(page);
// Outputs the document to the current web page
document.Draw("D:/HelloWorld.pdf");
Please refer to the DynamicPDF documentation on CJK fonts.
SinoTypeSongLight font you are using to add Korean characters actually supports simplified Chinese language characters. There is no support for Korean character in that font so blank space is expected for the first line in the PDF.
In the second and third lines you are actually using the correct fonts (HanyangSystemsGothicMedium & HanyangSystemsShinMyeongJoMedium) that support Korean characters. However, according to the documentation link above you should have the Asian Font Pack installed on the machine where you are viewing this PDF. I am not sure what PDF viewer plugin your Chrome browser uses but PDF viewers like Adobe Reader provide Asian Font Pack as an add-on. Please see the screenshot that shows the PDF generated with your code in Adobe Reader DC with Asian Font Pack.
Disclaimer: I work for ceTe Software, the company that develops DynamicPDF libraries.
Related
I'm using Syncfusion's HTML to PDF which is working great!
Little hiccup though, all their documentation shows if you want to change the font of the page numbers at the bottom you have two choices:
standard font:
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12f)
custom font:
PdfFont font = new PdfTrueTypeFont(Server.MapPath("/App_Data/ARIALUNI.ttf"), 24)
But I need to allow a font from google fonts. I have the font loaded in my html but the page numbers are painted after so I'm not sure how to 1. embed it & 2. set it.
Appreciate any help.
Many thanks
For anyone that comes across this rare ask, it's not supported. You need to load and store the TrueType font and then set it to the file location as above.
Zebra model: Zebra Z4M
I have a problem with printing labels from a PDF file on a Zebra printer. If I send a file to be printed that has several pages (one page = one label) the printer prints one page, pauses for 2 seconds, and prints another label (instead of printing continuously)
I create C# app where I generate simple PDF file (using iTextSharp) and print it on Zebra (i send file to Zebra one file who contain multiple pages -> each page == one label)
In iTextSharp i create PDF file with custom dimension:
var pgSize = new iTextSharp.text.Rectangle(353, 180);
Document pdfDocument = new Document(pgSize, 0, 0, 0, 0);
In printer i set dimensions corresponding to the actual size of the label:
P.S.
I noticed that if I send a PDF file for printing with only one page, but by setting the number of copies (e.g. to 5 copies) the printer prints normally (without pausing on each label)
It reads the PDF one page at a time, after printing the first page it will clear it from memory then convert and load the second page.
This printer is discontinued, PDF is not easy to print, especially for old models.
I recommend using ZebraDesigner Professional software for better printing performance, it is more optimized for Zebra printers and have many great options (see image below)
I had a Code 128 True Type Font.
Font font1DText = new Font("Code 128", 16);
e.Graphics.DrawString("12345", font1DText, Brushes.Black, fInfoStartX , fInfoStartY);
I had tried this on Windows 10 and Window 7. The funny thing is initially with Win10 when i print to a printer, it does not show the the barcode which is supposed to be line and spaces. It shows the raw text of the content ie "12345".
At a later stage(i am not sure what i did) it suddenly is able to print correctly.
I now use the same font and code on another PC Win7. The problem happens again showing the raw text "12345"
My purpose of this thread is not about encoding the 128. But why doesn't the print correctly display the 128 font.
I want to use Indian Font (Hindi) in Windows apps.When i used Mangal font for Hindi text ,then text visible but in block format.
so any one can help me for this.
Create New windows forms project and in Form.OnLoad handler, add the following lines:
PrivateFontCollection pfc = new PrivateFontCollection();
string fontFilePath = "C:\\Fonts\\PALETX3.ttf"
pfc.AddFontFile(fontFilePath);
label1.Font = new Font(pfc.Families[0], 16, FontStyle.Regular);
You can find more information from
http://msdn.microsoft.com/en-us/library/ms533820(VS.85).aspx
You can use this code:
YourMainForm.YourTextBox.Font = new Font("Your name of indian font",
YourMainForm.YourTextBox.Font.Size);
Make sure the font you are using supports the Unicode characters in controls. You can find this out using windows utility Character Map.
Some older fonts have characters for a certain code page but not for Unicode characters. For example windows font Marlett have only a few Unicode chars defined, the rest will appear as the boxes in your screen shot. If that is the case your best bet is to find a newer Unicode version of the font. Although in theory you can use font editing software to create a new version yourself (the glyphs are already in there) but it won't be easy. Best of luck :)
I have written a WPF user control that uses Tahoma as a font to display unicode strings, which works fine. However, I have noticed that some eastern asian characters are actually missing in Tahoma, i.e. this font does not support all common Unicode characters.
However, when I display a string that contains some east asian letters, that I suppose are missing in Tahoma.ttf, the character is displayed correctly anyway, instead of a black rectangle that I expected to get for the missing unicode character.
So out of curiosity: is there any fallback mechanism, i.e. does Windows 7 or C# WPF replace the missing characters from a fallback font? Can anybody please explain how exactly this is working, and which font is actually used as a allback?
See the Font Fallback section of the FontFamily reference.
Thanks alot H.B., with your keyword, I was able to find this really helpful ressource from Microsoft, that explains how Font Fallback and Font Linking work:
http://msdn.microsoft.com/en-us/goglobal/bb688134
Here is a good quote:
A user running Windows XP selects the Tahoma font to enter some text first in English, next in Hebrew, and then in Telugu. Since Tahoma is an OpenType font, it provides support for Latin and Hebrew scripts, but does not contain any Telugu glyphs. Uniscribe detects this lack of font support and automatically renders the Telugu script by using its fallback font, which is Gautami.