Page Index Toggle Pages: 1 [2] 3 4 5 Send TopicPrint
Very Hot Topic (More than 25 Replies) how to set wpf spreadsheet export pdf font. (Read 22367 times)
David Chiang
Junior Member
**
Offline


I Love MindFusion!

Posts: 75
Joined: Apr 15th, 2020
Re: how to set wpf spreadsheet export pdf font.
Reply #15 - May 30th, 2020 at 1:29pm
Print Post  
Thanks for the reply, the attach pdf works on chrome and acrobat reader. How do I need to change my code to make it work?

Thanks


I can not give your the complete code since the data feed is from the live data from one of my restful server.

The data is working since I can export to xlsx and csv file


           private void menuItemPdf_Click(object sender, RoutedEventArgs e)
           {
                 SaveFileDialog dialog = new SaveFileDialog();

                 dialog.Filter = "PDF Files (*.pdf)|*.pdf|All files (*.*)|*.*||";
                 if (dialog.ShowDialog(this) == true)
                 {
                       var activeSheet = workbookView.ActiveWorksheet;
                       PdfExporter pdfExporter = new PdfExporter();
                       pdfExporter.AutoDetectEncoding = false;
                       pdfExporter.DefaultEncoding = Encoding.Unicode;
                       pdfExporter.Export(activeSheet, dialog.FileName);
                 }
           }


This is all my code

Any setting is needed?

It works on PDF exporting for reporting module

Thanks

« Last Edit: Jun 1st, 2020 at 4:38am by David Chiang »  

ReportPDF.png ( 10 KB | 155 Downloads )
ReportPDF.png
Back to top
 
IP Logged
 
Slavcho
God Member
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: how to set wpf spreadsheet export pdf font.
Reply #16 - Jun 1st, 2020 at 8:21am
Print Post  
If export with same code works on our side but not on yours we'll have to implement some logging to investigate, our developer thinks the part that queries font character sizes might be failing on your side for whatever reason. We also have a feature in ASP.NET components that does not query system fonts (because access to font files is restricted on servers), but uses a pre-made table of font measures. We'll add that to the spreadsheet for you to try if you are interested.

Regards,
Slavcho
  
Back to top
 
IP Logged
 
David Chiang
Junior Member
**
Offline


I Love MindFusion!

Posts: 75
Joined: Apr 15th, 2020
Re: how to set wpf spreadsheet export pdf font.
Reply #17 - Jun 1st, 2020 at 12:39pm
Print Post  
it would be much appreciate if your engineer can look into the issue. I am using WPF package not ASP.NET. The PDF for reporting is working but not spreadsheet. Thanks a lot

David Chiang
  
Back to top
 
IP Logged
 
Slavcho
God Member
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: how to set wpf spreadsheet export pdf font.
Reply #18 - Jun 2nd, 2020 at 6:23am
Print Post  
Could you try exporting with this build -
https://mindfusion.eu/_temp/font_cache.zip

using following options?

Code
Select All
pdfExporter.FontCachePath = @"path\to\pdflib-fontrecords.xml";
pdfExporter.AutoDetectEncoding = false;
pdfExporter.DefaultEncoding = Encoding.Unicode; 



If still different from our PDF, please attach yours exported from exact same bbb.xlsx you attached earlier so we try to compare them.

Regards,
Slavcho
  
Back to top
 
IP Logged
 
David Chiang
Junior Member
**
Offline


I Love MindFusion!

Posts: 75
Joined: Apr 15th, 2020
Re: how to set wpf spreadsheet export pdf font.
Reply #19 - Jun 3rd, 2020 at 2:18am
Print Post  
This is the code I applied

                       PdfExporter pdfExporter = new PdfExporter();
                       pdfExporter.FontCachePath = @"C:\ZZReport\pdflib-fontrecords.xml";
                       pdfExporter.AutoDetectEncoding = false;
                       pdfExporter.DefaultEncoding = Encoding.Unicode;
                       pdfExporter.Export(activeSheet, dialog.FileName);


It seems still get the same result. I also try run this program without these two lines

                       pdfExporter.AutoDetectEncoding = false;
                       pdfExporter.DefaultEncoding = Encoding.Unicode;


But got errors. Say something internal lock and stop the run after a while.

Thanks

Still can not open from acrobat read. But is readable from chrome.
  

zz.rar ( 44 KB | 180 Downloads )
Back to top
 
IP Logged
 
Slavcho
God Member
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: how to set wpf spreadsheet export pdf font.
Reply #20 - Jun 3rd, 2020 at 11:19am
Print Post  
Right, so we can find /FontDescriptor objects in our PDF but not in yours:

Code
Select All
21 0 obj
<<
/Type /FontDescriptor
/FontName /MingLiU
/Flags 5
/FontBBox [0 -199 999 1199]
>>
endobj 



