mirror of
https://github.com/UglyToad/PdfPig.git
synced 2026-03-10 00:23:29 +08:00
Add svg export example
@@ -614,4 +614,32 @@ using (var document = PdfDocument.Open(@"document.pdf"))
|
||||
### Results
|
||||
Viewing the exported html file using [hocrjs](https://github.com/kba/hocrjs):
|
||||
|
||||

|
||||

|
||||
|
||||
## [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
|
||||
|
||||
Reference in New Issue
Block a user