Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
多くのAspose.PDF for .NETクラス、メソッド、プロパティを使用する必要がある場合は、ラッパーアセンブリを作成することを検討してください(C#または他の.NETプログラミング言語を使用)。ラッパーアセンブリは、非管理コードからAspose.PDF for .NETを直接使用することを避けるのに役立ちます。
良いアプローチは、Aspose.PDF for .NETを参照する.NETアセンブリを開発し、それを使ってすべての作業を行い、非管理コードに対して最小限のクラスとメソッドのみを公開することです。アプリケーションは、ラッパーライブラリのみで動作する必要があります。
COM Interopを介して呼び出す必要のあるクラスとメソッドの数を減らすことで、プロジェクトが簡素化されます。COM Interopを介して.NETクラスを使用するには、しばしば高度なスキルが必要です。
using System.Runtime.InteropServices;
namespace TextRetriever
{
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface IRetriever
{
[DispId(1)]
void SetLicense(string file);
[DispId(2)]
string GetText(string file);
}
[ClassInterface(ClassInterfaceType.None)]
[ComSourceInterfaces(typeof(IRetriever))]
public class Retriever : IRetriever
{
public void SetLicense(string file)
{
var lic = new Aspose.Pdf.License();
lic.SetLicense(file);
}
public string GetText(string file)
{
// Open PDF document
using (var document = new Aspose.Pdf.Document(file))
{
// Create TextAbsorber object to extract text
var absorber = new Aspose.Pdf.Text.TextAbsorber();
// Accept the absorber for all document's pages
document.Pages.Accept(absorber);
// Get the extracted text
string text = absorber.Text;
return text;
}
}
}
}
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.