From 6412f14ceb6fdffaaa80300d3f6619dfe83aa5da Mon Sep 17 00:00:00 2001 From: BobLd <38405645+BobLd@users.noreply.github.com> Date: Mon, 6 Apr 2020 10:22:24 +0100 Subject: [PATCH] Add svg export example --- Document-Layout-Analysis.md | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/Document-Layout-Analysis.md b/Document-Layout-Analysis.md index 81f2891..0d0c9b2 100644 --- a/Document-Layout-Analysis.md +++ b/Document-Layout-Analysis.md @@ -614,4 +614,32 @@ using (var document = PdfDocument.Open(@"document.pdf")) ### Results Viewing the exported html file using [hocrjs](https://github.com/kba/hocrjs): -![hocr example](https://github.com/UglyToad/PdfPig/blob/master/documentation/Document%20Layout%20Analysis/hocr%20example.png) \ No newline at end of file +![hocr example](https://github.com/UglyToad/PdfPig/blob/master/documentation/Document%20Layout%20Analysis/hocr%20example.png) + +## [SVG - work in progress](https://github.com/UglyToad/PdfPig/blob/master/src/UglyToad.PdfPig.DocumentLayoutAnalysis/Export/SvgTextExporter.cs) +### Description +Converts the pdf page to SVG (Scalable Vector Graphics). + +### References +- https://en.wikipedia.org/wiki/Scalable_Vector_Graphics + +### Usage +```csharp +SvgTextExporter exporter = new SvgTextExporter(); + +var options = new ParsingOptions() { ClipPaths = true }; // true if clipped path are needed +using (var document = PdfDocument.Open(@"document.pdf", options )) +{ + for (var i = 0; i < document.NumberOfPages; i++) + { + var page = document.GetPage(i + 1); + + // Convert page to text + var svg = exporter.Get(page); + + // Save text to an html file + File.WriteAllText("document.html", svg); + } +} +``` +### Results