### Setup and Export DOCX Source: https://github.com/tfriedel/claude-office-skills/blob/main/public/docx/docx-js.md Imports necessary components from the docx library and shows how to create a document buffer for Node.js or a blob for browser downloads. Assumes the docx library is installed globally. ```javascript const { Document, Packer, Paragraph, TextRun, Table, TableRow, TableCell, ImageRun, Media, Header, Footer, AlignmentType, PageOrientation, LevelFormat, ExternalHyperlink, InternalHyperlink, TableOfContents, HeadingLevel, BorderStyle, WidthType, TabStopType, TabStopPosition, UnderlineType, ShadingType, VerticalAlign, SymbolRun, PageNumber, FootnoteReferenceRun, Footnote, PageBreak } = require('docx'); // Create & Save const doc = new Document({ sections: [{ children: [/* content */] }] }); Packer.toBuffer(doc).then(buffer => fs.writeFileSync("doc.docx", buffer)); // Node.js Packer.toBlob(doc).then(blob => { /* download logic */ }); // Browser ``` -------------------------------- ### Complete html2pptx and PptxGenJS Example Source: https://github.com/tfriedel/claude-office-skills/blob/main/public/pptx/html2pptx.md A full example showing the initialization of pptxgen, conversion of multiple HTML slides using html2pptx, adding a chart to a placeholder, and saving the presentation. ```javascript const pptxgen = require('pptxgenjs'); const html2pptx = require('./html2pptx'); async function createPresentation() { const pptx = new pptxgen(); pptx.layout = 'LAYOUT_16x9'; pptx.author = 'Your Name'; pptx.title = 'My Presentation'; // Slide 1: Title const { slide: slide1 } = await html2pptx('slides/title.html', pptx); // Slide 2: Content with chart const { slide: slide2, placeholders } = await html2pptx('slides/data.html', pptx); const chartData = [{ name: 'Sales', labels: ['Q1', 'Q2', 'Q3', 'Q4'], values: [4500, 5500, 6200, 7100] }]; slide2.addChart(pptx.charts.BAR, chartData, { ...placeholders[0], showTitle: true, title: 'Quarterly Sales', showCatAxisTitle: true, catAxisTitle: 'Quarter', showValAxisTitle: true, valAxisTitle: 'Sales ($000s)' }); // Save await pptx.writeFile({ fileName: 'presentation.pptx' }); console.log('Presentation created successfully!'); } createPresentation().catch(console.error); ``` -------------------------------- ### Install Python and Node.js Dependencies Source: https://github.com/tfriedel/claude-office-skills/blob/main/README.md Install necessary Python and Node.js packages for the Office document skills. Ensure system tools like LibreOffice, Poppler, and Pandoc are also available. ```bash # Python dependencies virtualenv/bin/pip install -r requirements.txt # Node.js dependencies (for html2pptx) npm install # System tools (usually pre-installed) # - LibreOffice (soffice) # - Poppler (pdftoppm) # - Pandoc ``` -------------------------------- ### OOXML Text Formatting Examples Source: https://github.com/tfriedel/claude-office-skills/blob/main/public/docx/ooxml.md Demonstrates how to apply bold, italic, underline, and highlight formatting to text within a run. ```xml Bold Italic Underlined Highlighted ``` -------------------------------- ### Example: Create Presentation from Template Source: https://github.com/tfriedel/claude-office-skills/blob/main/README.md Demonstrates a two-step process for creating a presentation from a template using command-line scripts. First, extract template text, then generate thumbnails for review. ```bash # 1. Extract template text virtualenv/bin/python -m markitdown template.pptx # 2. Generate thumbnails virtualenv/bin/python public/pptx/scripts/thumbnail.py template.pptx outputs/sales-deck/thumbnails ``` -------------------------------- ### Application Properties in OOXML Source: https://github.com/tfriedel/claude-office-skills/blob/main/public/pptx/ooxml.md Example of `app.xml` content showing slide count and basic statistics for the presentation. ```xml 2 10 50 ``` -------------------------------- ### Install Node.js Dependencies Source: https://github.com/tfriedel/claude-office-skills/blob/main/CLAUDE.md Install Node.js dependencies, including the Playwright Chromium browser, for JavaScript-based workflows like html2pptx. ```bash npm install ``` -------------------------------- ### Text Formatting: Complete Example XML Source: https://github.com/tfriedel/claude-office-skills/blob/main/public/pptx/ooxml.md A comprehensive example of text formatting, including language, size, bold attribute, and a light gray color fill. Includes the 'dirty="0"' attribute for clean state. ```xml Formatted text ``` -------------------------------- ### Basic PDF Creation with reportlab Source: https://github.com/tfriedel/claude-office-skills/blob/main/public/pdf/SKILL.md Create a simple PDF document with text and a line using the reportlab library. This is a foundational example for PDF generation. ```python from reportlab.lib.pagesizes import letter from reportlab.pdfgen import canvas c = canvas.Canvas("hello.pdf", pagesize=letter) width, height = letter # Add text c.drawString(100, height - 100, "Hello World!") c.drawString(100, height - 120, "This is a PDF created with reportlab") # Add a line c.line(100, height - 140, 400, height - 140) # Save c.save() ``` -------------------------------- ### Convert HTML to PPTX Source: https://github.com/tfriedel/claude-office-skills/blob/main/CLAUDE.md Converts HTML files into a PowerPoint presentation using the html2pptx.js library. Requires Node.js to be installed. ```bash node script.js # Uses html2pptx.js library ``` -------------------------------- ### Configure Document with Headers, Footers, and Page Setup Source: https://github.com/tfriedel/claude-office-skills/blob/main/public/docx/docx-js.md Set up a new document with custom page margins, landscape orientation, and page numbering. Includes default headers and footers with current and total page numbers. ```javascript const doc = new Document({ sections: [{ properties: { page: { margin: { top: 1440, right: 1440, bottom: 1440, left: 1440 }, // 1440 = 1 inch size: { orientation: PageOrientation.LANDSCAPE }, pageNumbers: { start: 1, formatType: "decimal" } // "upperRoman", "lowerRoman", "upperLetter", "lowerLetter" } }, headers: { default: new Header({ children: [new Paragraph({ alignment: AlignmentType.RIGHT, children: [new TextRun("Header Text")] })] }) }, footers: { default: new Footer({ children: [new Paragraph({ alignment: AlignmentType.CENTER, children: [new TextRun("Page "), new TextRun({ children: [PageNumber.CURRENT] }), new TextRun(" of "), new TextRun({ children: [PageNumber.TOTAL_PAGES] })] })] }) }, children: [/* content */] }] }); ``` -------------------------------- ### Install Python Dependencies Source: https://github.com/tfriedel/claude-office-skills/blob/main/CLAUDE.md Install or update Python dependencies required for the repository's scripts. Always use the venv/bin/pip command. ```bash venv/bin/pip install -r requirements.txt ``` -------------------------------- ### HTML Slide Template for html2pptx Source: https://context7.com/tfriedel/claude-office-skills/llms.txt This is an example HTML structure for creating slides compatible with the `html2pptx` utility. Ensure the body dimensions match the `pptx.layout` setting and use `div.placeholder` for chart/table injection areas. Note the comment regarding `
` usage. ```html

