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.

Mon Mar 19, 2018 1:31 pm

Hi Spire.Pdf team,
I am trying to use Spire.pdf to print pdf files and I have troubles with fonts. The printed output is corrupted for some fonts. Printing the same file using Acrobat Reader works fine.
I tried to analyze the pdf file, but your method PdfDocument.UsedFonts always fails (input string is not in correct format). Not only for this file, for ALL files I have tried.

Can you help me? See attachments for more details.

Regards,
Milan

pdf2.PNG

pdf1.PNG

milansvec
 
Posts: 5
Joined: Mon Mar 19, 2018 1:06 pm

Tue Mar 20, 2018 2:01 am

Dear Milan,

Thanks for your inquiry.
If you were using an older version, I first suggest downloading our latest Spire.PDF Pack(Hot Fix) Version:4.3.4 to have a try. Besides, please ensure that the fonts used in your PDF files have been installed on your system. After trying, if the issue still occurs, please provide a sample PDF file which can reproduce your issue to help us do further investigations.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1187
Joined: Tue Sep 27, 2016 1:06 am

Tue Mar 20, 2018 9:38 am

Hi, thanks for quick reply.
I already updated to the last version. I do not know the font name used in pdf, that is why I tried to use PdfDocument.usedfonts method to find it and verify the font in OS. But this method fails (raises exception), see attachement. It fails for all the pdf files I have tested. This issue does not allow me to get list of fonts, that are used in the pdf file, so I can not continue investigation.
Regards,
Milan

milansvec
 
Posts: 5
Joined: Mon Mar 19, 2018 1:06 pm

Tue Mar 20, 2018 10:04 am

Hello Milan,

Thanks for your prompt response.
Please attach a sample PDF file which can reproduce your issue here (or send it to support@e-iceblue.com). We will look into it and help you out.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1187
Joined: Tue Sep 27, 2016 1:06 am

Tue Mar 20, 2018 1:40 pm

Hello Nina,
I have sent the files by email. Thank you for help.

Regards,
Milan

milansvec
 
Posts: 5
Joined: Mon Mar 19, 2018 1:06 pm

Wed Mar 21, 2018 4:07 am

Dear Milan,

I have received your email.
After testing, I still can't reproduce your issue, the printing and UsedFonts worked well on my side. I checked your PDF file and noticed many fonts are not embedded, you could check the used fonts in Foxit PDF Editor (see attachment). The issue might be caused by a lack of some fonts on your system, so please ensure that the used fonts have been installed on your system successfully. And please also provide your testing environment (such as windows 7, 64-bit) as well as region and language setting (such as China, Chinese) to help us do further test.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1187
Joined: Tue Sep 27, 2016 1:06 am

Wed Mar 21, 2018 3:19 pm

Hi Nina,
wow, you really tested the software! Great work! Thanks.

With the not embedded font, I will make sure, that it is installed on the target system.

For PdfDocument.UsedFonts... my language settings are CZECH (čeština), see attachment for picture).

Regards,
Milan

czech.PNG

milansvec
 
Posts: 5
Joined: Mon Mar 19, 2018 1:06 pm

Thu Mar 22, 2018 2:49 am

Dear Milan,

Thank you for sharing information.
With the same setting, I finally reproduced the UsedFonts issue on my side. The issue is caused by the culture thread. Please refer to below code to fix it.
Code: Select all
CultureInfo cc = Thread.CurrentThread.CurrentCulture;
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
       FilenameTextBox.Text = openFileDialog1.FileName;
}
PdfDocument doc = new PdfDocument();
doc.LoadFromFile(FilenameTextBox.Text);
LogTextBox.AppendText("Analyzing " + FilenameTextBox.Text + Environment.NewLine);
foreach (var font in doc.UsedFonts)
{
        LogTextBox.AppendText(string.Format("Font: %s {0} {1} {2} {3}", font.Name, font.Size, font.Style.ToString(), font.Type.ToString()) + Environment.NewLine);
}
Thread.CurrentThread.CurrentCulture = cc;

However, I still can't find the printing issue, the fonts display correct at my end. Please check the attached xps file. My testing code shown as below. Please make sure the used fonts installed on your system and then directly use this code example to have a test. If the issue still occurs, please tell us your printer name.
Code: Select all
PdfDocument doc = new PdfDocument();
doc.LoadFromFile(FilenameTextBox.Text);
doc.PrintSettings.PrinterName = "Microsoft XPS Document Writer";
doc.PrintSettings.SelectPageRange(1, 1);
doc.Print();

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1187
Joined: Tue Sep 27, 2016 1:06 am

Thu Mar 22, 2018 3:00 pm

Hello Nina, thank you, I will test it and let you know. May be the culture setting affects even the printing process.

Regards,
Milan

milansvec
 
Posts: 5
Joined: Mon Mar 19, 2018 1:06 pm

Fri Mar 23, 2018 1:50 am

Dear Milan,

OK, we look forward to hearing from you. Wish everything goes well.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1187
Joined: Tue Sep 27, 2016 1:06 am

Tue Mar 27, 2018 10:09 am

Hello,

Greetings from E-iceblue.
How is your issue now? Could you please give us some feedback at your convenience?
Thanks in advance.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1187
Joined: Tue Sep 27, 2016 1:06 am

Return to Spire.PDF