User Tools

Site Tools


ai-pdf-genration-english

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
ai-pdf-genration-english [2026/10/12 13:53] – misaai-pdf-genration-english [2026/10/12 15:50] (current) – [2. How it works under the hood] misa
Line 1: Line 1:
-= Generating Professional PDF Reports from Excel Files Using AI (=builder)=+====== AI-Generated PDF Reports from Excel – How-To & SOP ======
  
-//Last updated: 12.10.2026 // +> **TL;DR:** Upload the .xlsx (as attachment, or place it in ''/home/user/Documents/inbox'') → tell the AI in one clear message what to build and where to save it → let it read and summarize the file first → review the generated PDF page by page → iterate with short fix requests → clean up temp files when done. **One project per chat**, delete chats you no longer need.
-//Owner: [Hrishabh] // +
-//Status: Production-Ready //+
  
-----+===== 1. What is possible =====
  
-== 1. Purpose ==+The AI assistant runs in a Linux environment and can turn a raw Excel export into a finished, presentation-ready A4 PDF report without any manual layout work: cover page, KPI dashboard, charts, formatted tables, status badges, page footers with page numbers – in the language of the data (German or English). It works best when the Excel file contains structured lists with status columns, areas, quantities or references.
  
-This document explains the repeatable process for converting raw Excel workbooks (e.g. camera inventory lists, status-quo tracking sheets) into **professional, presentation-ready PDF reports** using the AI assistant **"builder"**. No local Python environment, no design tools, and no manual layout work is required — the AI reads the data, analyses it, generates charts, and produces a print-ready A4 PDF in a single session.+===== 2. How it works under the hood =====
  
-----+^  Component                        ^    Role                                                            ^ 
 +| ''openpyxl'' / ''pandas'' (Python) | Reads the .xlsx: values, sheet structure, cell colors/legend      | 
 +| ''matplotlib''                     | Builds the charts (donut, bar charts, timelines) as image files   | 
 +| HTML/CSS + ''WeasyPrint''          | Lays out real A4 pages and renders them into the final PDF (cover,                 footers, page x of y)                                                                                    | 
 +| ''pdftoppm'' (poppler)             | Renders PDF pages back to images so the AI can visually inspect its own output before handover                                                                               |
  
-== 2. Prerequisites ==+The standard pipeline: **read → understand → summarize → build charts → build HTML report → render PDF → verify pages → iterate on feedback.**
  
-^ Requirement ^ Details ^ 
-| **AI tool** | "builder" (web-based AI assistant with file-reading + code-execution capability) | 
-| **Source file** | An `.xlsx` workbook with the data to be reported (one sheet, structured rows/columns) | 
-| **Access to output folder** | `/home/user/Documents/generatedpdf/` (or any writable path) | 
-| **Internet connection** | Required for the builder session | 
-| **No local installs needed** | Python, openpyxl, matplotlib, and WeasyPrint are installed in the builder environment | 
  
----- 
  
-== 3. Process Overview ==+===== 3. Prerequisites =====
  
-The full workflow takes **5–10 minutes** per report from file upload to finished PDF:+* The Excel file (.xlsx), ideally one sheet per topic 
 +* A fixed output folder and filename, e.g. ''/home/user/Documents/generatedpdf/<name>.pdf'' 
 +* A decision: report language (data in German → report in German) 
 +* Optional: brand colors or a logo image you want on the cover
  
-    ┌──────────────┐     ┌──────────────────┐     ┌─────────────────┐     ┌──────────┐ +===== 4. Step-by-step workflow =====
-    │  1. Upload   │ ──▶ │  2. Instruct     │ ──▶ │  3. AI reads &  │ ──▶ │  4. Get  │ +
-    │  Excel file  │     │  (prompt + specs)│     │  generates PDF  │     │  the PDF │ +
-    └──────────────┘     └──────────────────┘     └─────────────────┘     └──────────┘+
  
