Tools.PdfToDrawio
Convert a pdf or svg to a diagrams.net-file - also called drawio.
Install / Use
/learn @Bygdrift/Tools.PdfToDrawioREADME
PdfToDrawio
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
The code
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().
Inspiration on how to use the project
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.
Whats next
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.
Related Skills
node-connect
345.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
104.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
345.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
345.4kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
