@papert-code/papert-code 0.3.95 → 0.3.96
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -0
- package/dist/chunks/{chunk-Q5TJEKUL.js → chunk-HSYOWGEB.js} +1 -1
- package/dist/chunks/{chunk-KDPC3L34.js → chunk-IK4ISYCE.js} +4 -4
- package/dist/chunks/{chunk-JATIVKZP.js → chunk-KBPFDUTA.js} +55 -10
- package/dist/chunks/{chunk-DQ32BMUI.js → chunk-TNDQXJLA.js} +924 -335
- package/dist/chunks/{gemini-SUVKHYG5.js → gemini-MVJNXCFF.js} +3910 -1535
- package/dist/chunks/{openaiContentGenerator-P6VRBRRB.js → openaiContentGenerator-GTG5MK5E.js} +2 -2
- package/dist/chunks/{papertContentGenerator-E64QQV3K.js → papertContentGenerator-Q5TTXUE6.js} +3 -3
- package/dist/chunks/{server-N2U4FF55.js → server-6D3KYATG.js} +7 -1
- package/dist/cli.js +5 -4
- package/dist/sandbox-macos-permissive-proxied.sb +1 -1
- package/dist/sandbox-macos-restrictive-proxied.sb +1 -1
- package/dist/skills/algorithmic-art/SKILL.md +405 -0
- package/dist/skills/algorithmic-art/templates/generator_template.js +223 -0
- package/dist/skills/algorithmic-art/templates/viewer.html +599 -0
- package/dist/skills/brand-guidelines/SKILL.md +73 -0
- package/dist/skills/canvas-design/SKILL.md +130 -0
- package/dist/skills/canvas-design/canvas-fonts/ArsenalSC-OFL.txt +93 -0
- package/dist/skills/canvas-design/canvas-fonts/ArsenalSC-Regular.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/BigShoulders-Bold.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/BigShoulders-OFL.txt +93 -0
- package/dist/skills/canvas-design/canvas-fonts/BigShoulders-Regular.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/Boldonse-OFL.txt +93 -0
- package/dist/skills/canvas-design/canvas-fonts/Boldonse-Regular.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/BricolageGrotesque-Bold.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/BricolageGrotesque-OFL.txt +93 -0
- package/dist/skills/canvas-design/canvas-fonts/BricolageGrotesque-Regular.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/CrimsonPro-Bold.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/CrimsonPro-Italic.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/CrimsonPro-OFL.txt +93 -0
- package/dist/skills/canvas-design/canvas-fonts/CrimsonPro-Regular.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/DMMono-OFL.txt +93 -0
- package/dist/skills/canvas-design/canvas-fonts/DMMono-Regular.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/EricaOne-OFL.txt +94 -0
- package/dist/skills/canvas-design/canvas-fonts/EricaOne-Regular.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/GeistMono-Bold.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/GeistMono-OFL.txt +93 -0
- package/dist/skills/canvas-design/canvas-fonts/GeistMono-Regular.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/Gloock-OFL.txt +93 -0
- package/dist/skills/canvas-design/canvas-fonts/Gloock-Regular.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/IBMPlexMono-Bold.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/IBMPlexMono-OFL.txt +93 -0
- package/dist/skills/canvas-design/canvas-fonts/IBMPlexMono-Regular.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/IBMPlexSerif-Bold.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/IBMPlexSerif-BoldItalic.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/IBMPlexSerif-Italic.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/IBMPlexSerif-Regular.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/InstrumentSans-Bold.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/InstrumentSans-BoldItalic.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/InstrumentSans-Italic.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/InstrumentSans-OFL.txt +93 -0
- package/dist/skills/canvas-design/canvas-fonts/InstrumentSans-Regular.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/InstrumentSerif-Italic.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/InstrumentSerif-Regular.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/Italiana-OFL.txt +93 -0
- package/dist/skills/canvas-design/canvas-fonts/Italiana-Regular.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/JetBrainsMono-Bold.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/JetBrainsMono-OFL.txt +93 -0
- package/dist/skills/canvas-design/canvas-fonts/JetBrainsMono-Regular.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/Jura-Light.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/Jura-Medium.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/Jura-OFL.txt +93 -0
- package/dist/skills/canvas-design/canvas-fonts/LibreBaskerville-OFL.txt +93 -0
- package/dist/skills/canvas-design/canvas-fonts/LibreBaskerville-Regular.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/Lora-Bold.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/Lora-BoldItalic.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/Lora-Italic.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/Lora-OFL.txt +93 -0
- package/dist/skills/canvas-design/canvas-fonts/Lora-Regular.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/NationalPark-Bold.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/NationalPark-OFL.txt +93 -0
- package/dist/skills/canvas-design/canvas-fonts/NationalPark-Regular.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/NothingYouCouldDo-OFL.txt +93 -0
- package/dist/skills/canvas-design/canvas-fonts/NothingYouCouldDo-Regular.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/Outfit-Bold.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/Outfit-OFL.txt +93 -0
- package/dist/skills/canvas-design/canvas-fonts/Outfit-Regular.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/PixelifySans-Medium.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/PixelifySans-OFL.txt +93 -0
- package/dist/skills/canvas-design/canvas-fonts/PoiretOne-OFL.txt +93 -0
- package/dist/skills/canvas-design/canvas-fonts/PoiretOne-Regular.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/RedHatMono-Bold.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/RedHatMono-OFL.txt +93 -0
- package/dist/skills/canvas-design/canvas-fonts/RedHatMono-Regular.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/Silkscreen-OFL.txt +93 -0
- package/dist/skills/canvas-design/canvas-fonts/Silkscreen-Regular.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/SmoochSans-Medium.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/SmoochSans-OFL.txt +93 -0
- package/dist/skills/canvas-design/canvas-fonts/Tektur-Medium.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/Tektur-OFL.txt +93 -0
- package/dist/skills/canvas-design/canvas-fonts/Tektur-Regular.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/WorkSans-Bold.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/WorkSans-BoldItalic.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/WorkSans-Italic.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/WorkSans-OFL.txt +93 -0
- package/dist/skills/canvas-design/canvas-fonts/WorkSans-Regular.ttf +0 -0
- package/dist/skills/canvas-design/canvas-fonts/YoungSerif-OFL.txt +93 -0
- package/dist/skills/canvas-design/canvas-fonts/YoungSerif-Regular.ttf +0 -0
- package/dist/skills/doc-coauthoring/SKILL.md +375 -0
- package/dist/skills/docx/SKILL.md +481 -0
- package/dist/skills/docx/scripts/__init__.py +1 -0
- package/dist/skills/docx/scripts/accept_changes.py +135 -0
- package/dist/skills/docx/scripts/comment.py +318 -0
- package/dist/skills/docx/scripts/office/helpers/__init__.py +0 -0
- package/dist/skills/docx/scripts/office/helpers/merge_runs.py +199 -0
- package/dist/skills/docx/scripts/office/helpers/simplify_redlines.py +197 -0
- package/dist/skills/docx/scripts/office/pack.py +159 -0
- package/dist/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
- package/dist/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
- package/dist/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
- package/dist/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
- package/dist/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
- package/dist/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
- package/dist/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
- package/dist/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
- package/dist/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
- package/dist/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
- package/dist/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
- package/dist/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
- package/dist/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
- package/dist/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
- package/dist/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
- package/dist/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
- package/dist/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
- package/dist/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
- package/dist/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
- package/dist/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
- package/dist/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
- package/dist/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
- package/dist/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
- package/dist/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
- package/dist/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
- package/dist/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
- package/dist/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
- package/dist/skills/docx/scripts/office/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
- package/dist/skills/docx/scripts/office/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
- package/dist/skills/docx/scripts/office/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
- package/dist/skills/docx/scripts/office/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
- package/dist/skills/docx/scripts/office/schemas/mce/mc.xsd +75 -0
- package/dist/skills/docx/scripts/office/schemas/microsoft/wml-2010.xsd +560 -0
- package/dist/skills/docx/scripts/office/schemas/microsoft/wml-2012.xsd +67 -0
- package/dist/skills/docx/scripts/office/schemas/microsoft/wml-2018.xsd +14 -0
- package/dist/skills/docx/scripts/office/schemas/microsoft/wml-cex-2018.xsd +20 -0
- package/dist/skills/docx/scripts/office/schemas/microsoft/wml-cid-2016.xsd +13 -0
- package/dist/skills/docx/scripts/office/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
- package/dist/skills/docx/scripts/office/schemas/microsoft/wml-symex-2015.xsd +8 -0
- package/dist/skills/docx/scripts/office/soffice.py +183 -0
- package/dist/skills/docx/scripts/office/unpack.py +132 -0
- package/dist/skills/docx/scripts/office/validate.py +111 -0
- package/dist/skills/docx/scripts/office/validators/__init__.py +15 -0
- package/dist/skills/docx/scripts/office/validators/base.py +847 -0
- package/dist/skills/docx/scripts/office/validators/docx.py +446 -0
- package/dist/skills/docx/scripts/office/validators/pptx.py +275 -0
- package/dist/skills/docx/scripts/office/validators/redlining.py +247 -0
- package/dist/skills/docx/scripts/templates/comments.xml +3 -0
- package/dist/skills/docx/scripts/templates/commentsExtended.xml +3 -0
- package/dist/skills/docx/scripts/templates/commentsExtensible.xml +3 -0
- package/dist/skills/docx/scripts/templates/commentsIds.xml +3 -0
- package/dist/skills/docx/scripts/templates/people.xml +3 -0
- package/dist/skills/frontend-design/SKILL.md +42 -0
- package/dist/skills/internal-comms/SKILL.md +32 -0
- package/dist/skills/internal-comms/examples/3p-updates.md +47 -0
- package/dist/skills/internal-comms/examples/company-newsletter.md +65 -0
- package/dist/skills/internal-comms/examples/faq-answers.md +30 -0
- package/dist/skills/internal-comms/examples/general-comms.md +16 -0
- package/dist/skills/mcp-builder/SKILL.md +236 -0
- package/dist/skills/mcp-builder/reference/evaluation.md +602 -0
- package/dist/skills/mcp-builder/reference/mcp_best_practices.md +249 -0
- package/dist/skills/mcp-builder/reference/node_mcp_server.md +970 -0
- package/dist/skills/mcp-builder/reference/python_mcp_server.md +719 -0
- package/dist/skills/mcp-builder/scripts/connections.py +151 -0
- package/dist/skills/mcp-builder/scripts/evaluation.py +373 -0
- package/dist/skills/mcp-builder/scripts/example_evaluation.xml +22 -0
- package/dist/skills/mcp-builder/scripts/requirements.txt +2 -0
- package/dist/skills/papert-code/SKILL.md +561 -0
- package/dist/skills/pdf/SKILL.md +314 -0
- package/dist/skills/pdf/forms.md +294 -0
- package/dist/skills/pdf/reference.md +612 -0
- package/dist/skills/pdf/scripts/check_bounding_boxes.py +65 -0
- package/dist/skills/pdf/scripts/check_fillable_fields.py +11 -0
- package/dist/skills/pdf/scripts/convert_pdf_to_images.py +33 -0
- package/dist/skills/pdf/scripts/create_validation_image.py +37 -0
- package/dist/skills/pdf/scripts/extract_form_field_info.py +122 -0
- package/dist/skills/pdf/scripts/extract_form_structure.py +115 -0
- package/dist/skills/pdf/scripts/fill_fillable_fields.py +98 -0
- package/dist/skills/pdf/scripts/fill_pdf_form_with_annotations.py +107 -0
- package/dist/skills/pptx/SKILL.md +232 -0
- package/dist/skills/pptx/editing.md +205 -0
- package/dist/skills/pptx/pptxgenjs.md +420 -0
- package/dist/skills/pptx/scripts/__init__.py +0 -0
- package/dist/skills/pptx/scripts/add_slide.py +195 -0
- package/dist/skills/pptx/scripts/clean.py +286 -0
- package/dist/skills/pptx/scripts/office/helpers/__init__.py +0 -0
- package/dist/skills/pptx/scripts/office/helpers/merge_runs.py +199 -0
- package/dist/skills/pptx/scripts/office/helpers/simplify_redlines.py +197 -0
- package/dist/skills/pptx/scripts/office/pack.py +159 -0
- package/dist/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
- package/dist/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
- package/dist/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
- package/dist/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
- package/dist/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
- package/dist/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
- package/dist/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
- package/dist/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
- package/dist/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
- package/dist/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
- package/dist/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
- package/dist/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
- package/dist/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
- package/dist/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
- package/dist/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
- package/dist/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
- package/dist/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
- package/dist/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
- package/dist/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
- package/dist/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
- package/dist/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
- package/dist/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
- package/dist/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
- package/dist/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
- package/dist/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
- package/dist/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
- package/dist/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
- package/dist/skills/pptx/scripts/office/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
- package/dist/skills/pptx/scripts/office/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
- package/dist/skills/pptx/scripts/office/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
- package/dist/skills/pptx/scripts/office/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
- package/dist/skills/pptx/scripts/office/schemas/mce/mc.xsd +75 -0
- package/dist/skills/pptx/scripts/office/schemas/microsoft/wml-2010.xsd +560 -0
- package/dist/skills/pptx/scripts/office/schemas/microsoft/wml-2012.xsd +67 -0
- package/dist/skills/pptx/scripts/office/schemas/microsoft/wml-2018.xsd +14 -0
- package/dist/skills/pptx/scripts/office/schemas/microsoft/wml-cex-2018.xsd +20 -0
- package/dist/skills/pptx/scripts/office/schemas/microsoft/wml-cid-2016.xsd +13 -0
- package/dist/skills/pptx/scripts/office/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
- package/dist/skills/pptx/scripts/office/schemas/microsoft/wml-symex-2015.xsd +8 -0
- package/dist/skills/pptx/scripts/office/soffice.py +183 -0
- package/dist/skills/pptx/scripts/office/unpack.py +132 -0
- package/dist/skills/pptx/scripts/office/validate.py +111 -0
- package/dist/skills/pptx/scripts/office/validators/__init__.py +15 -0
- package/dist/skills/pptx/scripts/office/validators/base.py +847 -0
- package/dist/skills/pptx/scripts/office/validators/docx.py +446 -0
- package/dist/skills/pptx/scripts/office/validators/pptx.py +275 -0
- package/dist/skills/pptx/scripts/office/validators/redlining.py +247 -0
- package/dist/skills/pptx/scripts/thumbnail.py +289 -0
- package/dist/skills/skill-creator/SKILL.md +357 -0
- package/dist/skills/skill-creator/references/output-patterns.md +82 -0
- package/dist/skills/skill-creator/references/workflows.md +28 -0
- package/dist/skills/skill-creator/scripts/init_skill.py +303 -0
- package/dist/skills/skill-creator/scripts/package_skill.py +110 -0
- package/dist/skills/skill-creator/scripts/quick_validate.py +103 -0
- package/dist/skills/slack-gif-creator/SKILL.md +254 -0
- package/dist/skills/slack-gif-creator/core/easing.py +234 -0
- package/dist/skills/slack-gif-creator/core/frame_composer.py +176 -0
- package/dist/skills/slack-gif-creator/core/gif_builder.py +269 -0
- package/dist/skills/slack-gif-creator/core/validators.py +136 -0
- package/dist/skills/slack-gif-creator/requirements.txt +4 -0
- package/dist/skills/theme-factory/SKILL.md +59 -0
- package/dist/skills/theme-factory/theme-showcase.pdf +0 -0
- package/dist/skills/theme-factory/themes/arctic-frost.md +19 -0
- package/dist/skills/theme-factory/themes/botanical-garden.md +19 -0
- package/dist/skills/theme-factory/themes/desert-rose.md +19 -0
- package/dist/skills/theme-factory/themes/forest-canopy.md +19 -0
- package/dist/skills/theme-factory/themes/golden-hour.md +19 -0
- package/dist/skills/theme-factory/themes/midnight-galaxy.md +19 -0
- package/dist/skills/theme-factory/themes/modern-minimalist.md +19 -0
- package/dist/skills/theme-factory/themes/ocean-depths.md +19 -0
- package/dist/skills/theme-factory/themes/sunset-boulevard.md +19 -0
- package/dist/skills/theme-factory/themes/tech-innovation.md +19 -0
- package/dist/skills/web-artifacts-builder/SKILL.md +74 -0
- package/dist/skills/web-artifacts-builder/scripts/bundle-artifact.sh +54 -0
- package/dist/skills/web-artifacts-builder/scripts/init-artifact.sh +322 -0
- package/dist/skills/web-artifacts-builder/scripts/shadcn-components.tar.gz +0 -0
- package/dist/skills/webapp-testing/SKILL.md +96 -0
- package/dist/skills/webapp-testing/examples/console_logging.py +35 -0
- package/dist/skills/webapp-testing/examples/element_discovery.py +40 -0
- package/dist/skills/webapp-testing/examples/static_html_automation.py +33 -0
- package/dist/skills/webapp-testing/scripts/with_server.py +106 -0
- package/dist/skills/xlsx/SKILL.md +292 -0
- package/dist/skills/xlsx/scripts/office/helpers/__init__.py +0 -0
- package/dist/skills/xlsx/scripts/office/helpers/merge_runs.py +199 -0
- package/dist/skills/xlsx/scripts/office/helpers/simplify_redlines.py +197 -0
- package/dist/skills/xlsx/scripts/office/pack.py +159 -0
- package/dist/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
- package/dist/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
- package/dist/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
- package/dist/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
- package/dist/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
- package/dist/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
- package/dist/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
- package/dist/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
- package/dist/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
- package/dist/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
- package/dist/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
- package/dist/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
- package/dist/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
- package/dist/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
- package/dist/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
- package/dist/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
- package/dist/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
- package/dist/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
- package/dist/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
- package/dist/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
- package/dist/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
- package/dist/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
- package/dist/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
- package/dist/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
- package/dist/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
- package/dist/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
- package/dist/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
- package/dist/skills/xlsx/scripts/office/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
- package/dist/skills/xlsx/scripts/office/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
- package/dist/skills/xlsx/scripts/office/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
- package/dist/skills/xlsx/scripts/office/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
- package/dist/skills/xlsx/scripts/office/schemas/mce/mc.xsd +75 -0
- package/dist/skills/xlsx/scripts/office/schemas/microsoft/wml-2010.xsd +560 -0
- package/dist/skills/xlsx/scripts/office/schemas/microsoft/wml-2012.xsd +67 -0
- package/dist/skills/xlsx/scripts/office/schemas/microsoft/wml-2018.xsd +14 -0
- package/dist/skills/xlsx/scripts/office/schemas/microsoft/wml-cex-2018.xsd +20 -0
- package/dist/skills/xlsx/scripts/office/schemas/microsoft/wml-cid-2016.xsd +13 -0
- package/dist/skills/xlsx/scripts/office/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
- package/dist/skills/xlsx/scripts/office/schemas/microsoft/wml-symex-2015.xsd +8 -0
- package/dist/skills/xlsx/scripts/office/soffice.py +183 -0
- package/dist/skills/xlsx/scripts/office/unpack.py +132 -0
- package/dist/skills/xlsx/scripts/office/validate.py +111 -0
- package/dist/skills/xlsx/scripts/office/validators/__init__.py +15 -0
- package/dist/skills/xlsx/scripts/office/validators/base.py +847 -0
- package/dist/skills/xlsx/scripts/office/validators/docx.py +446 -0
- package/dist/skills/xlsx/scripts/office/validators/pptx.py +275 -0
- package/dist/skills/xlsx/scripts/office/validators/redlining.py +247 -0
- package/dist/skills/xlsx/scripts/recalc.py +184 -0
- package/package.json +5 -4
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pdf
|
|
3
|
+
description: Use this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill.
|
|
4
|
+
license: Proprietary. LICENSE.txt has complete terms
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# PDF Processing Guide
|
|
8
|
+
|
|
9
|
+
## Overview
|
|
10
|
+
|
|
11
|
+
This guide covers essential PDF processing operations using Python libraries and command-line tools. For advanced features, JavaScript libraries, and detailed examples, see REFERENCE.md. If you need to fill out a PDF form, read FORMS.md and follow its instructions.
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
from pypdf import PdfReader, PdfWriter
|
|
17
|
+
|
|
18
|
+
# Read a PDF
|
|
19
|
+
reader = PdfReader("document.pdf")
|
|
20
|
+
print(f"Pages: {len(reader.pages)}")
|
|
21
|
+
|
|
22
|
+
# Extract text
|
|
23
|
+
text = ""
|
|
24
|
+
for page in reader.pages:
|
|
25
|
+
text += page.extract_text()
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Python Libraries
|
|
29
|
+
|
|
30
|
+
### pypdf - Basic Operations
|
|
31
|
+
|
|
32
|
+
#### Merge PDFs
|
|
33
|
+
```python
|
|
34
|
+
from pypdf import PdfWriter, PdfReader
|
|
35
|
+
|
|
36
|
+
writer = PdfWriter()
|
|
37
|
+
for pdf_file in ["doc1.pdf", "doc2.pdf", "doc3.pdf"]:
|
|
38
|
+
reader = PdfReader(pdf_file)
|
|
39
|
+
for page in reader.pages:
|
|
40
|
+
writer.add_page(page)
|
|
41
|
+
|
|
42
|
+
with open("merged.pdf", "wb") as output:
|
|
43
|
+
writer.write(output)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
#### Split PDF
|
|
47
|
+
```python
|
|
48
|
+
reader = PdfReader("input.pdf")
|
|
49
|
+
for i, page in enumerate(reader.pages):
|
|
50
|
+
writer = PdfWriter()
|
|
51
|
+
writer.add_page(page)
|
|
52
|
+
with open(f"page_{i+1}.pdf", "wb") as output:
|
|
53
|
+
writer.write(output)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
#### Extract Metadata
|
|
57
|
+
```python
|
|
58
|
+
reader = PdfReader("document.pdf")
|
|
59
|
+
meta = reader.metadata
|
|
60
|
+
print(f"Title: {meta.title}")
|
|
61
|
+
print(f"Author: {meta.author}")
|
|
62
|
+
print(f"Subject: {meta.subject}")
|
|
63
|
+
print(f"Creator: {meta.creator}")
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
#### Rotate Pages
|
|
67
|
+
```python
|
|
68
|
+
reader = PdfReader("input.pdf")
|
|
69
|
+
writer = PdfWriter()
|
|
70
|
+
|
|
71
|
+
page = reader.pages[0]
|
|
72
|
+
page.rotate(90) # Rotate 90 degrees clockwise
|
|
73
|
+
writer.add_page(page)
|
|
74
|
+
|
|
75
|
+
with open("rotated.pdf", "wb") as output:
|
|
76
|
+
writer.write(output)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### pdfplumber - Text and Table Extraction
|
|
80
|
+
|
|
81
|
+
#### Extract Text with Layout
|
|
82
|
+
```python
|
|
83
|
+
import pdfplumber
|
|
84
|
+
|
|
85
|
+
with pdfplumber.open("document.pdf") as pdf:
|
|
86
|
+
for page in pdf.pages:
|
|
87
|
+
text = page.extract_text()
|
|
88
|
+
print(text)
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
#### Extract Tables
|
|
92
|
+
```python
|
|
93
|
+
with pdfplumber.open("document.pdf") as pdf:
|
|
94
|
+
for i, page in enumerate(pdf.pages):
|
|
95
|
+
tables = page.extract_tables()
|
|
96
|
+
for j, table in enumerate(tables):
|
|
97
|
+
print(f"Table {j+1} on page {i+1}:")
|
|
98
|
+
for row in table:
|
|
99
|
+
print(row)
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
#### Advanced Table Extraction
|
|
103
|
+
```python
|
|
104
|
+
import pandas as pd
|
|
105
|
+
|
|
106
|
+
with pdfplumber.open("document.pdf") as pdf:
|
|
107
|
+
all_tables = []
|
|
108
|
+
for page in pdf.pages:
|
|
109
|
+
tables = page.extract_tables()
|
|
110
|
+
for table in tables:
|
|
111
|
+
if table: # Check if table is not empty
|
|
112
|
+
df = pd.DataFrame(table[1:], columns=table[0])
|
|
113
|
+
all_tables.append(df)
|
|
114
|
+
|
|
115
|
+
# Combine all tables
|
|
116
|
+
if all_tables:
|
|
117
|
+
combined_df = pd.concat(all_tables, ignore_index=True)
|
|
118
|
+
combined_df.to_excel("extracted_tables.xlsx", index=False)
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### reportlab - Create PDFs
|
|
122
|
+
|
|
123
|
+
#### Basic PDF Creation
|
|
124
|
+
```python
|
|
125
|
+
from reportlab.lib.pagesizes import letter
|
|
126
|
+
from reportlab.pdfgen import canvas
|
|
127
|
+
|
|
128
|
+
c = canvas.Canvas("hello.pdf", pagesize=letter)
|
|
129
|
+
width, height = letter
|
|
130
|
+
|
|
131
|
+
# Add text
|
|
132
|
+
c.drawString(100, height - 100, "Hello World!")
|
|
133
|
+
c.drawString(100, height - 120, "This is a PDF created with reportlab")
|
|
134
|
+
|
|
135
|
+
# Add a line
|
|
136
|
+
c.line(100, height - 140, 400, height - 140)
|
|
137
|
+
|
|
138
|
+
# Save
|
|
139
|
+
c.save()
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
#### Create PDF with Multiple Pages
|
|
143
|
+
```python
|
|
144
|
+
from reportlab.lib.pagesizes import letter
|
|
145
|
+
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, PageBreak
|
|
146
|
+
from reportlab.lib.styles import getSampleStyleSheet
|
|
147
|
+
|
|
148
|
+
doc = SimpleDocTemplate("report.pdf", pagesize=letter)
|
|
149
|
+
styles = getSampleStyleSheet()
|
|
150
|
+
story = []
|
|
151
|
+
|
|
152
|
+
# Add content
|
|
153
|
+
title = Paragraph("Report Title", styles['Title'])
|
|
154
|
+
story.append(title)
|
|
155
|
+
story.append(Spacer(1, 12))
|
|
156
|
+
|
|
157
|
+
body = Paragraph("This is the body of the report. " * 20, styles['Normal'])
|
|
158
|
+
story.append(body)
|
|
159
|
+
story.append(PageBreak())
|
|
160
|
+
|
|
161
|
+
# Page 2
|
|
162
|
+
story.append(Paragraph("Page 2", styles['Heading1']))
|
|
163
|
+
story.append(Paragraph("Content for page 2", styles['Normal']))
|
|
164
|
+
|
|
165
|
+
# Build PDF
|
|
166
|
+
doc.build(story)
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
#### Subscripts and Superscripts
|
|
170
|
+
|
|
171
|
+
**IMPORTANT**: Never use Unicode subscript/superscript characters (₀₁₂₃₄₅₆₇₈₉, ⁰¹²³⁴⁵⁶⁷⁸⁹) in ReportLab PDFs. The built-in fonts do not include these glyphs, causing them to render as solid black boxes.
|
|
172
|
+
|
|
173
|
+
Instead, use ReportLab's XML markup tags in Paragraph objects:
|
|
174
|
+
```python
|
|
175
|
+
from reportlab.platypus import Paragraph
|
|
176
|
+
from reportlab.lib.styles import getSampleStyleSheet
|
|
177
|
+
|
|
178
|
+
styles = getSampleStyleSheet()
|
|
179
|
+
|
|
180
|
+
# Subscripts: use <sub> tag
|
|
181
|
+
chemical = Paragraph("H<sub>2</sub>O", styles['Normal'])
|
|
182
|
+
|
|
183
|
+
# Superscripts: use <super> tag
|
|
184
|
+
squared = Paragraph("x<super>2</super> + y<super>2</super>", styles['Normal'])
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
For canvas-drawn text (not Paragraph objects), manually adjust font the size and position rather than using Unicode subscripts/superscripts.
|
|
188
|
+
|
|
189
|
+
## Command-Line Tools
|
|
190
|
+
|
|
191
|
+
### pdftotext (poppler-utils)
|
|
192
|
+
```bash
|
|
193
|
+
# Extract text
|
|
194
|
+
pdftotext input.pdf output.txt
|
|
195
|
+
|
|
196
|
+
# Extract text preserving layout
|
|
197
|
+
pdftotext -layout input.pdf output.txt
|
|
198
|
+
|
|
199
|
+
# Extract specific pages
|
|
200
|
+
pdftotext -f 1 -l 5 input.pdf output.txt # Pages 1-5
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### qpdf
|
|
204
|
+
```bash
|
|
205
|
+
# Merge PDFs
|
|
206
|
+
qpdf --empty --pages file1.pdf file2.pdf -- merged.pdf
|
|
207
|
+
|
|
208
|
+
# Split pages
|
|
209
|
+
qpdf input.pdf --pages . 1-5 -- pages1-5.pdf
|
|
210
|
+
qpdf input.pdf --pages . 6-10 -- pages6-10.pdf
|
|
211
|
+
|
|
212
|
+
# Rotate pages
|
|
213
|
+
qpdf input.pdf output.pdf --rotate=+90:1 # Rotate page 1 by 90 degrees
|
|
214
|
+
|
|
215
|
+
# Remove password
|
|
216
|
+
qpdf --password=mypassword --decrypt encrypted.pdf decrypted.pdf
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### pdftk (if available)
|
|
220
|
+
```bash
|
|
221
|
+
# Merge
|
|
222
|
+
pdftk file1.pdf file2.pdf cat output merged.pdf
|
|
223
|
+
|
|
224
|
+
# Split
|
|
225
|
+
pdftk input.pdf burst
|
|
226
|
+
|
|
227
|
+
# Rotate
|
|
228
|
+
pdftk input.pdf rotate 1east output rotated.pdf
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
## Common Tasks
|
|
232
|
+
|
|
233
|
+
### Extract Text from Scanned PDFs
|
|
234
|
+
```python
|
|
235
|
+
# Requires: pip install pytesseract pdf2image
|
|
236
|
+
import pytesseract
|
|
237
|
+
from pdf2image import convert_from_path
|
|
238
|
+
|
|
239
|
+
# Convert PDF to images
|
|
240
|
+
images = convert_from_path('scanned.pdf')
|
|
241
|
+
|
|
242
|
+
# OCR each page
|
|
243
|
+
text = ""
|
|
244
|
+
for i, image in enumerate(images):
|
|
245
|
+
text += f"Page {i+1}:\n"
|
|
246
|
+
text += pytesseract.image_to_string(image)
|
|
247
|
+
text += "\n\n"
|
|
248
|
+
|
|
249
|
+
print(text)
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### Add Watermark
|
|
253
|
+
```python
|
|
254
|
+
from pypdf import PdfReader, PdfWriter
|
|
255
|
+
|
|
256
|
+
# Create watermark (or load existing)
|
|
257
|
+
watermark = PdfReader("watermark.pdf").pages[0]
|
|
258
|
+
|
|
259
|
+
# Apply to all pages
|
|
260
|
+
reader = PdfReader("document.pdf")
|
|
261
|
+
writer = PdfWriter()
|
|
262
|
+
|
|
263
|
+
for page in reader.pages:
|
|
264
|
+
page.merge_page(watermark)
|
|
265
|
+
writer.add_page(page)
|
|
266
|
+
|
|
267
|
+
with open("watermarked.pdf", "wb") as output:
|
|
268
|
+
writer.write(output)
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
### Extract Images
|
|
272
|
+
```bash
|
|
273
|
+
# Using pdfimages (poppler-utils)
|
|
274
|
+
pdfimages -j input.pdf output_prefix
|
|
275
|
+
|
|
276
|
+
# This extracts all images as output_prefix-000.jpg, output_prefix-001.jpg, etc.
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### Password Protection
|
|
280
|
+
```python
|
|
281
|
+
from pypdf import PdfReader, PdfWriter
|
|
282
|
+
|
|
283
|
+
reader = PdfReader("input.pdf")
|
|
284
|
+
writer = PdfWriter()
|
|
285
|
+
|
|
286
|
+
for page in reader.pages:
|
|
287
|
+
writer.add_page(page)
|
|
288
|
+
|
|
289
|
+
# Add password
|
|
290
|
+
writer.encrypt("userpassword", "ownerpassword")
|
|
291
|
+
|
|
292
|
+
with open("encrypted.pdf", "wb") as output:
|
|
293
|
+
writer.write(output)
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
## Quick Reference
|
|
297
|
+
|
|
298
|
+
| Task | Best Tool | Command/Code |
|
|
299
|
+
|------|-----------|--------------|
|
|
300
|
+
| Merge PDFs | pypdf | `writer.add_page(page)` |
|
|
301
|
+
| Split PDFs | pypdf | One page per file |
|
|
302
|
+
| Extract text | pdfplumber | `page.extract_text()` |
|
|
303
|
+
| Extract tables | pdfplumber | `page.extract_tables()` |
|
|
304
|
+
| Create PDFs | reportlab | Canvas or Platypus |
|
|
305
|
+
| Command line merge | qpdf | `qpdf --empty --pages ...` |
|
|
306
|
+
| OCR scanned PDFs | pytesseract | Convert to image first |
|
|
307
|
+
| Fill PDF forms | pdf-lib or pypdf (see FORMS.md) | See FORMS.md |
|
|
308
|
+
|
|
309
|
+
## Next Steps
|
|
310
|
+
|
|
311
|
+
- For advanced pypdfium2 usage, see REFERENCE.md
|
|
312
|
+
- For JavaScript libraries (pdf-lib), see REFERENCE.md
|
|
313
|
+
- If you need to fill out a PDF form, follow the instructions in FORMS.md
|
|
314
|
+
- For troubleshooting guides, see REFERENCE.md
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
**CRITICAL: You MUST complete these steps in order. Do not skip ahead to writing code.**
|
|
2
|
+
|
|
3
|
+
If you need to fill out a PDF form, first check to see if the PDF has fillable form fields. Run this script from this file's directory:
|
|
4
|
+
`python scripts/check_fillable_fields <file.pdf>`, and depending on the result go to either the "Fillable fields" or "Non-fillable fields" and follow those instructions.
|
|
5
|
+
|
|
6
|
+
# Fillable fields
|
|
7
|
+
If the PDF has fillable form fields:
|
|
8
|
+
- Run this script from this file's directory: `python scripts/extract_form_field_info.py <input.pdf> <field_info.json>`. It will create a JSON file with a list of fields in this format:
|
|
9
|
+
```
|
|
10
|
+
[
|
|
11
|
+
{
|
|
12
|
+
"field_id": (unique ID for the field),
|
|
13
|
+
"page": (page number, 1-based),
|
|
14
|
+
"rect": ([left, bottom, right, top] bounding box in PDF coordinates, y=0 is the bottom of the page),
|
|
15
|
+
"type": ("text", "checkbox", "radio_group", or "choice"),
|
|
16
|
+
},
|
|
17
|
+
// Checkboxes have "checked_value" and "unchecked_value" properties:
|
|
18
|
+
{
|
|
19
|
+
"field_id": (unique ID for the field),
|
|
20
|
+
"page": (page number, 1-based),
|
|
21
|
+
"type": "checkbox",
|
|
22
|
+
"checked_value": (Set the field to this value to check the checkbox),
|
|
23
|
+
"unchecked_value": (Set the field to this value to uncheck the checkbox),
|
|
24
|
+
},
|
|
25
|
+
// Radio groups have a "radio_options" list with the possible choices.
|
|
26
|
+
{
|
|
27
|
+
"field_id": (unique ID for the field),
|
|
28
|
+
"page": (page number, 1-based),
|
|
29
|
+
"type": "radio_group",
|
|
30
|
+
"radio_options": [
|
|
31
|
+
{
|
|
32
|
+
"value": (set the field to this value to select this radio option),
|
|
33
|
+
"rect": (bounding box for the radio button for this option)
|
|
34
|
+
},
|
|
35
|
+
// Other radio options
|
|
36
|
+
]
|
|
37
|
+
},
|
|
38
|
+
// Multiple choice fields have a "choice_options" list with the possible choices:
|
|
39
|
+
{
|
|
40
|
+
"field_id": (unique ID for the field),
|
|
41
|
+
"page": (page number, 1-based),
|
|
42
|
+
"type": "choice",
|
|
43
|
+
"choice_options": [
|
|
44
|
+
{
|
|
45
|
+
"value": (set the field to this value to select this option),
|
|
46
|
+
"text": (display text of the option)
|
|
47
|
+
},
|
|
48
|
+
// Other choice options
|
|
49
|
+
],
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
```
|
|
53
|
+
- Convert the PDF to PNGs (one image for each page) with this script (run from this file's directory):
|
|
54
|
+
`python scripts/convert_pdf_to_images.py <file.pdf> <output_directory>`
|
|
55
|
+
Then analyze the images to determine the purpose of each form field (make sure to convert the bounding box PDF coordinates to image coordinates).
|
|
56
|
+
- Create a `field_values.json` file in this format with the values to be entered for each field:
|
|
57
|
+
```
|
|
58
|
+
[
|
|
59
|
+
{
|
|
60
|
+
"field_id": "last_name", // Must match the field_id from `extract_form_field_info.py`
|
|
61
|
+
"description": "The user's last name",
|
|
62
|
+
"page": 1, // Must match the "page" value in field_info.json
|
|
63
|
+
"value": "Simpson"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"field_id": "Checkbox12",
|
|
67
|
+
"description": "Checkbox to be checked if the user is 18 or over",
|
|
68
|
+
"page": 1,
|
|
69
|
+
"value": "/On" // If this is a checkbox, use its "checked_value" value to check it. If it's a radio button group, use one of the "value" values in "radio_options".
|
|
70
|
+
},
|
|
71
|
+
// more fields
|
|
72
|
+
]
|
|
73
|
+
```
|
|
74
|
+
- Run the `fill_fillable_fields.py` script from this file's directory to create a filled-in PDF:
|
|
75
|
+
`python scripts/fill_fillable_fields.py <input pdf> <field_values.json> <output pdf>`
|
|
76
|
+
This script will verify that the field IDs and values you provide are valid; if it prints error messages, correct the appropriate fields and try again.
|
|
77
|
+
|
|
78
|
+
# Non-fillable fields
|
|
79
|
+
If the PDF doesn't have fillable form fields, you'll add text annotations. First try to extract coordinates from the PDF structure (more accurate), then fall back to visual estimation if needed.
|
|
80
|
+
|
|
81
|
+
## Step 1: Try Structure Extraction First
|
|
82
|
+
|
|
83
|
+
Run this script to extract text labels, lines, and checkboxes with their exact PDF coordinates:
|
|
84
|
+
`python scripts/extract_form_structure.py <input.pdf> form_structure.json`
|
|
85
|
+
|
|
86
|
+
This creates a JSON file containing:
|
|
87
|
+
- **labels**: Every text element with exact coordinates (x0, top, x1, bottom in PDF points)
|
|
88
|
+
- **lines**: Horizontal lines that define row boundaries
|
|
89
|
+
- **checkboxes**: Small square rectangles that are checkboxes (with center coordinates)
|
|
90
|
+
- **row_boundaries**: Row top/bottom positions calculated from horizontal lines
|
|
91
|
+
|
|
92
|
+
**Check the results**: If `form_structure.json` has meaningful labels (text elements that correspond to form fields), use **Approach A: Structure-Based Coordinates**. If the PDF is scanned/image-based and has few or no labels, use **Approach B: Visual Estimation**.
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## Approach A: Structure-Based Coordinates (Preferred)
|
|
97
|
+
|
|
98
|
+
Use this when `extract_form_structure.py` found text labels in the PDF.
|
|
99
|
+
|
|
100
|
+
### A.1: Analyze the Structure
|
|
101
|
+
|
|
102
|
+
Read form_structure.json and identify:
|
|
103
|
+
|
|
104
|
+
1. **Label groups**: Adjacent text elements that form a single label (e.g., "Last" + "Name")
|
|
105
|
+
2. **Row structure**: Labels with similar `top` values are in the same row
|
|
106
|
+
3. **Field columns**: Entry areas start after label ends (x0 = label.x1 + gap)
|
|
107
|
+
4. **Checkboxes**: Use the checkbox coordinates directly from the structure
|
|
108
|
+
|
|
109
|
+
**Coordinate system**: PDF coordinates where y=0 is at TOP of page, y increases downward.
|
|
110
|
+
|
|
111
|
+
### A.2: Check for Missing Elements
|
|
112
|
+
|
|
113
|
+
The structure extraction may not detect all form elements. Common cases:
|
|
114
|
+
- **Circular checkboxes**: Only square rectangles are detected as checkboxes
|
|
115
|
+
- **Complex graphics**: Decorative elements or non-standard form controls
|
|
116
|
+
- **Faded or light-colored elements**: May not be extracted
|
|
117
|
+
|
|
118
|
+
If you see form fields in the PDF images that aren't in form_structure.json, you'll need to use **visual analysis** for those specific fields (see "Hybrid Approach" below).
|
|
119
|
+
|
|
120
|
+
### A.3: Create fields.json with PDF Coordinates
|
|
121
|
+
|
|
122
|
+
For each field, calculate entry coordinates from the extracted structure:
|
|
123
|
+
|
|
124
|
+
**Text fields:**
|
|
125
|
+
- entry x0 = label x1 + 5 (small gap after label)
|
|
126
|
+
- entry x1 = next label's x0, or row boundary
|
|
127
|
+
- entry top = same as label top
|
|
128
|
+
- entry bottom = row boundary line below, or label bottom + row_height
|
|
129
|
+
|
|
130
|
+
**Checkboxes:**
|
|
131
|
+
- Use the checkbox rectangle coordinates directly from form_structure.json
|
|
132
|
+
- entry_bounding_box = [checkbox.x0, checkbox.top, checkbox.x1, checkbox.bottom]
|
|
133
|
+
|
|
134
|
+
Create fields.json using `pdf_width` and `pdf_height` (signals PDF coordinates):
|
|
135
|
+
```json
|
|
136
|
+
{
|
|
137
|
+
"pages": [
|
|
138
|
+
{"page_number": 1, "pdf_width": 612, "pdf_height": 792}
|
|
139
|
+
],
|
|
140
|
+
"form_fields": [
|
|
141
|
+
{
|
|
142
|
+
"page_number": 1,
|
|
143
|
+
"description": "Last name entry field",
|
|
144
|
+
"field_label": "Last Name",
|
|
145
|
+
"label_bounding_box": [43, 63, 87, 73],
|
|
146
|
+
"entry_bounding_box": [92, 63, 260, 79],
|
|
147
|
+
"entry_text": {"text": "Smith", "font_size": 10}
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"page_number": 1,
|
|
151
|
+
"description": "US Citizen Yes checkbox",
|
|
152
|
+
"field_label": "Yes",
|
|
153
|
+
"label_bounding_box": [260, 200, 280, 210],
|
|
154
|
+
"entry_bounding_box": [285, 197, 292, 205],
|
|
155
|
+
"entry_text": {"text": "X"}
|
|
156
|
+
}
|
|
157
|
+
]
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
**Important**: Use `pdf_width`/`pdf_height` and coordinates directly from form_structure.json.
|
|
162
|
+
|
|
163
|
+
### A.4: Validate Bounding Boxes
|
|
164
|
+
|
|
165
|
+
Before filling, check your bounding boxes for errors:
|
|
166
|
+
`python scripts/check_bounding_boxes.py fields.json`
|
|
167
|
+
|
|
168
|
+
This checks for intersecting bounding boxes and entry boxes that are too small for the font size. Fix any reported errors before filling.
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## Approach B: Visual Estimation (Fallback)
|
|
173
|
+
|
|
174
|
+
Use this when the PDF is scanned/image-based and structure extraction found no usable text labels (e.g., all text shows as "(cid:X)" patterns).
|
|
175
|
+
|
|
176
|
+
### B.1: Convert PDF to Images
|
|
177
|
+
|
|
178
|
+
`python scripts/convert_pdf_to_images.py <input.pdf> <images_dir/>`
|
|
179
|
+
|
|
180
|
+
### B.2: Initial Field Identification
|
|
181
|
+
|
|
182
|
+
Examine each page image to identify form sections and get **rough estimates** of field locations:
|
|
183
|
+
- Form field labels and their approximate positions
|
|
184
|
+
- Entry areas (lines, boxes, or blank spaces for text input)
|
|
185
|
+
- Checkboxes and their approximate locations
|
|
186
|
+
|
|
187
|
+
For each field, note approximate pixel coordinates (they don't need to be precise yet).
|
|
188
|
+
|
|
189
|
+
### B.3: Zoom Refinement (CRITICAL for accuracy)
|
|
190
|
+
|
|
191
|
+
For each field, crop a region around the estimated position to refine coordinates precisely.
|
|
192
|
+
|
|
193
|
+
**Create a zoomed crop using ImageMagick:**
|
|
194
|
+
```bash
|
|
195
|
+
magick <page_image> -crop <width>x<height>+<x>+<y> +repage <crop_output.png>
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
Where:
|
|
199
|
+
- `<x>, <y>` = top-left corner of crop region (use your rough estimate minus padding)
|
|
200
|
+
- `<width>, <height>` = size of crop region (field area plus ~50px padding on each side)
|
|
201
|
+
|
|
202
|
+
**Example:** To refine a "Name" field estimated around (100, 150):
|
|
203
|
+
```bash
|
|
204
|
+
magick images_dir/page_1.png -crop 300x80+50+120 +repage crops/name_field.png
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
(Note: if the `magick` command isn't available, try `convert` with the same arguments).
|
|
208
|
+
|
|
209
|
+
**Examine the cropped image** to determine precise coordinates:
|
|
210
|
+
1. Identify the exact pixel where the entry area begins (after the label)
|
|
211
|
+
2. Identify where the entry area ends (before next field or edge)
|
|
212
|
+
3. Identify the top and bottom of the entry line/box
|
|
213
|
+
|
|
214
|
+
**Convert crop coordinates back to full image coordinates:**
|
|
215
|
+
- full_x = crop_x + crop_offset_x
|
|
216
|
+
- full_y = crop_y + crop_offset_y
|
|
217
|
+
|
|
218
|
+
Example: If the crop started at (50, 120) and the entry box starts at (52, 18) within the crop:
|
|
219
|
+
- entry_x0 = 52 + 50 = 102
|
|
220
|
+
- entry_top = 18 + 120 = 138
|
|
221
|
+
|
|
222
|
+
**Repeat for each field**, grouping nearby fields into single crops when possible.
|
|
223
|
+
|
|
224
|
+
### B.4: Create fields.json with Refined Coordinates
|
|
225
|
+
|
|
226
|
+
Create fields.json using `image_width` and `image_height` (signals image coordinates):
|
|
227
|
+
```json
|
|
228
|
+
{
|
|
229
|
+
"pages": [
|
|
230
|
+
{"page_number": 1, "image_width": 1700, "image_height": 2200}
|
|
231
|
+
],
|
|
232
|
+
"form_fields": [
|
|
233
|
+
{
|
|
234
|
+
"page_number": 1,
|
|
235
|
+
"description": "Last name entry field",
|
|
236
|
+
"field_label": "Last Name",
|
|
237
|
+
"label_bounding_box": [120, 175, 242, 198],
|
|
238
|
+
"entry_bounding_box": [255, 175, 720, 218],
|
|
239
|
+
"entry_text": {"text": "Smith", "font_size": 10}
|
|
240
|
+
}
|
|
241
|
+
]
|
|
242
|
+
}
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
**Important**: Use `image_width`/`image_height` and the refined pixel coordinates from the zoom analysis.
|
|
246
|
+
|
|
247
|
+
### B.5: Validate Bounding Boxes
|
|
248
|
+
|
|
249
|
+
Before filling, check your bounding boxes for errors:
|
|
250
|
+
`python scripts/check_bounding_boxes.py fields.json`
|
|
251
|
+
|
|
252
|
+
This checks for intersecting bounding boxes and entry boxes that are too small for the font size. Fix any reported errors before filling.
|
|
253
|
+
|
|
254
|
+
---
|
|
255
|
+
|
|
256
|
+
## Hybrid Approach: Structure + Visual
|
|
257
|
+
|
|
258
|
+
Use this when structure extraction works for most fields but misses some elements (e.g., circular checkboxes, unusual form controls).
|
|
259
|
+
|
|
260
|
+
1. **Use Approach A** for fields that were detected in form_structure.json
|
|
261
|
+
2. **Convert PDF to images** for visual analysis of missing fields
|
|
262
|
+
3. **Use zoom refinement** (from Approach B) for the missing fields
|
|
263
|
+
4. **Combine coordinates**: For fields from structure extraction, use `pdf_width`/`pdf_height`. For visually-estimated fields, you must convert image coordinates to PDF coordinates:
|
|
264
|
+
- pdf_x = image_x * (pdf_width / image_width)
|
|
265
|
+
- pdf_y = image_y * (pdf_height / image_height)
|
|
266
|
+
5. **Use a single coordinate system** in fields.json - convert all to PDF coordinates with `pdf_width`/`pdf_height`
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
## Step 2: Validate Before Filling
|
|
271
|
+
|
|
272
|
+
**Always validate bounding boxes before filling:**
|
|
273
|
+
`python scripts/check_bounding_boxes.py fields.json`
|
|
274
|
+
|
|
275
|
+
This checks for:
|
|
276
|
+
- Intersecting bounding boxes (which would cause overlapping text)
|
|
277
|
+
- Entry boxes that are too small for the specified font size
|
|
278
|
+
|
|
279
|
+
Fix any reported errors in fields.json before proceeding.
|
|
280
|
+
|
|
281
|
+
## Step 3: Fill the Form
|
|
282
|
+
|
|
283
|
+
The fill script auto-detects the coordinate system and handles conversion:
|
|
284
|
+
`python scripts/fill_pdf_form_with_annotations.py <input.pdf> fields.json <output.pdf>`
|
|
285
|
+
|
|
286
|
+
## Step 4: Verify Output
|
|
287
|
+
|
|
288
|
+
Convert the filled PDF to images and verify text placement:
|
|
289
|
+
`python scripts/convert_pdf_to_images.py <output.pdf> <verify_images/>`
|
|
290
|
+
|
|
291
|
+
If text is mispositioned:
|
|
292
|
+
- **Approach A**: Check that you're using PDF coordinates from form_structure.json with `pdf_width`/`pdf_height`
|
|
293
|
+
- **Approach B**: Check that image dimensions match and coordinates are accurate pixels
|
|
294
|
+
- **Hybrid**: Ensure coordinate conversions are correct for visually-estimated fields
|