-**Step-by-step:**+- **Step 1 – Upload the file.** Attach the .xlsx to the chat. If the AI reports it cannot find the file on disk, copy it into ''/home/user/Documents/inbox'' (this actually happened in Case Study B and cost one round trip). 
 +- **Step 2 – Send the initial prompt** (Section 5, Prompt A or B). Always include: what to do + exact target folder + filename. 
 +- **Step 3 – Let it read first.** The AI dumps the workbook structure, identifies sections/statuses/counts and summarizes them back to you. Check that summary – correcting understanding here is much cheaper than correcting a finished PDF. 
 +- **Step 4 – Generation.** Charts are generated, the report is laid out (cover, dashboard, sections, detail tables, open items), and the PDF is rendered into your target folder. 
 +- **Step 5 – Page-by-page review.** The AI renders pages to images and shows you key pages (cover, summary, charts, tables, final page). Look at: totals, spellings, colors, missing rows. 
 +- **Step 6 – Iterate with short fix prompts** (Section 5, Prompt C). Typical fixes: wrong total in a chart, typo, extra section, color change, logo. 
 +- **Step 7 – Handover & cleanup.** Confirm the file location, then ask the AI to delete its temporary files (Section 5, Prompt D).
  
-# **Upload** the `.xlsx` file as an attachment in the chat (paperclip icon). +===== 5. Prompt library (copy & paste) =====
-# **Describe** what you want in plain language — see §5 for proven prompt templates. +
-# The AI **reads every row and column**, detects structure, categories, statuses, and dates automatically. +
-# The AI **generates charts** (donut, bar, timeline) and a full HTML/CSS report layout. +
-# The AI **renders the PDF** (A4, with cover page, headers, footers, page numbers) into the target folder. +
-# You **receive the PDF** as a clickable file link — download or forward to your customer.+
  
-----+**Prompt A – initial request, new report:** 
 +<code> 
 +Read the attached Excel file "NAME_OF_FILE.xlsx". It is written in German. 
 +Before building anything, summarize what you understand: sheets, key columns, 
 +statuses, and all relevant counts – I will confirm before you proceed. 
 +Then create a professional customer-presentation PDF based on it with: 
 +cover page with key numbers, summary dashboard with KPI cards, charts, 
 +clean detail tables, status badges, and a footer with page numbers. 
 +Save the result to: /home/user/Documents/generatedpdf/REPORTNAME.pdf 
 +</code>
  
-== 4. Worked Examples ==+**Prompt B – new file, same style as before:** 
 +<code> 
 +I uploaded a new Excel file "NAME_OF_FILE.xlsx". Read it and understand the content first. 
 +Create a professional PDF report (same style as the last one: cover, KPI dashboard, 
 +charts, tables, open-items section with recommended actions). 
 +Save it to /home/user/Documents/generatedpdf/ with exactly the same name as the Excel file. 
 +</code>
  
-=== Example A: "AS von Status Quo.xlsx" → Status-Quo-Bericht ===+**Prompt C – fixes / iterations (one issue per message works best):** 
 +<code> 
 +Page 3, chart "Kameras nach Bereich": the numbers do not add up to the total (342). 
 +Fix the chart so all categories are included and re-render the PDF. 
 +</code>
  
-* **Source data:** 152 camera positions across 3 video systems (Video 1/2/3), color-coded by source (RE 1309, RE 1296, AN 1801, AN 1940, Alt Bestand, Parkraumüberwachung), with German status notes ("montiert aber nicht im System", "BEHOBEN AM 24.07.2026", etc.) +<code> 
-* **Output:** 16-page PDF — `StatusQuo_Bericht_Kundenvorstellung.pdf` +Change the accent color on the cover to #1a5d9e and shorten the subtitle text. 
-* **Contents:** +</code>
- * Cover page with KPIs (152 positions, 9 halls, 28 defects fixed, open items) +
- * Executive summary with donut chart (OK / Behoben / Offen) +
- * Distribution charts by hall and by camera source +
- * Full detail tables per video system with color-coded status pills +
- * Open-items table + AN-1940 order positions + KFZ recognition gaps +
- * 4-step action plan for the customer+
  
