Added Profile debug
Changed NextItem property to use GetNextItem method when printing Changed RegisterFont to improve print performance
This commit is contained in:
@@ -14,11 +14,45 @@ using Microsoft.Win32;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Xml;
|
||||
using System.IO;
|
||||
using Volian.Base.Library;
|
||||
|
||||
namespace Volian.Svg.Library
|
||||
{
|
||||
public static class FontFind
|
||||
{
|
||||
public static string FileName(string fontName)
|
||||
{
|
||||
string baseFont = string.Empty;
|
||||
Regex find = new Regex(fontName + @" ?\(.*\)", RegexOptions.IgnoreCase);
|
||||
RegistryKey regKey = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Windows NT\CurrentVersion\Fonts");
|
||||
string[] values = regKey.GetValueNames();
|
||||
baseFont = regKey.GetValue(values[0]).ToString();
|
||||
foreach (string valueName in regKey.GetValueNames())
|
||||
if (find.IsMatch(valueName))
|
||||
return regKey.GetValue(valueName).ToString();
|
||||
return baseFont;
|
||||
}
|
||||
public static string FullFileName(string fontName)
|
||||
{
|
||||
return FontDir + @"\" + FileName(fontName);
|
||||
}
|
||||
private static string _FontDir = null;
|
||||
public static string FontDir
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_FontDir == null)
|
||||
{
|
||||
RegistryKey regKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders");
|
||||
_FontDir = regKey.GetValue("Fonts").ToString();
|
||||
}
|
||||
return _FontDir;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static class VolianPdf
|
||||
{
|
||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
public static int PageCount(string fileName)
|
||||
{
|
||||
PdfReader pdfr = new PdfReader(fileName);
|
||||
@@ -28,18 +62,30 @@ namespace Volian.Svg.Library
|
||||
}
|
||||
public static void RegisterFont(string fontName)
|
||||
{
|
||||
int profileDepth = ProfileTimer.Push(">>>> RegisterFont");
|
||||
if (!iTextSharp.text.FontFactory.IsRegistered(fontName))
|
||||
{
|
||||
//foreach (string name in FontKey.GetValueNames())
|
||||
//{
|
||||
// if (name.StartsWith(fontName))
|
||||
// {
|
||||
// string fontFile = (string)FontKey.GetValue(name);
|
||||
// iTextSharp.text.FontFactory.Register(fontFile.Contains("\\") ? fontFile : FontFolder + "\\" + fontFile);
|
||||
// }
|
||||
//}
|
||||
iTextSharp.text.FontFactory.RegisterDirectories();
|
||||
int profileDepth1 = ProfileTimer.Push(">>>> RegisterDirectory");
|
||||
iTextSharp.text.FontFactory.RegisterDirectory(FontFind.FontDir);
|
||||
ProfileTimer.Pop(profileDepth1);
|
||||
if (!iTextSharp.text.FontFactory.IsRegistered(fontName))
|
||||
{
|
||||
_MyLog.WarnFormat("Problem with Font {0} in {1}", fontName, FontFind.FontDir);
|
||||
iTextSharp.text.FontFactory.RegisterDirectory(FontFind.FontDir);
|
||||
int profileDepth2 = ProfileTimer.Push(">>>> RegisterDirectories");
|
||||
iTextSharp.text.FontFactory.RegisterDirectories();
|
||||
ProfileTimer.Pop(profileDepth2);
|
||||
if (!iTextSharp.text.FontFactory.IsRegistered(fontName))
|
||||
{
|
||||
_MyLog.WarnFormat("Font {0} could not be found!", fontName);
|
||||
}
|
||||
else
|
||||
{
|
||||
iTextSharp.text.Font fnt = iTextSharp.text.FontFactory.GetFont(fontName, 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
ProfileTimer.Pop(profileDepth);
|
||||
}
|
||||
private static RegistryKey _FontKey = Registry.LocalMachine.OpenSubKey("Software").OpenSubKey("Microsoft").OpenSubKey("Windows NT").OpenSubKey("CurrentVersion").OpenSubKey("Fonts");
|
||||
public static RegistryKey FontKey
|
||||
|
Reference in New Issue
Block a user