PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Fri Jul 19, 2024 7:15 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Mon Jul 20, 2015 10:58 am 
Offline

Joined: Mon Jul 20, 2015 10:47 am
Posts: 2
Hello everyone,
I am working on a project where I have to export some Unicode chars.

This works fine for everyone Unicode letter like : [U+00B1] but not for [U+1F512]any chance to work this out?

Code:
 
            _document = new Document();

            Style style = _document.Styles["Normal"];
            style.Font.Name = "Segoe UI Symbol"; // Includes both Unicode chars!

            var _lastSection = _document.AddSection();
            _lastSection.AddParagraph("[U+00B1] [U+1F512]"); // These are the actual symbols, the forum doesnt allow me to submit the post otherwise!!
            string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "test.pdf");
            if(File.Exists(path))
                File.Delete(path);

            // Create a renderer for the MigraDoc document.
            PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(true, PdfFontEmbedding.Always);

            // Associate the MigraDoc document with a renderer
            pdfRenderer.Document = _document;

            // Layout and render document to PDF
            pdfRenderer.RenderDocument();

            // Save the document...
            pdfRenderer.PdfDocument.Save(path);


This code produces the 'broken' (not rendering Unicode) pdf. (All Unicode symbols are shown correctly in the debugger and the used Font does implement both!)

Thanks for the help

cBra


Top
 Profile  
Reply with quote  
PostPosted: Mon Jul 20, 2015 11:32 am 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 951
Location: CCAA
Hi!

AFAIK all Unicode characters greater or equal to U+10000 are not yet supported by PDFsharp.

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
PostPosted: Mon Jul 20, 2015 12:01 pm 
Offline

Joined: Mon Jul 20, 2015 10:47 am
Posts: 2
Any chance to "hack" my way around it? It is a necessity to have access to all Unicode symbols for me.


Top
 Profile  
Reply with quote  
PostPosted: Mon Jul 20, 2015 3:38 pm 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 951
Location: CCAA
cBra wrote:
Any chance to "hack" my way around it?
I don't know how much is required for that.

Look at this code:
Code:
const string strA = "\u0081";
const string strB = "\U0001f512";
int lenA = strA.Length;
int lenB = strB.Length;
lenA will be 1 and lenB will be 2. Oops.
These surrogate pairs are a problem for this forum, they are a problem for PDFsharp, they are a problem for C#/.NET or whatever.

I don't know how many changes are required in PDFsharp, but you won't get away with changing just two or three lines. The problem starts earlier as the normal .NET string functions won't handle those surrogate pairs as one character.

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 12 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group