mirror of
https://github.com/UglyToad/PdfPig.git
synced 2026-03-10 00:23:29 +08:00
add content order text extractor and example of use
This commit is contained in:
22
examples/ExtractTextWithNewlines.cs
Normal file
22
examples/ExtractTextWithNewlines.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
namespace UglyToad.Examples
|
||||
{
|
||||
using System;
|
||||
using PdfPig;
|
||||
using PdfPig.DocumentLayoutAnalysis.TextExtractor;
|
||||
|
||||
internal static class ExtractTextWithNewlines
|
||||
{
|
||||
public static void Run(string filePath)
|
||||
{
|
||||
using (var document = PdfDocument.Open(filePath))
|
||||
{
|
||||
foreach (var page in document.GetPages())
|
||||
{
|
||||
var text = ContentOrderTextExtractor.GetText(page, true);
|
||||
|
||||
Console.WriteLine(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user