Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
If you need to use many of Aspose.PDF for .NET classes, methods and properties, consider creating a wrapper assembly (using C# or any other .NET programming language). Wrapper assemblies help to avoid using Aspose.PDF for .NET directly from unmanaged code.
A good approach is to develop a .NET assembly that references Aspose.PDF for .NET and does all the work with it, and only exposes a minimal set of classes and methods to unmanaged code. Your application then should work just with your wrapper library.
Reducing the number of classes and methods that you need to invoke via COM Interop simplifies the project. Using .NET classes via COM Interop often requires advanced skills.
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.