Sales Results

``` -------------------------------- ### Template Inventory Structure Source: https://github.com/tfriedel/claude-office-skills/blob/main/public/pptx/SKILL.md This is an example structure for a template inventory Markdown file. It should list all slides with their index, layout code, and a description. ```markdown # Template Inventory Analysis **Total Slides: [count]** **IMPORTANT: Slides are 0-indexed (first slide = 0, last slide = count-1)** ## [Category Name] - Slide 0: [Layout code if available] - Description/purpose - Slide 1: [Layout code] - Description/purpose - Slide 2: [Layout code] - Description/purpose [... EVERY slide must be listed individually with its index ...] ``` -------------------------------- ### Compare DOCX Tracked Changes Source: https://github.com/tfriedel/claude-office-skills/blob/main/public/docx/SKILL.md Demonstrates how tracked changes are represented in XML. The 'GOOD' example shows a more granular approach to marking changes compared to the 'BAD' example which replaces an entire sentence. ```xml The term is 30 days.The term is 60 days. ``` ```xml The term is 3060 days. ``` -------------------------------- ### Relationship Definitions in OOXML Source: https://github.com/tfriedel/claude-office-skills/blob/main/public/pptx/ooxml.md Shows example relationship definitions in `presentation.xml.rels` and `slide1.xml.rels` for linking slides, masters, and media files. ```xml ``` ```xml ``` -------------------------------- ### Shape Replacement Structure Example Source: https://github.com/tfriedel/claude-office-skills/blob/main/public/pptx/SKILL.md Demonstrates the JSON structure for specifying text replacements for shapes within a presentation. Shapes not included in this structure will have their text automatically cleared. ```json { "slide-0": { "shape-0": { "paragraphs": [ // Paragraph objects go here ] } // Other shapes on slide-0 will be cleared } } ``` -------------------------------- ### Paragraph Formatting Example Source: https://github.com/tfriedel/claude-office-skills/blob/main/public/pptx/SKILL.md Illustrates the structure for defining paragraphs with various formatting options like text, alignment, bolding, bullets, color, and theme color. Use this structure when providing content for shapes. ```json { "paragraphs": [ { "text": "New presentation title text", "alignment": "CENTER", "bold": true }, { "text": "Section Header", "bold": true }, { "text": "First bullet point without bullet symbol", "bullet": true, "level": 0 }, { "text": "Red colored text", "color": "FF0000" }, { "text": "Theme colored text", "theme_color": "DARK_1" }, { "text": "Regular paragraph text without special formatting" } ] } ``` -------------------------------- ### Convert PPTX to Markdown Source: https://github.com/tfriedel/claude-office-skills/blob/main/public/pptx/SKILL.md Use this command to extract text content from a .pptx file into a markdown format for easier reading and analysis. Ensure markitdown is installed. ```bash python -m markitdown path-to-file.pptx ``` -------------------------------- ### Create DOCX Document with JavaScript Source: https://context7.com/tfriedel/claude-office-skills/llms.txt Uses the 'docx' npm package to generate .docx files from JavaScript. Supports rich formatting, tables, lists, headers, footers, and page numbering. Ensure the 'docx' package is installed. ```javascript const { Document, Packer, Paragraph, TextRun, Table, TableRow, TableCell, Header, Footer, AlignmentType, HeadingLevel, LevelFormat, BorderStyle, WidthType, ShadingType, VerticalAlign, PageNumber, ImageRun } = require('docx'); const fs = require('fs'); const tableBorder = { style: BorderStyle.SINGLE, size: 1, color: "CCCCCC" }; const cellBorders = { top: tableBorder, bottom: tableBorder, left: tableBorder, right: tableBorder }; const doc = new Document({ styles: { default: { document: { run: { font: "Arial", size: 24 } } }, paragraphStyles: [ { id: "Heading1", name: "Heading 1", basedOn: "Normal", next: "Normal", run: { size: 32, bold: true, color: "000000" }, paragraph: { spacing: { before: 240, after: 240 }, outlineLevel: 0 } } ] }, numbering: { config: [{ reference: "bullet-list", levels: [{ level: 0, format: LevelFormat.BULLET, text: "•", alignment: AlignmentType.LEFT, style: { paragraph: { indent: { left: 720, hanging: 360 } } } }] }] }, sections: [{ properties: { page: { margin: { top: 1440, right: 1440, bottom: 1440, left: 1440 } } }, headers: { default: new Header({ children: [ new Paragraph({ alignment: AlignmentType.RIGHT, children: [new TextRun("Company Confidential")] }) ]}) }, footers: { default: new Footer({ children: [ new Paragraph({ alignment: AlignmentType.CENTER, children: [ new TextRun("Page "), new TextRun({ children: [PageNumber.CURRENT] }), new TextRun(" of "), new TextRun({ children: [PageNumber.TOTAL_PAGES] }) ]}) ]}) }, children: [ new Paragraph({ heading: HeadingLevel.HEADING_1, children: [new TextRun("Executive Summary")] }), new Paragraph({ children: [new TextRun("Revenue increased 22% in FY2024.")] }), new Paragraph({ numbering: { reference: "bullet-list", level: 0 }, children: [new TextRun("North America: +18%")] }), new Paragraph({ numbering: { reference: "bullet-list", level: 0 }, children: [new TextRun("EMEA: +31%")] }), new Table({ columnWidths: [4680, 4680], margins: { top: 100, bottom: 100, left: 180, right: 180 }, rows: [ new TableRow({ tableHeader: true, children: [ new TableCell({ borders: cellBorders, width: { size: 4680, type: WidthType.DXA }, shading: { fill: "D5E8F0", type: ShadingType.CLEAR }, children: [new Paragraph({ alignment: AlignmentType.CENTER, children: [new TextRun({ text: "Region", bold: true })] })] }), new TableCell({ borders: cellBorders, width: { size: 4680, type: WidthType.DXA }, shading: { fill: "D5E8F0", type: ShadingType.CLEAR }, children: [new Paragraph({ alignment: AlignmentType.CENTER, children: [new TextRun({ text: "Growth", bold: true })] })] }) ]}), new TableRow({ children: [ new TableCell({ borders: cellBorders, width: { size: 4680, type: WidthType.DXA }, children: [new Paragraph({ children: [new TextRun("North America")] })] }), new TableCell({ borders: cellBorders, width: { size: 4680, type: WidthType.DXA }, children: [new Paragraph({ children: [new TextRun("+18%")] })] }) ]}) ] }) ] }] }); Packer.toBuffer(doc).then(buf => fs.writeFileSync("outputs/report/report.docx", buf)); ``` -------------------------------- ### Initialize and Use html2pptx Source: https://github.com/tfriedel/claude-office-skills/blob/main/public/pptx/html2pptx.md This snippet demonstrates the basic usage of the html2pptx library. It initializes a pptxgenjs presentation, sets the layout, converts an HTML file to a slide, and optionally adds a chart to a placeholder. Finally, it writes the presentation to a file. ```javascript const pptxgen = require('pptxgenjs'); const html2pptx = require('./html2pptx'); const pptx = new pptxgen(); pptx.layout = 'LAYOUT_16x9'; // Must match HTML body dimensions const { slide, placeholders } = await html2pptx('slide1.html', pptx); // Add chart to placeholder area if (placeholders.length > 0) { slide.addChart(pptx.charts.LINE, chartData, placeholders[0]); } await pptx.writeFile('output.pptx'); ``` -------------------------------- ### Python Document Class Initialization Source: https://github.com/tfriedel/claude-office-skills/blob/main/public/docx/ooxml.md Demonstrates various ways to initialize the Document class, including specifying author, initials, track revisions, and custom RSID. ```python # Adjust import path or run with: PYTHONPATH=/path/to/skill python script.py # e.g: from skills.docx.scripts.document import Document, DocxXMLEditor from ... import Document, DocxXMLEditor # Basic initialization (automatically creates temp copy and sets up infrastructure) doc = Document('unpacked') # Customize author and initials doc = Document('unpacked', author="John Doe", initials="JD") # Enable track revisions mode doc = Document('unpacked', track_revisions=True) # Specify custom RSID (auto-generated if not provided) doc = Document('unpacked', rsid="07DC5ECB") ``` -------------------------------- ### Create New Excel File with Formulas and Formatting Source: https://github.com/tfriedel/claude-office-skills/blob/main/public/xlsx/SKILL.md Demonstrates creating a new Excel workbook using openpyxl, adding data, formulas, and applying basic formatting like bold text, background color, and alignment. Column width can also be adjusted. ```python from openpyxl import Workbook from openpyxl.styles import Font, PatternFill, Alignment wb = Workbook() sheet = wb.active # Add data sheet['A1'] = 'Hello' sheet['B1'] = 'World' sheet.append(['Row', 'of', 'data']) # Add formula sheet['B2'] = '=SUM(A1:A10)' # Formatting sheet['A1'].font = Font(bold=True, color='FF0000') sheet['A1'].fill = PatternFill('solid', start_color='FFFF00') sheet['A1'].alignment = Alignment(horizontal='center') # Column width sheet.column_dimensions['A'].width = 20 wb.save('output.xlsx') ``` -------------------------------- ### Text Inventory JSON Structure Source: https://github.com/tfriedel/claude-office-skills/blob/main/public/pptx/SKILL.md This is an example structure of the JSON output from the text inventory script. It details shapes, their properties, and paragraph content on each slide. ```json { "slide-0": { "shape-0": { "placeholder_type": "TITLE", // or null for non-placeholders "left": 1.5, // position in inches "top": 2.0, "width": 7.5, "height": 1.2, "paragraphs": [ { "text": "Paragraph text", // Optional properties (only included when non-default): "bullet": true, // explicit bullet detected "level": 0, // only included when bullet is true ``` -------------------------------- ### Create a Table with Borders and Headers Source: https://github.com/tfriedel/claude-office-skills/blob/main/public/docx/docx-js.md Constructs a table with specified column widths, margins, borders, and header styling. Ensure column widths are set at both the table and cell levels. Use ShadingType.CLEAR to avoid unexpected background colors. ```javascript const tableBorder = { style: BorderStyle.SINGLE, size: 1, color: "CCCCCC" }; const cellBorders = { top: tableBorder, bottom: tableBorder, left: tableBorder, right: tableBorder }; new Table({ columnWidths: [4680, 4680], // ⚠️ CRITICAL: Set column widths at table level - values in DXA (twentieths of a point) margins: { top: 100, bottom: 100, left: 180, right: 180 }, // Set once for all cells rows: [ new TableRow({ tableHeader: true, children: [ new TableCell({ borders: cellBorders, width: { size: 4680, type: WidthType.DXA }, // ALSO set width on each cell // ⚠️ CRITICAL: Always use ShadingType.CLEAR to prevent black backgrounds in Word. shading: { fill: "D5E8F0", type: ShadingType.CLEAR }, verticalAlign: VerticalAlign.CENTER, children: [new Paragraph({ alignment: AlignmentType.CENTER, children: [new TextRun({ text: "Header", bold: true, size: 22 })] })] }), new TableCell({ borders: cellBorders, width: { size: 4680, type: WidthType.DXA }, // ALSO set width on each cell shading: { fill: "D5E8F0", type: ShadingType.CLEAR }, children: [new Paragraph({ alignment: AlignmentType.CENTER, children: [new TextRun({ text: "Bullet Points", bold: true, size: 22 })] })] }) ] }), new TableRow({ children: [ new TableCell({ borders: cellBorders, width: { size: 4680, type: WidthType.DXA }, // ALSO set width on each cell children: [new Paragraph({ children: [new TextRun("Regular data")] })] }), new TableCell({ borders: cellBorders, width: { size: 4680, type: WidthType.DXA }, // ALSO set width on each cell children: [ new Paragraph({ numbering: { reference: "bullet-list", level: 0 }, children: [new TextRun("First bullet point")] }), new Paragraph({ numbering: { reference: "bullet-list", level: 0 }, children: [new TextRun("Second bullet point")] }) ] }) ] }) ] }) ``` -------------------------------- ### Create Complex PDFs from Scratch with pdf-lib Source: https://github.com/tfriedel/claude-office-skills/blob/main/public/pdf/REFERENCE.md Generate a new PDF document from scratch using pdf-lib. Embed standard fonts, add text with styling, draw shapes like rectangles, and create table-like structures. ```javascript import { PDFDocument, rgb, StandardFonts } from 'pdf-lib'; import fs from 'fs'; async function createPDF() { const pdfDoc = await PDFDocument.create(); // Add fonts const helveticaFont = await pdfDoc.embedFont(StandardFonts.Helvetica); const helveticaBold = await pdfDoc.embedFont(StandardFonts.HelveticaBold); // Add page const page = pdfDoc.addPage([595, 842]); // A4 size const { width, height } = page.getSize(); // Add text with styling page.drawText('Invoice #12345', { x: 50, y: height - 50, size: 18, font: helveticaBold, color: rgb(0.2, 0.2, 0.8) }); // Add rectangle (header background) page.drawRectangle({ x: 40, y: height - 100, width: width - 80, height: 30, color: rgb(0.9, 0.9, 0.9) }); // Add table-like content const items = [ ['Item', 'Qty', 'Price', 'Total'], ['Widget', '2', '$50', '$100'], ['Gadget', '1', '$75', '$75'] ]; let yPos = height - 150; items.forEach(row => { let xPos = 50; row.forEach(cell => { page.drawText(cell, { x: xPos, y: yPos, size: 12, font: helveticaFont }); xPos += 120; }); yPos -= 25; }); const pdfBytes = await pdfDoc.save(); fs.writeFileSync('created.pdf', pdfBytes); } ``` -------------------------------- ### Advanced Table Extraction to Excel with pdfplumber and pandas Source: https://github.com/tfriedel/claude-office-skills/blob/main/public/pdf/SKILL.md Extract all tables from a PDF, convert them into pandas DataFrames, and combine them into a single Excel file. Requires pandas to be installed. ```python import pandas as pd with pdfplumber.open("document.pdf") as pdf: all_tables = [] for page in pdf.pages: tables = page.extract_tables() for table in tables: if table: # Check if table is not empty df = pd.DataFrame(table[1:], columns=table[0]) all_tables.append(df) # Combine all tables if all_tables: combined_df = pd.concat(all_tables, ignore_index=True) combined_df.to_excel("extracted_tables.xlsx", index=False) ``` -------------------------------- ### html2pptx Basic Usage Source: https://github.com/tfriedel/claude-office-skills/blob/main/public/pptx/html2pptx.md Demonstrates the basic workflow for converting an HTML file into a PowerPoint slide using the html2pptx library and pptxgenjs. ```APIDOC ## Basic Usage of html2pptx ### Description This example shows how to initialize a PptxGenJS presentation, convert an HTML file into a slide using `html2pptx`, and potentially add other elements like charts to the generated slide. ### Code Example ```javascript const pptxgen = require('pptxgenjs'); const html2pptx = require('./html2pptx'); async function convertHtmlToPpt() { const pptx = new pptxgen(); pptx.layout = 'LAYOUT_16x9'; // Must match HTML body dimensions // Convert HTML file to a slide const { slide, placeholders } = await html2pptx('slide1.html', pptx); // Example: Add a chart to the first placeholder if available if (placeholders.length > 0) { // Assuming chartData is defined elsewhere // const chartData = [...]; // slide.addChart(pptx.charts.LINE, chartData, placeholders[0]); } await pptx.writeFile('output.pptx'); console.log('Presentation saved as output.pptx'); } convertHtmlToPpt().catch(console.error); ``` ``` -------------------------------- ### Basic HTML Structure for Conversion Source: https://github.com/tfriedel/claude-office-skills/blob/main/public/pptx/html2pptx.md This is a sample HTML document structure. Ensure that the HTML body dimensions match the presentation layout set in pptxgenjs for accurate conversion. Avoid CSS gradients as they are not supported. ```html