-=== Example B: "Kamera Netzwerkliste.xlsx" → Systemstatus-Bericht ===+<code> 
 +Add our company logo (attached) to the top-left of the cover page. 
 +</code>
  
-* **Source data:** 342 NVR camera entries (name, channel IP, device IP, area, firmware, model, network status, video signal, recording status, image diagnosis, arm status) +**Prompt D – cleanup after handover:** 
-* **Output:** 22-page PDF — `Kamera Netzwerkliste.pdf` +<code> 
-* **Contents:** +The report is final. Delete all temporary files you created for it (chart images, 
- * Cover page with KPIs (342 cameras, 98.8% online, 7 NVRs, 4 offline) +HTML, scripts, page previews) and confirm that only the final PDF remains in 
- * Executive summary with status donut + key messages +/home/user/Documents/generatedpdf. 
- * Area distribution chart (WA außen 84, WE außen 76, Hallen 1–9, …) +</code>
- * NVR infrastructure table (7 recorders with IP, model, firmware, camera count) +
- * **Complete 342-row camera list** with per-camera status pills +
- * Offline-cameras table with recommended remediation steps+
  
-----+===== 6. Case studies =====
  
-== 5. Prompt Templates (Copy & Paste) ==+==== 6.1 "AS von Status Quo.xlsx" → Status-Quo-Bericht ====
  
-> **Tip:** The more specific your prompt, the better the first result. You can always iterate with follow-up messages ("change the color", "add a logo placeholder", "make section 3 shorter").+| ^^Item^^ | ^^Value^^ 
 +| Source file | ''AS von Status Quo.xlsx'' (sheet "Tabelle1", 90 columns, German) 
 +| Output | ''/home/user/Documents/generatedpdf/StatusQuo_Bericht_Kundenvorstellung.pdf'' – 16 pages 
 +| Content | 152 camera positions across Video 1 / Video 2 / Video 3 + parking items, halls 1–9 plus outdoor areas 
 +| Status mix | 106 in operation · 28 defects fixed (22.–29.07.2026) · 12 mounted but not in system · 4 open orders (AN 1940) · 2 missing vehicle recognition 
 +| Highlights | Color legend taken 1:1 from the sheet (RE 1309 yellow, AN 1940 green, RE 1296 orange, AN 1801 blue, Bestand grey, Parkraumüberwachung purple); "Behoben" dates extracted per position; contradictory notes (KFZ-Kennung fehlt vs. vorhanden) flagged for on-site clarification instead of silently dropped 
 +| Lessons | The AI caught two of its own typos and a misclassified status only because pages were visually checked; always review cover + dashboard + at least one detail page
  
-=== 5.1 Basic report generation ===+==== 6.2 "Kamera Netzwerkliste.xlsx" → Kamera Netzwerkliste.pdf ====
  
-    Read this Excel file. It is in [German/English]. Create a professional +| ^^Item^^ | ^^Value^^ 
-    PDF report for customer presentation. Save it to /home/user/Documents/ +| Source file | ''Kamera Netzwerkliste.xlsx'' (sheet "Kamera", 342 camera rows) 
-    generatedpdf/ with the same base name as the Excel file (e.g. "MyReport.pdf"). +| Output | ''/home/user/Documents/generatedpdf/Kamera Netzwerkliste.pdf'' – 22 pages, same name as the Excel file as requested 
-    Include: cover page, executive summary with KPIs, charts, detail tables, +| Content | 342 cameras on 7 NVRs across 16 areas; 338 online & recording (98.8 %), 4 offline (parking/outdoor cams); firmware mix: 250 on V5 recorders, 92 on older V4 units flagged for modernization 
-    and an open-items / action-plan section. The report must be in [German/English].+| Highlights | Cover KPIs, status donut, area + model charts, full NVR infrastructure table with IPs, complete list of all 342 cameras, offline-cam action table with recommended fixes 
 +| Lessons | The first upload did **not** land on the server disk (only a preview was visible). Solution: asked to re-upload; the file then appeared in ''/home/user/Documents/inbox''. → Always verify with the AI that it can actually read the file before starting.
  
