PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Apr 26, 2018 5:18 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: Mon Apr 16, 2018 8:37 am 
Offline

Joined: Mon Apr 16, 2018 8:25 am
Posts: 6
Hello,

new PDFSharp user here, very powerful tool but struggling with a problem on font names.

When trying to embed Times New Roman, the font name referenced in the PDF is somehow transformed in "Times#20New#20Roman" and Adobe applications complain about not being able to find the font when loading the PDF (tried on Illustrator and InDesign).

Is it something known (possibly some glaring oversight since I cannot believe this is not happening to somebody else)?

Using Windows (10) with Adobe CC applications and PDFSharp 1.50.4845-RC2a.

Thank you very much in advance.

Best regards,
Mario


Top
 Profile  
Reply with quote  
PostPosted: Mon Apr 16, 2018 10:03 am 
Offline
empira Employee
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 2811
Location: Cologne, Germany
Hi!

I'd expect the font name in the PDF to start with "TimesNewRoman".

Nothing we will do without an MCVE aka IssueSubmissionTemplate.
viewtopic.php?f=2&t=832

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Mon Apr 16, 2018 10:11 am 
Offline

Joined: Mon Apr 16, 2018 8:25 am
Posts: 6
Hello, thanks for the prompt reply.

I opened the PDF file with a text editor and I see a lot of those:

/BaseFont/QDAHJM+Times#20New#20Roman
/FontName/QDAHJM+Times#20New#20Roman

We tried with a different library, same system, same fonts, and there's no problem with the resulting PDF.

Thanks!

- Mario


Top
 Profile  
Reply with quote  
PostPosted: Mon Apr 16, 2018 10:22 am 
Offline

Joined: Mon Apr 16, 2018 8:25 am
Posts: 6
(Zipped) PDF file attached, preparing a stripped down example in Visual Studio that exhibits the issue.

- Mario


Attachments:
C22D2D77-7CD7-4920-9970-0CFCEDB2DE6C_tempfile.zip [91.53 KiB]
Downloaded 3 times
Top
 Profile  
Reply with quote  
PostPosted: Mon Apr 16, 2018 10:49 am 
Offline

Joined: Mon Apr 16, 2018 8:25 am
Posts: 6
Also attached an MCVE, Visual Studio solution.

Thanks,
Mario


Attachments:
SVGtoPDFPoC.zip [158.01 KiB]
Downloaded 5 times
Top
 Profile  
Reply with quote  
PostPosted: Mon Apr 16, 2018 9:12 pm 
Offline
User avatar

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

I thought I knew PDFsharp, but turns out I do not.

Until PDFsharp 1.50 beta 2 there were no spaces.
With PDFsharp 1.50 beta 3 and later there are spaces.

In the PDF Reference I found no information whether spaces are allowed or forbidden.
Adobe Reader does not complain. And the spaces "#20" persist when I use "Save as" in Adobe Reader DC, so it looks as if spaces are OK for PDF - just not OK for older Adobe tools it seems.

A PDF created from Word shows "TimesNewRoman" without spaces.

I'll investigate this a bit further, but not tonight.
It could be better to use fontnames without spaces like early versions did.

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


Top
 Profile  
Reply with quote  
PostPosted: Mon Apr 23, 2018 7:04 am 
Offline

Joined: Mon Apr 16, 2018 8:25 am
Posts: 6
Hello, we went into more details and our investigations so far uncovered a couple of connected issues:

1) Postscript name is not fetched correctly.
If I understand well the specs, the /FontName and /BaseFont directives expect the postscript name of the font.
It seems that in the RC2a library version a different name is used (often containing spaces, while all proper postscript names I saw never included spaces).
Times New Roman is a good example that shows the problem.

2) In these fonts in which the name used by PDFSharp includes spaces, every space is replaced by a "#20" escape sequence; while I guess that this is good for many other cases, it seems that an "escaped" font name in the above-mentioned PDF directives cause issues in many applications, among which Adobe ones, that don't deal properly with them (probably they are out of specs).

I hope the above points can be taken care soon because they make the current version quite unusable.

Best regards,
Mario


Top
 Profile  
Reply with quote  
PostPosted: Mon Apr 23, 2018 9:58 am 
Offline
empira Employee
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 2811
Location: Cologne, Germany
mabian wrote:
I hope the above points can be taken care soon because they make the current version quite unusable.
The "#20" is there since December 2015 (and not just since RC2) and you are the first to complain about it. If it was "quite unusable" then we should have heard many complaints so far.

mabian wrote:
If I understand well the specs, the /FontName and /BaseFont directives expect the postscript name of the font.
What are the specs? How should spaces be treated?

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Mon Apr 23, 2018 10:49 am 
Offline

Joined: Mon Apr 16, 2018 8:25 am
Posts: 6
Thomas Hoevel wrote:
mabian wrote:
I hope the above points can be taken care soon because they make the current version quite unusable.
The "#20" is there since December 2015 (and not just since RC2) and you are the first to complain about it. If it was "quite unusable" then we should have heard many complaints so far.


Probably only a few people use fonts which name, as processed by PDFSharp, has spaces in it.
Or people don't get annoyed by having to deal with a "font remap" window each time the pdf is opened in an application like Illustrator.
Or they don't use fonts of the type that triggers the troublesome case.

In the process we are developing, hundreds of PDF files are produced automatically and then worked in Illustrator, this loading delay can be significant.
So, maybe not unusable but for sure a bit annoying - at least in the context I described.

Thomas Hoevel wrote:
mabian wrote:
If I understand well the specs, the /FontName and /BaseFont directives expect the postscript name of the font.
What are the specs? How should spaces be treated?

I took a look at the PDF 1.7 specs (see attachment) and there's no explicit mention of forbidden spaces.
But I never saw a name with spaces in all PDFs I inspected, other than the ones produced with PDFSharp.
The specs are quite clear in describing how to get the correct name to put in the BaseFont and FontName statements, though they don't explicitly mention escaping rules.

I'm surprised like you that nobody else reported this issue.
For the moment being, the quickest solution for us was reverting to an earlier version, of course with the risk of getting some bugs and losing enhancements that were introduced in later versions..

Thanks,
Mario


Attachments:
Postscript.png
Postscript.png [ 117.8 KiB | Viewed 19 times ]
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC


Who is online

Users browsing this forum: Baidu [Spider], Bing [Bot] and 6 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:  
Powered by phpBB® Forum Software © phpBB Group