Recipe Title

  • Item: Description

Text with bold, italic, underline.

5

``` -------------------------------- ### PDF Form Field Values JSON Source: https://context7.com/tfriedel/claude-office-skills/llms.txt Example JSON structure for defining values to be filled into PDF form fields. Each object maps a field ID to its desired value. ```json // outputs/form/field_values.json [ { "field_id": "last_name", "description": "Applicant last name", "page": 1, "value": "Smith" }, { "field_id": "first_name", "description": "Applicant first name", "page": 1, "value": "Jane" }, { "field_id": "Checkbox12", "description": "US citizen checkbox", "page": 1, "value": "/On" }, { "field_id": "state_select","description": "State of residence", "page": 2, "value": "CA" } ] ``` -------------------------------- ### Create PPTX Thumbnail Grid Source: https://github.com/tfriedel/claude-office-skills/blob/main/CLAUDE.md Generates a grid of thumbnails from a PPTX file for visual analysis. The number of columns can be specified. ```bash venv/bin/python public/pptx/scripts/thumbnail.py template.pptx outputs//thumbnails [--cols 4] ``` -------------------------------- ### OCR Scanned PDFs with pytesseract Source: https://github.com/tfriedel/claude-office-skills/blob/main/public/pdf/SKILL.md Use this to extract text from scanned PDF documents. Requires `pytesseract` and `pdf2image` to be installed. The PDF is first converted to images, and then OCR is applied to each image. ```python import pytesseract from pdf2image import convert_from_path # Convert PDF to images images = convert_from_path('scanned.pdf') # OCR each page text = "" for i, image in enumerate(images): text += f"Page {i+1}:\n" text += pytesseract.image_to_string(image) text += "\n\n" print(text) ``` -------------------------------- ### Create Thumbnail Grids Source: https://github.com/tfriedel/claude-office-skills/blob/main/public/pptx/SKILL.md Generate a visual thumbnail grid for a PowerPoint template to aid in analyzing slide layouts and design patterns. ```bash python scripts/thumbnail.py template.pptx ``` -------------------------------- ### Basic Text Formatting Source: https://github.com/tfriedel/claude-office-skills/blob/main/public/docx/docx-js.md Demonstrates how to create paragraphs with various text formatting options. It is crucial to use separate Paragraph elements for line breaks, not '\n' within TextRun. ```javascript // IMPORTANT: Never use \n for line breaks - always use separate Paragraph elements // ❌ WRONG: new TextRun("Line 1\nLine 2") // ✅ CORRECT: new Paragraph({ children: [new TextRun("Line 1")] }), new Paragraph({ children: [new TextRun("Line 2")] }) // Basic text with all formatting options new Paragraph({ alignment: AlignmentType.CENTER, spacing: { before: 200, after: 200 }, indent: { left: 720, right: 720 }, children: [ new TextRun({ text: "Bold", bold: true }), new TextRun({ text: "Italic", italics: true }), new TextRun({ text: "Underlined", underline: { type: UnderlineType.DOUBLE, color: "FF0000" } }), new TextRun({ text: "Colored", color: "FF0000", size: 28, font: "Arial" }), // Arial default new TextRun({ text: "Highlighted", highlight: "yellow" }), new TextRun({ text: "Strikethrough", strike: true }), new TextRun({ text: "x2", superScript: true }), new TextRun({ text: "H2O", subScript: true }), new TextRun({ text: "SMALL CAPS", smallCaps: true }), new SymbolRun({ char: "2022", font: "Symbol" }), // Bullet • new SymbolRun({ char: "00A9", font: "Arial" }) // Copyright © - Arial for symbols ] }) ``` -------------------------------- ### Example Validation Error: Overflow Worsened Source: https://github.com/tfriedel/claude-office-skills/blob/main/public/pptx/SKILL.md This error message highlights shapes where the replacement text caused an overflow issue to worsen. Check the text content and formatting for affected shapes. ```bash ERROR: Replacement text made overflow worse in these shapes: - slide-0/shape-2: overflow worsened by 1.25" (was 0.00", now 1.25") ``` -------------------------------- ### Example Validation Error: Invalid Shapes Source: https://github.com/tfriedel/claude-office-skills/blob/main/public/pptx/SKILL.md This error message indicates that shapes specified in the replacement JSON were not found in the presentation's inventory. Verify shape names and slide numbers. ```bash ERROR: Invalid shapes in replacement JSON: - Shape 'shape-99' not found on 'slide-0'. Available shapes: shape-0, shape-1, shape-4 - Slide 'slide-999' not found in inventory ``` -------------------------------- ### Replace Node with Tracked Changes Source: https://github.com/tfriedel/claude-office-skills/blob/main/public/docx/ooxml.md Use replace_node() to modify text within tracked changes. This example shows changing a single word, a number, or completely replacing text while preserving formatting. ```python # Minimal edit - change one word: "The report is monthly" → "The report is quarterly" # Original: The report is monthly node = doc["word/document.xml"].get_node(tag="w:r", contains="The report is monthly") rpr = tags[0].toxml() if (tags := node.getElementsByTagName("w:rPr")) else "" replacement = f'{rpr}The report is {rpr}monthly{rpr}quarterly' doc["word/document.xml"].replace_node(node, replacement) ``` ```python # Minimal edit - change number: "within 30 days" → "within 45 days" # Original: within 30 days node = doc["word/document.xml"].get_node(tag="w:r", contains="within 30 days") rpr = tags[0].toxml() if (tags := node.getElementsByTagName("w:rPr")) else "" replacement = f'{rpr}within {rpr}30{rpr}45{rpr} days' doc["word/document.xml"].replace_node(node, replacement) ``` ```python # Complete replacement - preserve formatting even when replacing all text node = doc["word/document.xml"].get_node(tag="w:r", contains="apple") rpr = tags[0].toxml() if (tags := node.getElementsByTagName("w:rPr")) else "" replacement = f'{rpr}apple{rpr}banana orange' doc["word/document.xml"].replace_node(node, replacement) ``` -------------------------------- ### OOXML Headings and Styles Source: https://github.com/tfriedel/claude-office-skills/blob/main/public/docx/ooxml.md Shows how to apply styles like 'Title' and 'Heading2' to paragraphs, along with text alignment. ```xml Document Title Section Heading ``` -------------------------------- ### Add Basic Table Source: https://github.com/tfriedel/claude-office-skills/blob/main/public/pptx/html2pptx.md Create a simple table with specified dimensions and basic formatting for borders and fill color. ```javascript slide.addTable([ ["Header 1", "Header 2", "Header 3"], ["Row 1, Col 1", "Row 1, Col 2", "Row 1, Col 3"], ["Row 2, Col 1", "Row 2, Col 2", "Row 2, Col 3"] ], { x: 0.5, y: 1, w: 9, h: 3, border: { pt: 1, color: "999999" }, fill: { color: "F1F1F1" } }); ``` -------------------------------- ### Adding Shapes to a Slide Source: https://github.com/tfriedel/claude-office-skills/blob/main/public/pptx/html2pptx.md Provides examples of adding different types of shapes (rectangle, circle, rounded rectangle) to a PptxGenJS slide, including options for fill color, line style, and corner radius. ```javascript // Rectangle slide.addShape(pptx.shapes.RECTANGLE, { x: 1, y: 1, w: 3, h: 2, fill: { color: "4472C4" }, line: { color: "000000", width: 2 } }); // Circle slide.addShape(pptx.shapes.OVAL, { x: 5, y: 1, w: 2, h: 2, fill: { color: "ED7D31" } }); // Rounded rectangle slide.addShape(pptx.shapes.ROUNDED_RECTANGLE, { x: 1, y: 4, w: 3, h: 1.5, fill: { color: "70AD47" }, rectRadius: 0.2 }); ``` -------------------------------- ### Convert PPTX to PDF then to Images using LibreOffice and Poppler Source: https://context7.com/tfriedel/claude-office-skills/llms.txt This two-step process converts PPTX slides to images. First, use headless LibreOffice (`soffice`) to convert PPTX to PDF. Second, use `pdftoppm` from Poppler to convert the PDF pages into JPEG images at a specified resolution (e.g., 150 DPI). ```bash # Step 1: PPTX → PDF (headless LibreOffice) soffice --headless --convert-to pdf --outdir outputs/my-deck/ outputs/my-deck/final.pptx # Output: outputs/my-deck/final.pdf # Step 2: PDF → JPEG images (150 DPI) pdftoppm -jpeg -r 150 outputs/my-deck/final.pdf outputs/my-deck/slide # Output: outputs/my-deck/slide-1.jpg, slide-2.jpg, ... # Specific page range only (e.g., slides 3–7) pdftoppm -jpeg -r 150 -f 3 -l 7 outputs/my-deck/final.pdf outputs/my-deck/slide ``` -------------------------------- ### Get OOXML Nodes by Criteria Source: https://github.com/tfriedel/claude-office-skills/blob/main/public/docx/ooxml.md Retrieves specific nodes from an OOXML document based on tag name and various filtering criteria. Use line number ranges for disambiguation when text appears multiple times. ```python # By text content node = doc["word/document.xml"].get_node(tag="w:p", contains="specific text") # By line range para = doc["word/document.xml"].get_node(tag="w:p", line_number=range(100, 150)) # By attributes node = doc["word/document.xml"].get_node(tag="w:del", attrs={"w:id": "1"}) # By exact line number (must be line number where tag opens) para = doc["word/document.xml"].get_node(tag="w:p", line_number=42) # Combine filters node = doc["word/document.xml"].get_node(tag="w:r", line_number=range(40, 60), contains="text") # Disambiguate when text appears multiple times - add line_number range node = doc["word/document.xml"].get_node(tag="w:r", contains="Section", line_number=range(2400, 2500)) ``` -------------------------------- ### Generate Thumbnail Grids from PPTX Source: https://github.com/tfriedel/claude-office-skills/blob/main/public/pptx/SKILL.md Use this script to create visual thumbnail grids of PowerPoint slides. Customize output prefix and the number of columns for grid layout. Adjust columns to control the number of slides per grid. ```bash python scripts/thumbnail.py template.pptx [output_prefix] ``` ```bash python scripts/thumbnail.py template.pptx my-grid ``` ```bash python scripts/thumbnail.py template.pptx workspace/my-grid ``` ```bash python scripts/thumbnail.py template.pptx analysis --cols 4 ``` ```bash python scripts/thumbnail.py presentation.pptx ``` -------------------------------- ### Interpreting recalc.py Output JSON Source: https://github.com/tfriedel/claude-office-skills/blob/main/public/xlsx/SKILL.md Example JSON output from the recalc.py script, showing the status of formula recalculation, total errors, total formulas processed, and a summary of specific error types and their locations if errors were found. ```json { "status": "success", // or "errors_found" "total_errors": 0, // Total error count "total_formulas": 42, // Number of formulas in file "error_summary": { // Only present if errors found "#REF!": { "count": 2, "locations": ["Sheet1!B5", "Sheet1!C10"] } } } ``` -------------------------------- ### Extract Figures/Images from PDF using pypdfium2 and PIL Source: https://github.com/tfriedel/claude-office-skills/blob/main/public/pdf/REFERENCE.md Provides a Python-based approach to rendering PDF pages and performing basic image processing for figure detection. This snippet outlines the setup for rendering and a simplified detection mask. ```python import pypdfium2 as pdfium from PIL import Image import numpy as np def extract_figures(pdf_path, output_dir): pdf = pdfium.PdfDocument(pdf_path) for page_num, page in enumerate(pdf): # Render high-resolution page bitmap = page.render(scale=3.0) img = bitmap.to_pil() # Convert to numpy for processing img_array = np.array(img) # Simple figure detection (non-white regions) mask = np.any(img_array != [255, 255, 255], axis=2) # Find contours and extract bounding boxes # (This is simplified - real implementation would need more sophisticated detection) # Save detected figures # ... implementation depends on specific needs ``` -------------------------------- ### Reordering Slides in `presentation.xml` Source: https://github.com/tfriedel/claude-office-skills/blob/main/public/pptx/ooxml.md Demonstrates how to reorder slides by modifying the `` in `ppt/presentation.xml`. The order of elements dictates the slide order. ```xml ``` -------------------------------- ### Show Detailed PDF Structure (qpdf) Source: https://github.com/tfriedel/claude-office-skills/blob/main/public/pdf/REFERENCE.md Outputs the internal structure of a PDF file to a text file, useful for debugging and understanding PDF content. Includes all page information. ```bash # Show detailed PDF structure for debugging qpdf --show-all-pages input.pdf > structure.txt ``` -------------------------------- ### Advanced PDF Cropping using pypdf Source: https://github.com/tfriedel/claude-office-skills/blob/main/public/pdf/REFERENCE.md Initializes a PDF reader and writer for performing operations like cropping on PDF documents. This snippet sets up the necessary objects for subsequent cropping logic. ```python from pypdf import PdfWriter, PdfReader reader = PdfReader("input.pdf") writer = PdfWriter() ```