Hi Maria,
//open document<o:p></o:p>
Document pdfDocument = new Document(myDir + "TRT_22-07-2014.pdf");
//string to hold extracted text
string extractedText;
System.Text.StringBuilder builder = new System.Text.StringBuilder();
using (MemoryStream textStream = new MemoryStream())
{
//create text device
TextDevice textDevice = new TextDevice();
//set text extraction options - set text extraction mode (Raw or Pure)
TextExtractionOptions textExtOptions = new
TextExtractionOptions(TextExtractionOptions.TextFormattingMode.Raw);
textDevice.ExtractionOptions = textExtOptions;
//convert a particular page and save text to the stream
textDevice.Process(pdfDocument.Pages[1], textStream);
//close memory stream
textStream.Close();
//get text from memory stream
extractedText = Encoding.Unicode.GetString(textStream.ToArray());
builder.Append(extractedText);
}
File.WriteAllText(myDir+"textdevice_Extracted_raw.txt", builder.ToString());
Please feel free to contact us for any further assistance.
Best Regards,
Hi Maria,
TextAbsorber textAbsorber
= new TextAbsorber(new TextExtractionOptions(TextExtractionOptions.TextFormattingMode.Raw));<o:p></o:p>
textAbsorber.TextSearchOptions.LimitToPageBounds = true;
textAbsorber.TextSearchOptions.Rectangle = new Aspose.Pdf.Rectangle(0, 20, 300, 672);
pdfDocument.Pages[page].Accept(textAbsorber);
linha = textAbsorber.Text;
Please feel free to contact us for any further assistance.
Best Regards,