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 22051 times)
Slavcho
God Member
*****
Online


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: how to set wpf spreadsheet export pdf font.
Reply #30 - Jun 4th, 2020 at 11:18am
Print Post  
try emailing it zipped with max. compression to support@mindfusion.eu
  
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 #31 - Jun 4th, 2020 at 12:01pm
Print Post  
Just did from lwcxxx@hotmail.com.

Thanks
  
Back to top
 
IP Logged
 
Slavcho
God Member
*****
Online


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: how to set wpf spreadsheet export pdf font.
Reply #32 - Jun 4th, 2020 at 12:42pm
Print Post  
Better edit out your email address above or it will get spammed. We have received the font file and ours is exactly the same when compared in binary mode, so problem is not font itself. If you attach a test project of yours showing failed export for MingLiU + Unicode we could find something else in program's state leading to problems. Have you tried if using same font as in reports along with Unicode encoding fixes spreadsheet's export?
  
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 #33 - Jun 4th, 2020 at 1:10pm
Print Post  
I just send out the project files but without server URL. The program will not run but it is the complete code.

Thanks
  
Back to top
 
IP Logged
 
Slavcho
God Member
*****
Online


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: how to set wpf spreadsheet export pdf font.
Reply #34 - Jun 7th, 2020 at 11:12am
Print Post  
We think this build should fix export -
https://mindfusion.eu/_temp/pdf_font_name.zip

Problem was MingLiU.ttf also contains native Chinese names of the font (like 細明體) which WPF probably returns first on Chinese versions of Windows. PDF objects need to be encoded in ASCII so exporter would fail if font name is in Chinese on your side, but worked for us since we get 'MingLiU' first. Now it should always encode using Latin name of the font. You'll still need to export using the Unicode option.

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 #35 - Jun 7th, 2020 at 1:36pm
Print Post  
Thanks a lot, But I still get the same result with following 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);

  

2020-06-07_213359.png ( 40 KB | 163 Downloads )
2020-06-07_213359.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 #36 - Jun 7th, 2020 at 1:41pm
Print Post  
With following 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);


I recompile the code and use the new library you send me.

Thanks
  

2020-06-07_213905.png ( 42 KB | 161 Downloads )
2020-06-07_213905.png
Back to top
 
IP Logged
 
Slavcho
God Member
*****
Online


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: how to set wpf spreadsheet export pdf font.
Reply #37 - Jun 8th, 2020 at 6:21am
Print Post  
Please attach the PDF file. What does this print on your side if you add MingLiU-TextBlock to window.xaml?

Code
Select All
<TextBlock x:Name="test" Text="test" FontFamily="MingLiU" />

void Window_Loaded(object s, RoutedEventArgs e)
{
	var drawing = VisualTreeHelper.GetDrawing(test);
	foreach (var child in drawing.Children)
	{
		var group = child as DrawingGroup;
		if (group != null)
		{
			foreach (var child2 in group.Children)
			{
				var glyphRun = child2 as GlyphRunDrawing;
				if (glyphRun != null)
				{
					foreach (var kv in glyphRun.GlyphRun.GlyphTypeface.FamilyNames)
					{
						Debug.WriteLine(
							string.Format("{0}:{1}", kv.Key, kv.Value));
					}
				}

			}
		}
	}
} 

  
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 #38 - Jun 9th, 2020 at 2:37am
Print Post  
The debug show following

en-US:MingLiU
zh-HK:細明體
zh-TW:細明體


and I add following code in my program

           private void Window_Loaded(object sender, RoutedEventArgs e)
           {
                 var drawing = VisualTreeHelper.GetDrawing(test);
                 foreach (var child in drawing.Children)
                 {
                       var group = child as DrawingGroup;
                       if (group != null)
                       {
                             foreach (var child2 in group.Children)
                             {
                                   var glyphRun = child2 as GlyphRunDrawing;
                                   if (glyphRun != null)
                                   {
                                         foreach (var kv in glyphRun.GlyphRun.GlyphTypeface.FamilyNames)
                                         {
                                               Debug.WriteLine(
                                                     string.Format("{0}:{1}", kv.Key, kv.Value));
                                         }
                                   }

                             }
                       }
                 }
           }


Thanks
  
Back to top
 
IP Logged
 
Slavcho
God Member
*****
Online


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: how to set wpf spreadsheet export pdf font.
Reply #39 - Jun 9th, 2020 at 5:52am
Print Post  
It shouldn't work any different than our Windows version then if reporting en-US variant of font name. Please attach your last PDF file so we can examine the font objects generated. Make sure your project is using new assembly files, e.g. check their modification dates in bin/debug after rebuilding.
  
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 #40 - Jun 9th, 2020 at 12:23pm
Print Post  
Here is the result and code are

                       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);


Thanks
  

result.rar ( 46 KB | 174 Downloads )
Back to top
 
IP Logged
 
Slavcho
God Member
*****
Online


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: how to set wpf spreadsheet export pdf font.
Reply #41 - Jun 9th, 2020 at 12:33pm
Print Post  
This PDF still tries to encode the Chinese font name for MingLiU instead of the English one, so the project's probably still referencing the older assemblies. Have you verified dll file dates inside bin/debug after rebuilding are ones from latest zip file above: 6/7/2020 1:53PM?
  
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 #42 - Jun 9th, 2020 at 1:17pm
Print Post  
This is the current version.
  

2020-06-09_211616.png ( 60 KB | 159 Downloads )
2020-06-09_211616.png
Back to top
 
IP Logged
 
Slavcho
God Member
*****
Online


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: how to set wpf spreadsheet export pdf font.
Reply #43 - Jun 9th, 2020 at 4:48pm
Print Post  
this build implements logging, please call pdfExporter.EnableLogging("log.txt") and attach the log file -
https://mindfusion.eu/_temp/pdf_log.zip
  
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 #44 - Jun 9th, 2020 at 10:10pm
Print Post  
Here is the log file.

Thanks
  

log.txt ( 65 KB | 193 Downloads )
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1 2 [3] 4 5 
Send TopicPrint