Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Tue Jul 11, 2017 12:57 pm

Hi,

i have an exisitng PDF File created from an PDF Printer. If i want to replace all Used Fonts with Arial i get the following error message:

can not replace font, the font is already embedded.

Here is my code:
Code: Select all
String fontFileName = @"c:\windows\fonts\Arial.ttf";
   Spire.Pdf.PdfDocument doc = new Spire.Pdf.PdfDocument();
   doc.LoadFromFile(file);
   PdfUsedFont[] fonts = doc.UsedFonts;
   foreach (PdfUsedFont font in fonts)
   {
      PdfTrueTypeFont trueTypeFont = new PdfTrueTypeFont(fontFileName, font.Size,font.Style);
      font.Replace(trueTypeFont);
   }
   doc.SaveToFile(@"c:\temp\output.pdf");

ck@mp2.at
 
Posts: 2
Joined: Tue Sep 09, 2014 6:14 am

Wed Jul 12, 2017 3:44 am

Hello,

Thanks for your inquiry.
To help us reproduce the issue, could you please share your sample pdf file and the related font file with us?

Many Thanks,
Jane
E-iceblue support team
User avatar

Jane.Bai
 
Posts: 1156
Joined: Tue Nov 29, 2016 1:47 am

Tue Jul 18, 2017 11:02 am

Hi,

here is the sample PDF. The font is the default Windows Arial.ttf.

Regards.

ck@mp2.at
 
Posts: 2
Joined: Tue Sep 09, 2014 6:14 am

Wed Jul 19, 2017 2:34 am

Hello,

Thanks for sharing the file.
I have reproduced the issue and posted it to our Dev team. We will let you know as soon as there is any progress.
Sorry for inconvenience caused.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Thu Jul 20, 2017 2:44 am

Hello,

After an initial test, our dev team found that there was unicode encoding in your pdf document. Becasue of this, the raplace operation might corrupt the inner chracter mapping and cause garbled data. Therefore, there might be no solution to your issue in a short time.
Sorry for the inconvenience caused.

Sincerely,
Jane
E-iceblue support team
User avatar

Jane.Bai
 
Posts: 1156
Joined: Tue Nov 29, 2016 1:47 am

Return to Spire.PDF