我需要从PDF文件中提取文本.我找到了iTextSharp和PDFBox,但它们都只是Java端口,为了使它们能够工作,我需要使用大量额外的dll.
所以,我的问题是:是否有一些本地C#库用于从PDF文件中提取文本?如果没有,是否难以写一个?
我正在使用MahApps.Metro在我的应用程序中实现Metro UI.
我有一个listview和MahApps.Metro正在改变它的风格.列表视图的MahApps样式就在这里.
加载款式:
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colours.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.AnimatedSingleRowTabControl.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
<ResourceDictionary Source="pack://application:,,,/FineRSS;component/Resources/Icons.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
Run Code Online (Sandbox Code Playgroud)
我需要跟踪选定的listviewitems,所以我正在使用下一个方法:
<ListView.ItemContainerStyle>
<Style TargetType="{x:Type ListViewItem}">
<Setter Property="IsSelected" Value="{Binding Mode=TwoWay, Path=IsSelected}"/>
</Style>
</ListView.ItemContainerStyle>
Run Code Online (Sandbox Code Playgroud)
但MahApps.Metro的风格被覆盖为ListView的默认风格.
我可以做些什么来保持样式和IsSelected绑定?
我正在基于椭圆创建简单的圆控制(具有中心和半径属性).
使用我的控件的代码很简单(控件在Canvas中):
<my:Circle Canvas.Left="1300" Canvas.Top="1243" CenterX="800" CenterY="800" Radius="100" />
Run Code Online (Sandbox Code Playgroud)
我创建了3个DP:CenterX,CenterY和Radius.
如何从回调中更改Canvas.Top和Canvas.Bottom?
我需要处理和保存原始bpp中的图像(1 - 对于BnW,8 - 对于灰色,24 - 颜色).处理后我总是有24bpp(由于使用Aforge.Net处理).我将原始bpp传递给保存功能,我正在使用下一个代码进行保存:
private static Bitmap changePixelFormat(Bitmap input, PixelFormat format)
{
Bitmap retval = new Bitmap(input.Width, input.Height, format);
retval.SetResolution(input.HorizontalResolution, input.VerticalResolution);
Graphics g = Graphics.FromImage(retval);
g.DrawImage(input, 0, 0);
g.Dispose();
return retval;
}
Run Code Online (Sandbox Code Playgroud)
当我通过时:
PixelFormat.Format8bppIndexed
Run Code Online (Sandbox Code Playgroud)
我得到一个例外:"图形对象无法在索引像素格式中创建图像":
Graphics g = Graphics.FromImage(retval);
Run Code Online (Sandbox Code Playgroud)
我已经尝试了下一个代码:
Bitmap s = new Bitmap("gray.jpg");
Bitmap NewPicture = s.Clone(new Rectangle(0, 0, s.Width, s.Height), PixelFormat.Format8bppIndexed);
Run Code Online (Sandbox Code Playgroud)
在此"NewImage"之后有PixelFormat 8bppIndexed,但是当我保存NewImage时:
NewPicture.Save("hello.jpg", ImageFormat.Jpeg);
Run Code Online (Sandbox Code Playgroud)
hello.jpg有24bpp.
我需要保留原始图像的bpp和图像格式.
为什么Bitmap.Save会忽略Bitmap的PixelFormat?
================================================== =====
谢谢大家,我找到了一个解决方案:http: //freeimage.sourceforge.net/license.html
借助这个免费库,可以将图像(尤其是JPEG)保存到8位灰度级.
在一次采访中,我被问到是否会有一些物体被自动分配给第二代垃圾收集器,我不知道该回答什么.
这可能吗?
也许如果物体足够大以保持零或第一代?
我有JavaScript的功能:
function calc(num) {
if (num <= 22) {
return parseInt(num);
} else {
num += '';
var curr = 0;
for (var i = 0; i < num['length']; i++) {
curr += parseInt(num[i]);
};
return curr;
};
};
Run Code Online (Sandbox Code Playgroud)
此函数计算新数字,如:如果我的数字大于22,则此函数返回新数字,它是其子数的总和(例如28> 22 => return(2 + 8)).
此功能在Firefox的伟大工程,但我发现了"南"错误在Internet Explorer与数字比22越大所以这个问题必须在"其他".
怎么了?