-=== 5.2 With specific design requirements ===+===== 7. Checklist for a professional look =====
  
-    Read the attached Excel file and generate a customer-facing PDF report. +* Cover page: title, subtitle, 3–4 KPI chips, date + document meta 
-    Requirements: +* Dashboard: big number cards + one status donut chart 
-    - Language: German +* Charts must sum to the total row count – **always verify** (real bug caught in Case Study B) 
-    - A4 format, professional corporate look (dark navy + gold accent) +* Status colors stay consistent with the source legend; use badges/pills for table statuses 
-    - Cover page with title, KPI cards, date +* Page footer with report name and "Seite x von y" 
-    - Donut chart for status overview +* Source reference at the end: document name, sheet, export date/time, author 
-    - Bar charts for distribution by [area / hall / department] +* One coherent palette (navy + one accent color worked well here)
-    - Full detail table with all rows from the sheet +
-    - Color-coded status pills: green = OK, red = open issue, blue = resolved +
-    - Page footer with document name + page number +
-    - Save to: /home/user/Documents/generatedpdf/[Name].pdf+
  
-=== 5.3 Iteration / correction ===+===== 8. Context management & cleanup – important =====
  
-    The report looks good. Please fix the following: +> **WARNING:** Every message, attachment and tool output inside a chat eats into the shared context window of that chat. A long-running chat with several big Excel files, many page previews and repeated regenerations will eventually hit the limit: responses get slower, older instructions are forgotten, and new uploads may not fit at all. Manage this **before** it happens:
-    1. Change "Fehlkkanäle" to "Fehlkanäle" (typo) +
-    2. Position 39 is already resolved — move it from "Offen" to "Behoben" +
-    3. Add a section 6 with recommended next steps as numbered action items +
-    Regenerate the PDF in the same location.+
  
-----+* **One project per chat.** Start a fresh chat for every new Excel/report. Do not continue an old 20-message chat with a completely new file. 
 +* **Delete chats you no longer need** (you do this in the app UI – the AI cannot delete your own chat history). Unused chats are a wasted resource and clutter. 
 +* **Clean up generated temp files after handover.** Ask the AI (Prompt D) to remove chart PNGs, HTML and page previews it created. Do not let 10+ preview images and intermediate files accumulate in the working folder or get re-read into the chat later. 
 +* **Attach each file only once per project.** Re-uploading a slightly edited version of the same big Excel is one of the fastest ways to blow up the context. If the data changed significantly, prefer a new chat. 
 +* **Keep the Excel slim:** delete unused sheets/hidden columns before uploading if you can – the AI reads the whole workbook. 
 +* **State your target once, precisely** (absolute folder + exact filename) in the first prompt; vague requests cause extra rounds of back-and-forth, and every round costs context. 
 +* **Overwrite the same output file** instead of producing v1/v2/v3 copies. 
 +* **If a chat starts to feel heavy** (slow answers, forgotten instructions), stop iterating and hand over: ask the AI for a short state summary, then continue in a new chat with something like: 
 +<code> 
 +State summary for continuation: 
 +Project: camera network report. Source: Kamera Netzwerkliste.xlsx. 
 +Output: /home/user/Documents/generatedpdf/Kamera Netzwerkliste.pdf (22 pages, final except cover logo). 
 +Next step: add our company logo to the cover page only. 
 +</code> 
 +* **Do not paste huge text dumps** (full console output, entire HTML) into the chat. If something went wrong, describe the symptom in 1–2 sentences and point at the file/page – let the AI read the file itself.
  
-== 6. What the AI Can and Cannot Do (Limitations) ==+===== 9. Troubleshooting =====
  
