Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
Si necesitas usar muchas de las clases, métodos y propiedades de Aspose.PDF for .NET, considera crear un ensamblaje wrapper (usando C# o cualquier otro lenguaje de programación .NET). Los ensamblajes wrapper ayudan a evitar el uso de Aspose.PDF for .NET directamente desde código no administrado.
Un buen enfoque es desarrollar un ensamblaje .NET que haga referencia a Aspose.PDF for .NET y realice todo el trabajo con él, y solo exponga un conjunto mínimo de clases y métodos al código no administrado. Tu aplicación debería trabajar solo con tu biblioteca wrapper.
Reducir el número de clases y métodos que necesitas invocar a través de COM Interop simplifica el proyecto. Usar clases .NET a través de COM Interop a menudo requiere habilidades avanzadas.
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.