PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

Problem with fonts embedding
https://forum.pdfsharp.net/viewtopic.php?f=3&t=396
Page 1 of 1

Author:  Jabberwok [ Wed May 28, 2008 4:17 pm ]
Post subject:  Problem with fonts embedding

I have PDF file, i tried to append some text to it using program from samples. (Unicode) After it worked there are errors in document (fonts are embedded with errors, and there are only dots instead of text)

Here are steps to reproduce:
1) Get this file http://www.uploading.com/files/KTG63HP6/form2.pdf.html
2) Open Unicode program from Samples C# folder (or use code below)
3) Change lines so that:
// Create new document
PdfDocument document = PdfReader.Open(@"c:\form2.pdf");
(here comes your path to file)
4) scroll down till you see pages that were added by code and see the result (and acrobat's error)

Code to test:

class Program
{
[STAThread]
static void Main(string[] args)
{
// Create new document
PdfDocument document = PdfReader.Open(@"c:\form2.pdf");

// Set unicode flag to true
XPdfFontOptions options = new XPdfFontOptions(PdfFontEncoding.Unicode,PdfFontEmbedding.Always);

XFont font = new XFont("Times New Roman", 12, XFontStyle.Regular, options);

// Draw text in different languages
for (int idx = 0; idx < texts.Length; idx++)
{
PdfPage page = document.AddPage();
XGraphics gfx = XGraphics.FromPdfPage(page);
XTextFormatter tf = new XTextFormatter(gfx);
tf.Alignment = XParagraphAlignment.Justify;

tf.DrawString(texts[idx], font, XBrushes.Black,
new XRect(100, 100, page.Width - 200, 600), XStringFormat.TopLeft);
}

string filename = "Unicode.pdf";
// Save the document...
document.Save(filename);
// ...and start a viewer.
Process.Start(filename);
}

static string[] texts = new string[]
{
// International version of the text in English
"English\n" +
"PDFsharp is a .NET library for creating and processing PDF documents 'on the fly'. " +
"The library is completely written in C# and based exclusively on safe, managed code. ",

// PDFsharp is 'Made in Germany'
"German\n" +
"PDFsharp ist eine .NET-Bibliothek zum Erzeugen und Verarbeiten von PDF-Dokumenten 'On the Fly'. " +
"Die Bibliothek ist vollständig in C# geschrieben und basiert ausschließlich auf sicherem, verwaltetem Code. ",

// Greek version
// The text was translated by Babel Fish. We here in Germany have no idea what it means.
// If you are a native speaker please correct it and mail it to mailto:PDFsharpSupport@pdfsharp.de
"Greek (Translated with Babel Fish)\n" +
"Το PDFsharp είναι βιβλιοθήκη δικτύου α. για τη δημιουργία και την επεξεργασία των εγγράφων PDF 'σχετικά με τη μύγα'. Η βιβλιοθήκη γράφεται εντελώς γ # και βασίζεται αποκλειστικά εκτός από, διοικούμενος κώδικας. Το PDFsharp προσφέρει δύο ισχυρά επίπεδα αφαίρεσης για να δημιουργήσει και να επεξεργαστεί",

// Russian version (by courtesy of Alexey Kuznetsov)
"Russia\n" +
"PDFsharp это .NET библиотека для создания и обработки PDF документов 'налету'. " +
"Библиотека полностью написана на языке C# и базируется исключительно на безопасном, управляемом коде. " +
"PDFsharp использует два мощных абстрактных уровня для создания и обработки PDF документов.\n" +
"Для рисования текста, графики, и изображений в ней используется набор классов, которые разработаны аналогично с",

// Your language may come here
"Invitation\n" +
"If you use PDFsharp and haven't found your native language in this document, we will be pleased to get your translation of the text above and include it here.\n" +
"Mail to PDFsharpSupport@pdfsharp.de"
};

Author:  Thomas Hoevel [ Wed Jun 04, 2008 8:22 am ]
Post subject: 

We cannot replicate this problem with current builds of PDFsharp.

A new version of PDFsharp will be publicly available during summer 2008.

Author:  Jabberwok [ Mon Jun 16, 2008 9:29 pm ]
Post subject: 

Strange, I could reproduce it on different computers. Still thank you very much for your reply, I will be waiting for new version!

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/