This week I worked on exploring python library that could be helpful with my project found some called Vpype and Pdf2Svg.


I used Pdf2Svg python library to convert an PDF file to SVG, then took that SVG file and convert it Gcode using Vpype-Gcode Python library.
if file and allowed_file(file.filename, ["pdf"]):
filename = secure_filename(file.filename)
file.save(os.path.join(app.config["TEXT_FOLDER"], filename))
subprocess.run(["pdf2svg",(os.path.join(app.config["TEXT_FOLDER"], filename)),(os.path.join(app.config["TEXT_FOLDER"], filename[:-4]+ "resized.svg"))])
subprocess.run(["vpype", "read", (os.path.join(app.config["TEXT_FOLDER"], filename[:-4]+ "resized.svg")), "gwrite", "--profile", "gcode", (os.path.join(app.config["GCODE_FOLDER"], "pervious.gcode"))])
flash("Text file has been Uploaded Successfully.")
else:
flash("Invalid file format. Only .pdf files are allowed.")
Sources
Comments