私のプロジェクトでエラーが発生します。
*DLL「gsdll32.dll」で「gsapi_new_instance」という名前のエントリポイントが見つかりません。*
Ghost-script Interpreterdll'gsdll32.dll'を使用して.pdfを画像形式に変換しようとした場合
のような多くのフォーラムで言われているように、このdllをすべての目的の場所にコピーしようとしても
Win\System32またはプロジェクトのディレクトリ..エラーは同じままです..:(
Ghost-scriptで指定されたPDFConvert.csクラスを使用し、変換ボタンのクリックで次のコードを記述しました。
private void btnConvert_Click(object sender, RoutedEventArgs e)
{
//First We Check whether the Dll is present
if (!File.Exists(AppDomain.CurrentDomain.BaseDirectory + "\\gsdll32.dll"))
{
MessageBox.Show("The library 'gsdll32.dll' required to run this program is not present! download GhostScript and copy \"gsdll32.dll\" to this program directory");
return;
}
if (string.IsNullOrEmpty(txtSingleFile.Text))
{
MessageBox.Show("Enter the File name");
txtSingleFile.Focus();
return;
}
else if (!File.Exists(txtSingleFile.Text))
{
MessageBox.Show("The File Does not exists");
txtSingleFile.Focus();
}
else
ConvertPdfToImage(txtSingleFile.Text);
}
私のConvertPdfToImageメソッドは次のようになります。
//The Ghost-Script Class Object Creation:
PdfToImage.PDFConvert converter = new PdfToImage.PDFConvert();
public void ConvertPdfToImage(string filename)
{
//bool converted = false;
System.IO.FileInfo input = new FileInfo(filename);
string outPut = string.Format("{0}\\{1}{2}", input.DirectoryName, input.Name, txtExtensionName.Text);
converter.OutputFormat = txtExtensionName.Text;
outPut = outPut.Replace(txtExtensionName.Text, string.Format("{1}{0}", txtExtensionName.Text, DateTime.Now.Ticks));
converter.Convert(input.FullName, outPut);
lblConvertingResult.Content = string.Format("{0}:File Converted..!!", DateTime.Now.ToShortTimeString());
}
このエラーは、Ghost-Script Interpreter APIによって提供されるサンプルデモで同じコードが適切に実行されるため、gsdll32.dllライブラリの配置ミスが原因であると考えています。dll-gsdll32.dllを保持する正確な場所を提案してください。 !!