Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
Extraer texto de un documento PDF es algo común. Sin embargo, en dicho texto, cuando se extrae, los SuperScripts y SubScripts contenidos en él, que son típicos de documentos y artículos técnicos, pueden no mostrarse. Un SubScript o SuperScript es un carácter, número o letra colocado por debajo o por encima de una línea de texto regular. Generalmente es más pequeño que el resto del texto.
SubScripts y SuperScripts se utilizan más a menudo en fórmulas, expresiones matemáticas y especificaciones de compuestos químicos. Es difícil editarlos cuando puede haber muchos de ellos en el mismo pasaje de texto. En una de las últimas versiones, la biblioteca Aspose.PDF for .NET agregó soporte para extraer texto de SuperScripts y SubScripts de PDF.
Utiliza la clase TextFragmentAbsorber y ya puedes hacer cualquier cosa con el texto encontrado, es decir, puedes simplemente usar todo el texto. Prueba el siguiente fragmento de código:
El siguiente fragmento de código también funciona con la biblioteca Aspose.PDF.Drawing.
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void ExtractSuperScriptsAndSubScripts()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf();
// Open PDF document
using (var document = new Aspose.Pdf.Document(dataDir + "SuperScriptExample.pdf"))
{
// Create an absorber
var absorber = new Aspose.Pdf.Text.TextFragmentAbsorber();
document.Pages[1].Accept(absorber);
using (StreamWriter writer = new StreamWriter(dataDir + "SuperScriptExample_out.txt"))
{
// Write the extracted text in text file
writer.WriteLine(absorber.Text);
}
}
}
O utiliza TextFragments por separado y realiza todo tipo de manipulaciones con ellos, por ejemplo, ordenar por coordenadas o por tamaño.
El siguiente fragmento de código también funciona con la biblioteca Aspose.PDF.Drawing.
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void ExtractSuperScriptsAndSubScriptsWithTextFragments()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf();
// Open PDF document
using (var document = new Aspose.Pdf.Document(dataDir + "SuperScriptExample.pdf"))
{
// Create an absorber
var absorber = new Aspose.Pdf.Text.TextFragmentAbsorber();
document.Pages[1].Accept(absorber);
using (StreamWriter writer = new StreamWriter(dataDir + "SuperScriptExample_out.txt"))
{
foreach (var textFragment in absorber.TextFragments)
{
// Write the extracted text in text file
writer.Write(textFragment.Text);
}
}
}
}
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.