-=== Capabilities === +| ^^Symptom^^ | ^^Fix^^ 
-* Read `.xlsx` files (all sheets, all cells, including merged cells and cell fills/colors) +| AI cannot find the uploaded file on disk | Re-upload as attachment, or copy it into ''/home/user/Documents/inbox''; ask the AI to confirm it can read the file 
-* Detect structure: headers, data rows, sections, color-coded categories +| Wrong totals / chart doesn't add up | Ask: "cross-check every chart total against the table row count and fix"; show the affected page 
-* Parse German / English / mixed-language content +| PDF looks plain for a customer meeting | Request: cover + KPI dashboard + donut/bar charts + status badges + footer with page numbers 
-* Generate matplotlib charts (donut, bar, timeline, stacked) +| Detail row missing or misread | Point at the exact row in the source Excel (row number + column) and describe what the AI must show 
-* Render full HTML/CSS → PDF via WeasyPrint (A4, multi-page, cover, footers) +| Chat becomes slow or forgets instructions | Fresh chat + state summary (Section 8); delete old unused chats 
-* Handle 150–350+ row datasets in a single pass +| German characters wrong | Should work out of the box (UTF-8, DejaVu fonts); if not, report it together with a page screenshot
-* Apply your color palette and brand colors from the Excel legend +
-* Write report text in German or English (or both) +
- +
-=== Limitations === +
- +
-^ Limitation ^ Workaround ^ +
-| **Cannot browse your file server** — uploaded files only land in `/tmp` or `inbox/` | Upload the file as a chat attachment, or place it in `/home/user/Documents/inbox/` | +
-| **Cannot access live systems** (NVR, CRM, ERP) | Export the data to Excel first, then upload | +
-| **No image/photo support** from Excel (e.g. camera snapshots embedded in cells) | Provide photos as separate attachments if needed | +
-| **Charts are matplotlib PNGs** — not interactive SVG/HTML charts | Acceptable for print PDFs; for web, request HTML export instead | +
-| **One session = one context window** — very large workbooks (10k+ rows) may need splitting | Split the Excel into per-area/per-hall files, or ask the AI to process in batches |+
  
 ---- ----