Do you have that MingLiU font installed? The exporter might rely on it being available on the system (https://en.wikipedia.org/wiki/List_of_typefaces_included_with_Microsoft_Windows) and use as fallback for Unicode.
  
Back to top
 
IP Logged
 
David Chiang
Junior Member
**
Offline


I Love MindFusion!

Posts: 75
Joined: Apr 15th, 2020
Re: how to set wpf spreadsheet export pdf font.
Reply #21 - Jun 4th, 2020 at 1:23am
Print Post  
I believe so. It is standard MS font in windows system since windows 95. The PDF function is working for report module but not spreadsheet. Thanks
  
Back to top
 
IP Logged
 
Slavcho
God Member
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: how to set wpf spreadsheet export pdf font.
Reply #22 - Jun 4th, 2020 at 6:59am
Print Post  
Does the exporter stop on any exception if you enable 'Break when exception is thrown' option in Ctrl+Alt+E dialog and run in debug mode (F5)?

Regards,
Slavcho
  
Back to top
 
IP Logged
 
Slavcho
God Member
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: how to set wpf spreadsheet export pdf font.
Reply #23 - Jun 4th, 2020 at 7:38am
Print Post  
Are you using same MingLiU font in exported reports as well when you say reporting module works? What happens if you change report's fonts to MingLiU, or spreadsheet's ones to a different Unicode font (e.g. Arial Unicode MS)?
  
Back to top
 
IP Logged
 
David Chiang
Junior Member
**
Offline


I Love MindFusion!

Posts: 75
Joined: Apr 15th, 2020
Re: how to set wpf spreadsheet export pdf font.
Reply #24 - Jun 4th, 2020 at 8:40am
Print Post  
                       var range = activeSheet.CellRanges[0, 0, i, recCount+1];
                       range.Style.FontName = "Arial Unicode MS";
                       activeSheet.EndInit();


Screen result.
  

spreadsheet_001.png ( 26 KB | 159 Downloads )
spreadsheet_001.png
Back to top
 
IP Logged
 
David Chiang
Junior Member
**
Offline


I Love MindFusion!

Posts: 75
Joined: Apr 15th, 2020
Re: how to set wpf spreadsheet export pdf font.
Reply #25 - Jun 4th, 2020 at 8:44am
Print Post  
Strange, PDF look OK now.
  

spreadsheet_002.png ( 53 KB | 158 Downloads )
spreadsheet_002.png
Back to top
 
IP Logged
 
David Chiang
Junior Member
**
Offline


I Love MindFusion!

Posts: 75
Joined: Apr 15th, 2020
Re: how to set wpf spreadsheet export pdf font.
Reply #26 - Jun 4th, 2020 at 8:47am
Print Post  
                       var range = activeSheet.CellRanges[0, 0, i, recCount+1];
                       range.Style.FontName = "MingLiU";
                       activeSheet.EndInit();

Screen looks good.
  

spreadsheet_003.png ( 53 KB | 162 Downloads )
spreadsheet_003.png
Back to top
 
IP Logged
 
David Chiang
Junior Member
**
Offline


I Love MindFusion!

Posts: 75
Joined: Apr 15th, 2020
Re: how to set wpf spreadsheet export pdf font.
Reply #27 - Jun 4th, 2020 at 8:50am
Print Post  
PDF become not readable.

Regards


All of above are not setting any code

                       var activeSheet = workbookView.ActiveWorksheet;
                       PdfExporter pdfExporter = new PdfExporter();
                       //pdfExporter.FontCachePath = @"C:\ZZReport\pdflib-fontrecords.xml";
                       //pdfExporter.AutoDetectEncoding = false;
                       //pdfExporter.DefaultEncoding = Encoding.Unicode;
                       pdfExporter.Export(activeSheet, dialog.FileName);
  

spreadsheet_004.png ( 62 KB | 161 Downloads )
spreadsheet_004.png
Back to top
 
IP Logged
 
Slavcho
God Member
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: how to set wpf spreadsheet export pdf font.
Reply #28 - Jun 4th, 2020 at 10:09am
Print Post  
It might not show on screen if you don't have the font installed, and WPF falls back to non-Unicode font. Can you see Arial Unicode MS in fonts applet? PDF export itself does some font fallback of its own and could still work if you don't have exact font. Strange thing is exporting MingLiU is not working for you, while it works on our end. Could you attach your MingLiU files so we compare with ours? I guess if you set same font you were testing with in report, it should work in spreadsheet too.
  
Back to top
 
IP Logged
 
David Chiang
Junior Member
**
Offline


I Love MindFusion!

Posts: 75
Joined: Apr 15th, 2020
Re: how to set wpf spreadsheet export pdf font.
Reply #29 - Jun 4th, 2020 at 11:13am
Print Post  
Where can I attach this file. It is too big to send. 10M file. The size is 27,447,296 and version is 7.03

Thanks
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1 [2] 3 4 5
Send TopicPrint