With this project, you can convert a pdf or svg-file to a drawio-file. Drawio-files can be read with Diagrams.net, which is an excellent, free diagramming and vector graphics application, that can be used online, as a desktop-program and as a plugin to visual studio code.
This project uses a great project called pdftosvg to convert pdf to svg and then merges the svg into drawio in a layer called Background and locks the layer. It also creates a new layer so the file is ready to draw upon. Here is an example on a drawio file.
The reason for this project, was the need of making an extension to an FM system (facility management), that can be integrated on a homepage, so users can download drawing files of buildings, to a free drawing program, and easily make there own:
- Evacuation map like this
- "You are here" map like this
- Description of correction to be done like this
- interior design plan
It's available as a Nuget package
How to parse a pdf or svg and get it returned as drawio:
var drawIo = new Bygdrift.PdfToDrawio.Convert("SomeContent.pdf"); //or svg
//var drawIo = new Bygdrift.PdfToDrawio.Convert(stream, Bygdrift.PdfToDrawio.Format.PDF); //It can also be loaded as a stream
drawIo.ToDrawIo("someContent.drawio");
var stream = drawIo.ToDrawIo();
How to parse a pdf or svg and get it returned as xml:
var drawIo = new Bygdrift.PdfToDrawio.Convert("SomeContent.pdf"); //or svg
//var drawIo = new Bygdrift.PdfToDrawio.Convert(stream, Bygdrift.PdfToDrawio.Format.PDF); //It can also be loaded as a stream
drawIo.ToMxGraphModel("someContent.xml");
var stream = drawIo.ToMxGraphModel();
The imported pdf can consist of multiple pages.
This project can be tested by downloading it and run the unit test PdfToDrawioTests.ConvertTests.ConvertPdf()
.
Personally, I will build a function app to Azure, as an http-trigger, that consist of a simple front end html, that can be integrated on an organisations intranet, so people can search and find a pdf from a FM-system. Then they can choose, either to download the pdf or a drawio-file.
It should be possible to add headers and footers to each page, and I will be working on a better help to users that doesn't know drawio. So if they are making an evacuation map, they can read in a "Howto get started"-shape on the fist page and some help to find a shape library for evacuation maps from their own organization.