pvginkel / PdfiumViewer

PDF viewer based on Google's PDFium.
Apache License 2.0
972 stars 418 forks source link

how can i get words locations (x, y coordinates)? #194

Open DenisSouth opened 5 years ago

DenisSouth commented 5 years ago

I can extract text like this. but I want to get locations of each phrase

public static string get_text(string PDFFilePath) { string feed = ""; using(var document = PdfiumViewer.PdfDocument.Load(PDFFilePath)) { var dpi = 300; using(var image = document.Render(0, dpi, dpi, PdfRenderFlags.CorrectFromDpi)) { feed = feed + document.GetPdfText(0) + "\n"; var encoder = ImageCodecInfo.GetImageEncoders().First(c => c.FormatID == ImageFormat.Jpeg.Guid); var encParams = new EncoderParameters(1); encParams.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 100 L); } } return feed; }