An open API service indexing awesome lists of open source software.

https://github.com/san-soni30/filetocanvas

A lightweight web tool to convert images and PDFs into Fabric.js canvas code. Supports base64 or URL embedding with live preview and export. Built with HTML, JavaScript, Bootstrap, Fabric.js, and PDF.js.
https://github.com/san-soni30/filetocanvas

bootstrap5 git github html-css-javascript

Last synced: 2 months ago
JSON representation

A lightweight web tool to convert images and PDFs into Fabric.js canvas code. Supports base64 or URL embedding with live preview and export. Built with HTML, JavaScript, Bootstrap, Fabric.js, and PDF.js.

Awesome Lists containing this project

README

          

# ๐ŸŽจ File to Canvas.js Converter

Convert PNG, JPEG, or PDF files into a **Canvas.js** (Fabric.js) object and view the generated code for easy use in your web projects.
This tool also supports **AI-powered image generation** through an integrated **n8n workflow**, allowing you to generate visuals from text prompts directly on the canvas.

---

## ๐Ÿš€ Features

- ๐Ÿ–ผ Upload image files (`.png`, `.jpg`, `.jpeg`) or PDF documents.
- ๐Ÿค– Generate images from text prompts via **n8n workflow** integration.
- ๐Ÿ“„ Render files directly onto an HTML5 `` using **Fabric.js**.
- ๐Ÿ’ป Export canvas state as **Canvas.js code** (JSON format).
- ๐Ÿ”— Option to embed images as **base64** or external URL.
- ๐Ÿ“‹ Copy or clear generated code easily from the UI.
- ๐Ÿงผ Clean **Bootstrap 5.3 UI** with responsive layout.

---

## ๐Ÿ“‚ File Structure

file-to-canvasjs-converter/
โ”‚
โ”œโ”€โ”€ index.html # Main HTML structure
โ”œโ”€โ”€ style.css # Custom styles
โ”œโ”€โ”€ app.js # Core logic (Fabric.js, PDF.js, n8n workflow integration)
โ””โ”€โ”€ README.md # Project documentation

---

## ๐Ÿ“ธ Screenshot

![Preview](image.png)

---

## ๐Ÿงฐ Technologies Used

- **HTML5, CSS3, JavaScript (ES6)**
- [Bootstrap 5.3](https://getbootstrap.com/)
- [Fabric.js 5.3](http://fabricjs.com/)
- [PDF.js](https://mozilla.github.io/pdf.js/)
- **n8n** for AI image generation workflow

---

## ๐Ÿ”ง How It Works

1. **Upload File**: Choose any supported file type (`.png`, `.jpg`, `.jpeg`, `.pdf`).
2. **Generate Image**: (Optional) Enter a text prompt and generate an image via **n8n workflow**.
3. **Preview Canvas**: The canvas displays the uploaded background image, first page of a PDF, or generated AI image.
4. **Generate Code**: Click **"Generate Code"** to view the `canvas.loadFromJSON()` object.
5. **Copy/Use Code**: Toggle the **base64** option or copy the code to reuse in your projects.

---

## ๐Ÿ“ฆ Setup

1. Clone or download this repository:
- git clone https://github.com/san-soni30/FileToCanvas.git

2. Open `index.html` in your browser.
3. Upload a file or generate an AI image, then generate Canvas.js code for your projects.

---

## โš ๏ธ Notes

* PDF rendering only displays the **first page**.
* Image background is scaled to fit the canvas.
* Use the **Include Base64** checkbox to decide how the image is embedded.
* n8n workflow requires a configured webhook endpoint for AI image generation.

---

## ๐Ÿ™Œ Contributions

Pull requests and improvements are welcome! If you'd like to add more file format support, AI features, or workflow enhancements, feel free to fork this project.

---

## ๐ŸŽฅ Demo

๐ŸŒ [Watch Live Demo](https://youtu.be/7ngcZvR5Jd8)

---

Happy coding! ๐Ÿ’ปโœจ