你也可以使用ImageMagick。而且它是完全免费的!没有试用或付款。
只需从这里下载 ImageMagick .exe 。安装它并在此处下载 NuGet 文件。
有代码!希望我有所帮助!(即使这个问题是 6 年前提出的......)
程序:
using ImageMagick;
public void PDFToBMP(string output)
{
MagickReadSettings settings = new MagickReadSettings();
// Settings the density to 500 dpi will create an image with a better quality
settings.Density = new Density(500);
string[] files= GetFiles();
foreach (string file in files)
{
string fichwithout = Path.GetFileNameWithoutExtension(file);
string path = Path.Combine(output, fichwithout);
using (MagickImageCollection images = new MagickImageCollection())
{
images.Read(fich);
foreach (MagickImage image in images)
{
settings.Height = image.Height;
settings.Width = image.Width;
image.Format = MagickFormat.Bmp; //if you want to do other formats of image, just change the extension here!
image.Write(path + ".bmp"); //and here!
}
}
}
}
功能GetFiles()
:
public string[] GetFiles()
{
if (!Directory.Exists(@"your\path"))
{
Directory.CreateDirectory(@"your\path");
}
DirectoryInfo dirInfo = new DirectoryInfo(@"your\path");
FileInfo[] fileInfos = dirInfo.GetFiles();
ArrayList list = new ArrayList();
foreach (FileInfo info in fileInfos)
{
if(info.Name != file)
{
// HACK: Just skip the protected samples file...
if (info.Name.IndexOf("protected") == -1)
list.Add(info.FullName);
}
}
return (string[])list.ToArray(typeof(string));
}