PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sun Nov 10, 2024 7:23 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Wed Aug 24, 2016 2:50 pm 
Offline

Joined: Wed Aug 24, 2016 9:31 am
Posts: 8
I would like to turn off font embedding.

In version 1.32, Unicode fonts are embedded and ANSI fonts are not (with PdfFontEmbedding.None).
Apparently the option was removed in version 1.5. Is there a "hack" available to turn it off?

Font embedding raises a licensing issue, that's why I want to turn it off.

The Monotype Imaging EULA applies for most fonts in Windows (as far as I know).

"You may embed the Font Software only into an electronic document that (i) is not a Commercial Product, (ii) is distributed in a secure format that does not permit the extraction of the embedded Font Software, and (iii) in the case where a recipient of an electronic document is able to Use the Font Software for editing, only if the recipient of such document is within your Licensed Unit."

Is the PDF a secure format that does not permit the extraction of the Font?


Top
 Profile  
Reply with quote  
PostPosted: Thu Aug 25, 2016 3:43 pm 
Offline

Joined: Wed Aug 24, 2016 9:31 am
Posts: 8
I want to note that font embedding drastically increases the PDF file size from 4KB to 13MB. I use Noto Sans CJK SC font (Chinese). I tried to modify version 1.5 to support external font, but without success.

PdfDocument.cs
Uncomment line 460,461

PdfType0Font.cs
Uncomment line 70

This produces a 4KB file but there is a font not found message by Acrobat Reader. Any ideas?


Top
 Profile  
Reply with quote  
PostPosted: Thu Aug 25, 2016 7:25 pm 
Offline

Joined: Wed Aug 24, 2016 9:31 am
Posts: 8
If it is not possible to turn of font embedding for Unicode fonts in PDF format, I suggest that font embedding can be optimized to only include characters used in the document. The font I am using is "Noto Sans CJK SC" and it produced a 13MB output file for 12 characters.


Top
 Profile  
Reply with quote  
PostPosted: Thu Aug 25, 2016 9:57 pm 
Offline

Joined: Wed Aug 24, 2016 9:31 am
Posts: 8
I found out that the font-name in the PDF must be like the filename of the otf file of the font.
for example: "SourceHanSansSC-Regular".

Then it worked. I added a new line to set the BaseFont variable accordingly after line 70, PdfType0Font.cs.


Top
 Profile  
Reply with quote  
PostPosted: Mon Aug 29, 2016 10:32 am 
Offline

Joined: Tue Aug 02, 2016 9:56 am
Posts: 40
Location: Amsterdam, The Netherlands
It is not possible to turn off font embedding in all situations, but it may be possible in some cases for CJK fonts. See https://forums.adobe.com/thread/2127278 for a different situation in which I was not able to get rid of the "font not found" message because I wanted full Unicode coverage, not just CJK.

The general direction PDF is going in is to embed all fonts, because you cannot in general rely on the same font, or even a similar font with the same internal encoding, to be installed on other machines.

_________________
Gerben Vos
Developer


Top
 Profile  
Reply with quote  
PostPosted: Wed Nov 28, 2018 7:56 am 
Offline

Joined: Wed Aug 22, 2018 5:01 am
Posts: 3
I would actually consider the removal of the disabling embedded fonts as a "Bug"... When I create a PDF out of an 40kB picture with watermarks - it creates a 1MB file... When modifying an 100kB PDF - it creates 500kB+ file...

And It's with these options:
document.Options.CompressContentStreams = true;
document.Options.EnableCcittCompressionForBilevelImages = true;
document.Options.FlateEncodeMode = PdfFlateEncodeMode.BestCompression;
document.Options.NoCompression = false;

And if we wrap it in an WebApi response which is Json then we get 40MB PDF file from 4MB image..... This is serious lack of optimizations....


Top
 Profile  
Reply with quote  
PostPosted: Wed Nov 28, 2018 9:16 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3111
Location: Cologne, Germany
AssassinLV wrote:
This is serious lack of optimizations....
Cannot replicate.
Probably this should be in a separate thread.

_________________
Regards
Thomas Hoevel
PDFsharp Team


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 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