Developer Tools
|
Office Productivity Applications
|
Platform-Agnostic APIs
|
Home | Online Demos | Downloads | Buy Now | Support | About Us | News | Working Together | Contact Us
Until recently, PDFOne .NET supported font embedding only in creation mode. In Version 1.43, methods to enable font embedding in reading mode as well were introduced. One of the methods provides the ability to replace a font existing in the document with another font that will be embedded in its place. In this article, we will see how to use these methods.
To embed a font, we need to first create a PDF font object with a font file present on the system. The font can then be embedded with the new PDFDocument.EmbedFont(PDFFont fontToBeEmbedded)
method.
PDFDocument doc = new PDFDocument(); doc.Load("DocWithoutEmbeddedFont.pdf"); Font fnt = new Font("Garamond", 24); PDFFont pfnt = new PDFFont(fnt, PDFFontEmbedType.Full); doc.EmbedFont(pfnt); doc.OpenAfterCreate = true; doc.Save("DocWithEmbeddedFont.pdf"); doc.Close();
Again, when you try to replace a font, you need to create the PDF font object with the PDFFontEmbedType.Full
setting. Next, you embed the font using another overloaded method PDFDocument.EmbedFont(PDFFont fontToBeEmbedded, string originalFont)
where you can specify the font that needs to be replaced.
PDFDocument doc = new PDFDocument(); doc.Load("DocWithoutEmbeddedFont.pdf"); Font wf = new Font("Segoe UI", 24); PDFFont pf = new PDFFont(wf, PDFFontEmbedType.Full); doc.EmbedFont(pf, "Garamond"); doc.OpenAfterCreate = true; doc.Save("DocWithReplacedFont.pdf"); doc.Close();
---o0O0o---
Our .NET Developer Tools | |
---|---|
Gnostice Document Studio .NETMulti-format document-processing component suite for .NET developers. |
PDFOne .NETA .NET PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, and bookmark PDF documents in .NET applications. |
Our Delphi/C++Builder developer tools | |
---|---|
Gnostice Document Studio DelphiMulti-format document-processing component suite for Delphi/C++Builder developers, covering both VCL and FireMonkey platforms. |
eDocEngine VCLA Delphi/C++Builder component suite for creating documents in over 20 formats and also export reports from popular Delphi reporting tools. |
PDFtoolkit VCLA Delphi/C++Builder component suite to edit, enhance, view, print, merge, split, encrypt, annotate, and bookmark PDF documents. |
Our Java developer tools | |
---|---|
Gnostice Document Studio JavaMulti-format document-processing component suite for Java developers. |
PDFOne (for Java)A Java PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, bookmark PDF documents in Java applications. |
Our Platform-Agnostic Cloud and On-Premises APIs | |
---|---|
StarDocsCloud-hosted and On-Premises REST-based document-processing and document-viewing APIs |
Privacy | Legal | Feedback | Newsletter | Blog | Resellers | © 2002-2024 Gnostice Information Technologies Private Limited. All rights reserved. |