Hi
I'm using PDFsharp 1.32 GDI+ version in .NET 2
i have trouble to figure out how to embed entire font to PDF Problem is Font Arial and czech characters. My goal is to no subset, but embed font into PDF in Unicode because I use Czech characters. Example text is "ěščřžýáíéúů".
My Code to insert text into PDF is:
Code:
private void DrawText(JObject obj, XGraphics gfx) {
XUnit padding = new XUnit((double)obj["possiblePadding"],XGraphicsUnit.Point);
string text = (string)obj["text"];
//prepare font
XFontStyle fontStyle = new XFontStyle();
if ((bool)obj["isBold"]) fontStyle |= XFontStyle.Bold;
if ((bool)obj["isItalic"]) fontStyle |= XFontStyle.Italic;
if ((bool)obj["isUnderline"]) fontStyle |= XFontStyle.Underline;
if (!(bool)obj["isBold"] && !(bool)obj["isItalic"] && !(bool)obj["isUnderline"]) fontStyle |= XFontStyle.Regular;
// set font
XPdfFontOptions fontOption = new XPdfFontOptions(PdfFontEncoding.Unicode,PdfFontEmbedding.Always);
XFont font = new XFont("Arial", (double)obj["fontsize"], fontStyle, fontOption);
string longestString = "something long for examlpe";
double left = 0;
double top = 0;
// set rectangle
XRect rect = new XRect(
left,
top,
gfx.MeasureString(longestString, font).ToSizeF().Width,
gfx.MeasureString(longestString, font).ToSizeF().Height
);
// set align
XTextFormatter tf = new XTextFormatter(gfx);
switch((string)obj["align"]) {
case "left" : tf.Alignment = XParagraphAlignment.Left; break;
case "right": tf.Alignment = XParagraphAlignment.Right; break;
case "center": tf.Alignment = XParagraphAlignment.Center; break;
default: tf.Alignment = XParagraphAlignment.Left; break;
}
// color
XBrush brush = null;
if (isStamp) {
brush = new XSolidBrush(XColor.FromArgb(System.Drawing.ColorTranslator.FromHtml(getColorRGB((string)obj["color"]))));
}
else {
brush = new XSolidBrush(XColor.FromArgb(System.Drawing.ColorTranslator.FromHtml((string)obj["color"])));
}
// draw text
tf.DrawString(text.Replace("$", Environment.NewLine), font, brush, rect);
}
this code generate PDF with fonts shown in attached file (now.jpg) in format
Arial,Bold (Embeded Subset) etc.
but I need to insert entire font in format shown in attached file (mustBe.jpg) in format
Arial-BoldMT (Embeded)only distinction beatween these two files is (i thing) embeding or subseting font.
Sorry I can't submit project to forum, but it is complex web site depends on many settings.
Is it any way to truly embed entire font not only subset? If there is no way to do that my only option will be change library and lost lot of work time.
I would appreciate your help
Thank you
Paul