- +//Author: <your name> · Version 1.0 · 2026-10-12 • Internal SOP – AI-generated PDF reports from Excel//
-== 7. Troubleshooting == +
- +
-=== Problem: "File not found on disk" === +
-The attachment did not land where the AI expected it. **Fix:** +
-# Ask the AI to run `find / -iname "*.xlsx"` and confirm the path. +
-# If it's in `/home/user/Documents/inbox/` instead of `/tmp/`, tell the AI the correct path. +
-# Worst case: re-upload the attachment in the same chat. +
- +
-=== Problem: AI misread a column or mixed up two columns === +
-**Fix:** Point to the specific row/column: +
- +
-    In row 14, column H says "montiert aber nicht im System" — that position +
-    should be listed as OPEN, not OK. Please re-check the status classification +
-    and regenerate the table. +
- +
-=== Problem: Chart numbers don't add up === +
-**Fix:** Ask the AI to print the per-category counts before generating the chart: +
- +
-    Before you render the donut chart, print the exact count for each category +
-    so I can verify the total equals 342. +
- +
-=== Problem: PDF has a layout glitch (text overflow, missing page) === +
-**Fix:** Request a targeted re-render: +
- +
-    Page 8 has text overflowing in the "Kamerabezeichnung" column. +
-    Reduce the font size of that table to 7pt and widen the name column to 32%. +
-    Regenerate only pages 6–14. +
- +
-=== Problem: Wrong date or wrong language === +
-**Fix:** Explicitly state in your prompt: "Report language: German. Report date: [DD.MM.YYYY]." +
- +
----- +
- +
-== 8. ⚠️ Context Size Management — READ BEFORE EACH SESSION == +
- +
-> **This is the single most important section. Ignoring it will cause failed sessions, truncated outputs, and lost work.** +
- +
-=== 8.1 Why context size matters === +
-Every message you send, every file the AI reads, and every response the AI generates all consume a **shared context window** (a finite token budget). Once the window is full: +
-* The AI starts **forgetting earlier instructions** ("amnesia") +
-* Long outputs get **truncated mid-sentence** +
-* File reads return **partial data** +
-* In worst case, the session **errors out** and you must restart +
- +
-=== 8.2 Rules to follow (non-negotiable) === +
- +
-# **Delete generated files after downloading.** Every PDF, PNG, or HTML file left in the workspace can be re-read into the context if you ask the AI to inspect them again. Once you have your PDF, clean up: +
-    rm /home/user/Documents/generatedpdf/OldReport.pdf +
-    rm /tmp/*.png /tmp/*.html +
- +
-# **Start a NEW chat for each new report.** Do not chain 5 different Excel reports into one conversation. Each report is a self-contained task. A fresh chat = full context budget. +
- +
-# **Do NOT upload the same file twice.** If you already attached `Report.xlsx` and the AI read it, do not re-attach it "just in case". The AI already has it in memory. +
- +
-# **Delete unused / finished chats regularly.** Old conversations stay stored server-side and can bloat your account's context history. In the chat list: +
- * Go to each completed chat → **Delete chat** (or "Archive" if available). +
- * Keep only the 1–2 active conversations. +
- +
-# **Keep prompts focused.** One report per message. Don't paste in 500 lines of extra context, screenshots, and "by the way also…" all in one prompt. +
- +
-# **If a session feels "sluggish" or the AI repeats itself**, that's the context window filling up. **Stop, save your work, delete temp files, and start a new chat.** +
- +
-=== 8.3 Quick "before I start a new report" checklist === +
- +
-    [ ] Downloaded & verified the last PDF? +
-    [ ] Deleted /tmp/*.png, /tmp/*.html, old .pdf from workspace? +
-    [ ] Closed or deleted all other finished chats? +
-    [ ] New chat opened? +
-    [ ] Excel file attached ONCE? +
-    [ ] Prompt written with: language, output path, section list, style? +
- +
----- +
- +
-== 9. Additional Tips & Best Practices == +
- +
-* **Name your files clearly.** `Kamera Netzwerkliste.pdf` is better than `report_final_v3_actual.pdf`. The AI uses the Excel filename as the PDF name by default. +
-* **Keep the Excel clean.** Remove hidden columns, stray rows, and merged header cells before uploading — it reduces misinterpretation risk. +
-* **Use the color legend in your sheet.** If row 1 contains a color key ("Gelb: RE 1309, Grün: AN 1940…"), the AI will pick it up and use those exact colors in the report automatically. +
-* **Ask for a "dry run" on large files first:** +
-    Before generating the PDF, just list the categories and counts you detected +
-    so I can verify the structure is correct. +
-* **Version control your reports.** After each generation, copy the PDF to a dated subfolder: +
-    mkdir -p /home/user/Documents/generatedpdf/archive/2026-10 +
-    cp "/home/user/Documents/generatedpdf/Kamera Netzwerkliste.pdf" \ +
-       /home/user/Documents/generatedpdf/archive/2026-10/ +
-* **For recurring reports** (monthly camera status), save your prompt as a DokuWiki snippet or text file so you never have to rewrite it. +
-* **The AI cannot see what is NOT in the Excel.** If a camera was removed on Monday, the report reflects the Excel — not the live system. Always export fresh data. +
- +
----- +
- +
-== 10. File Locations Quick Reference == +
- +
-^ Path ^ Purpose ^ +
-| `/home/user/Documents/generatedpdf/` | **Output folder** for all generated PDFs | +
-| `/home/user/Documents/inbox/` | Staging area — drop Excel files here if attachment upload fails | +
-| `/tmp/AS.xlsx`, `/tmp/cams.json`, etc. | AI working files (charts, parsed JSON) — **safe to delete after each session** | +
- +
----- +
- +
-== 11. Revision History == +
- +
-^ Date ^ Author ^ Change ^ +
-| 12.10.2026 | [Hrishabh] | Initial version: process, examples A+B, prompts, context management guide | +
- +
----- +
- +
-//Questions or improvements? → [[team:ai-tooling:feedback]] //+
ai-pdf-genration-english.1791813197.txt.gz · Last modified: by misa