{"id":"8f36eac6-534e-4053-b429-43d751a67df1","shortId":"3NGsaK","kind":"skill","title":"pdf-official","tagline":"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.","description":"# PDF Processing Guide\n\n## Overview\n\nThis 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.\n\n## Quick Start\n\n```python\nfrom pypdf import PdfReader, PdfWriter\n\n# Read a PDF\nreader = PdfReader(\"document.pdf\")\nprint(f\"Pages: {len(reader.pages)}\")\n\n# Extract text\ntext = \"\"\nfor page in reader.pages:\n    text += page.extract_text()\n```\n\n## Python Libraries\n\n### pypdf - Basic Operations\n\n#### Merge PDFs\n```python\nfrom pypdf import PdfWriter, PdfReader\n\nwriter = PdfWriter()\nfor pdf_file in [\"doc1.pdf\", \"doc2.pdf\", \"doc3.pdf\"]:\n    reader = PdfReader(pdf_file)\n    for page in reader.pages:\n        writer.add_page(page)\n\nwith open(\"merged.pdf\", \"wb\") as output:\n    writer.write(output)\n```\n\n#### Split PDF\n```python\nreader = PdfReader(\"input.pdf\")\nfor i, page in enumerate(reader.pages):\n    writer = PdfWriter()\n    writer.add_page(page)\n    with open(f\"page_{i+1}.pdf\", \"wb\") as output:\n        writer.write(output)\n```\n\n#### Extract Metadata\n```python\nreader = PdfReader(\"document.pdf\")\nmeta = reader.metadata\nprint(f\"Title: {meta.title}\")\nprint(f\"Author: {meta.author}\")\nprint(f\"Subject: {meta.subject}\")\nprint(f\"Creator: {meta.creator}\")\n```\n\n#### Rotate Pages\n```python\nreader = PdfReader(\"input.pdf\")\nwriter = PdfWriter()\n\npage = reader.pages[0]\npage.rotate(90)  # Rotate 90 degrees clockwise\nwriter.add_page(page)\n\nwith open(\"rotated.pdf\", \"wb\") as output:\n    writer.write(output)\n```\n\n### pdfplumber - Text and Table Extraction\n\n#### Extract Text with Layout\n```python\nimport pdfplumber\n\nwith pdfplumber.open(\"document.pdf\") as pdf:\n    for page in pdf.pages:\n        text = page.extract_text()\n        print(text)\n```\n\n#### Extract Tables\n```python\nwith pdfplumber.open(\"document.pdf\") as pdf:\n    for i, page in enumerate(pdf.pages):\n        tables = page.extract_tables()\n        for j, table in enumerate(tables):\n            print(f\"Table {j+1} on page {i+1}:\")\n            for row in table:\n                print(row)\n```\n\n#### Advanced Table Extraction\n```python\nimport pandas as pd\n\nwith pdfplumber.open(\"document.pdf\") as pdf:\n    all_tables = []\n    for page in pdf.pages:\n        tables = page.extract_tables()\n        for table in tables:\n            if table:  # Check if table is not empty\n                df = pd.DataFrame(table[1:], columns=table[0])\n                all_tables.append(df)\n\n# Combine all tables\nif all_tables:\n    combined_df = pd.concat(all_tables, ignore_index=True)\n    combined_df.to_excel(\"extracted_tables.xlsx\", index=False)\n```\n\n### reportlab - Create PDFs\n\n#### Basic PDF Creation\n```python\nfrom reportlab.lib.pagesizes import letter\nfrom reportlab.pdfgen import canvas\n\nc = canvas.Canvas(\"hello.pdf\", pagesize=letter)\nwidth, height = letter\n\n# Add text\nc.drawString(100, height - 100, \"Hello World!\")\nc.drawString(100, height - 120, \"This is a PDF created with reportlab\")\n\n# Add a line\nc.line(100, height - 140, 400, height - 140)\n\n# Save\nc.save()\n```\n\n#### Create PDF with Multiple Pages\n```python\nfrom reportlab.lib.pagesizes import letter\nfrom reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, PageBreak\nfrom reportlab.lib.styles import getSampleStyleSheet\n\ndoc = SimpleDocTemplate(\"report.pdf\", pagesize=letter)\nstyles = getSampleStyleSheet()\nstory = []\n\n# Add content\ntitle = Paragraph(\"Report Title\", styles['Title'])\nstory.append(title)\nstory.append(Spacer(1, 12))\n\nbody = Paragraph(\"This is the body of the report. \" * 20, styles['Normal'])\nstory.append(body)\nstory.append(PageBreak())\n\n# Page 2\nstory.append(Paragraph(\"Page 2\", styles['Heading1']))\nstory.append(Paragraph(\"Content for page 2\", styles['Normal']))\n\n# Build PDF\ndoc.build(story)\n```\n\n## Command-Line Tools\n\n### pdftotext (poppler-utils)\n```bash\n# Extract text\npdftotext input.pdf output.txt\n\n# Extract text preserving layout\npdftotext -layout input.pdf output.txt\n\n# Extract specific pages\npdftotext -f 1 -l 5 input.pdf output.txt  # Pages 1-5\n```\n\n### qpdf\n```bash\n# Merge PDFs\nqpdf --empty --pages file1.pdf file2.pdf -- merged.pdf\n\n# Split pages\nqpdf input.pdf --pages . 1-5 -- pages1-5.pdf\nqpdf input.pdf --pages . 6-10 -- pages6-10.pdf\n\n# Rotate pages\nqpdf input.pdf output.pdf --rotate=+90:1  # Rotate page 1 by 90 degrees\n\n# Remove password\nqpdf --password=mypassword --decrypt encrypted.pdf decrypted.pdf\n```\n\n### pdftk (if available)\n```bash\n# Merge\npdftk file1.pdf file2.pdf cat output merged.pdf\n\n# Split\npdftk input.pdf burst\n\n# Rotate\npdftk input.pdf rotate 1east output rotated.pdf\n```\n\n## Common Tasks\n\n### Extract Text from Scanned PDFs\n```python\n# Requires: pip install pytesseract pdf2image\nimport pytesseract\nfrom pdf2image import convert_from_path\n\n# Convert PDF to images\nimages = convert_from_path('scanned.pdf')\n\n# OCR each page\ntext = \"\"\nfor i, image in enumerate(images):\n    text += f\"Page {i+1}:\\n\"\n    text += pytesseract.image_to_string(image)\n    text += \"\\n\\n\"\n\nprint(text)\n```\n\n### Add Watermark\n```python\nfrom pypdf import PdfReader, PdfWriter\n\n# Create watermark (or load existing)\nwatermark = PdfReader(\"watermark.pdf\").pages[0]\n\n# Apply to all pages\nreader = PdfReader(\"document.pdf\")\nwriter = PdfWriter()\n\nfor page in reader.pages:\n    page.merge_page(watermark)\n    writer.add_page(page)\n\nwith open(\"watermarked.pdf\", \"wb\") as output:\n    writer.write(output)\n```\n\n### Extract Images\n```bash\n# Using pdfimages (poppler-utils)\npdfimages -j input.pdf output_prefix\n\n# This extracts all images as output_prefix-000.jpg, output_prefix-001.jpg, etc.\n```\n\n### Password Protection\n```python\nfrom pypdf import PdfReader, PdfWriter\n\nreader = PdfReader(\"input.pdf\")\nwriter = PdfWriter()\n\nfor page in reader.pages:\n    writer.add_page(page)\n\n# Add password\nwriter.encrypt(\"userpassword\", \"ownerpassword\")\n\nwith open(\"encrypted.pdf\", \"wb\") as output:\n    writer.write(output)\n```\n\n## Quick Reference\n\n| Task | Best Tool | Command/Code |\n|------|-----------|--------------|\n| Merge PDFs | pypdf | `writer.add_page(page)` |\n| Split PDFs | pypdf | One page per file |\n| Extract text | pdfplumber | `page.extract_text()` |\n| Extract tables | pdfplumber | `page.extract_tables()` |\n| Create PDFs | reportlab | Canvas or Platypus |\n| Command line merge | qpdf | `qpdf --empty --pages ...` |\n| OCR scanned PDFs | pytesseract | Convert to image first |\n| Fill PDF forms | pdf-lib or pypdf (see forms.md) | See forms.md |\n\n## Next Steps\n\n- For advanced pypdfium2 usage, see reference.md\n- For JavaScript libraries (pdf-lib), see reference.md\n- If you need to fill out a PDF form, follow the instructions in forms.md\n- For troubleshooting guides, see reference.md\n\n## When to Use\nThis skill is applicable to execute the workflow or actions described in the overview.\n\n## Limitations\n- Use this skill only when the task clearly matches the scope described above.\n- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.\n- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.","tags":["pdf","official","antigravity","awesome","skills","sickn33","agent-skills","agentic-skills","ai-agent-skills","ai-agents","ai-coding","ai-workflows"],"capabilities":["skill","source-sickn33","skill-pdf-official","topic-agent-skills","topic-agentic-skills","topic-ai-agent-skills","topic-ai-agents","topic-ai-coding","topic-ai-workflows","topic-antigravity","topic-antigravity-skills","topic-claude-code","topic-claude-code-skills","topic-codex-cli","topic-codex-skills"],"categories":["antigravity-awesome-skills"],"synonyms":[],"warnings":[],"endpointUrl":"https://skills.sh/sickn33/antigravity-awesome-skills/pdf-official","protocol":"skill","transport":"skills-sh","auth":{"type":"none","details":{"cli":"npx skills add sickn33/antigravity-awesome-skills","source_repo":"https://github.com/sickn33/antigravity-awesome-skills","install_from":"skills.sh"}},"qualityScore":"0.700","qualityRationale":"deterministic score 0.70 from registry signals: · indexed on github topic:agent-skills · 34616 github stars · SKILL.md body (7,151 chars)","verified":false,"liveness":"unknown","lastLivenessCheck":null,"agentReviews":{"count":0,"score_avg":null,"cost_usd_avg":null,"success_rate":null,"latency_p50_ms":null,"narrative_summary":null,"summary_updated_at":null},"enrichmentModel":"deterministic:skill-github:v1","enrichmentVersion":1,"enrichedAt":"2026-04-23T00:51:22.854Z","embedding":null,"createdAt":"2026-04-18T21:42:15.260Z","updatedAt":"2026-04-23T00:51:22.854Z","lastSeenAt":"2026-04-23T00:51:22.854Z","tsv":"'+1':180,292,296,645 '+90':563 '-10':555 '-5':532,549 '0':221,343,674 '1':340,460,525,531,548,564,567 '100':391,393,397,411 '12':461 '120':399 '140':413,416 '1east':598 '2':479,483,491 '20':471 '400':414 '5':527 '6':554 '90':223,225,569 'action':865 'add':388,407,448,657,743 'advanc':20,64,303,821 'all_tables.append':344 'appli':675 'applic':859 'ask':903 'author':201 'avail':581 'bash':506,534,582,704 'basic':120,368 'best':759 'bodi':462,467,475 'boundari':911 'build':494 'burst':593 'c':380 'c.drawstring':390,396 'c.line':410 'c.save':418 'canva':379,788 'canvas.canvas':381 'cat':587 'check':331 'clarif':905 'clear':878 'clockwis':227 'column':341 'combin':346,352 'combined_df.to':360 'command':16,60,499,791 'command-lin':15,59,498 'command/code':761 'common':601 'content':449,488 'convert':619,622,627,802 'cover':6,50 'creat':366,404,419,665,785 'creation':370 'creator':209 'criteria':914 'decrypt':576 'decrypted.pdf':578 'degre':226,570 'describ':866,882 'detail':25,69 'df':337,345,353 'doc':440 'doc.build':496 'doc1.pdf':136 'doc2.pdf':137 'doc3.pdf':138 'document.pdf':101,192,253,270,313,681 'empti':336,538,796 'encrypted.pdf':577,750 'enumer':168,277,286,639 'environ':894 'environment-specif':893 'essenti':7,51 'etc':722 'exampl':26,70 'excel':361 'execut':861 'exist':669 'expert':899 'extract':107,187,243,244,265,305,507,512,520,603,702,716,775,780 'extracted_tables.xlsx':362 'f':103,177,196,200,204,208,289,524,642 'fals':364 'featur':21,65 'file':134,142,774 'file1.pdf':540,585 'file2.pdf':541,586 'fill':33,77,806,838 'first':805 'follow':41,85,843 'form':37,81,808,842 'forms.md':39,83,815,817,847 'getsamplestylesheet':439,446 'guid':5,46,49,850 'heading1':485 'height':386,392,398,412,415 'hello':394 'hello.pdf':382 'ignor':357 'imag':625,626,637,640,651,703,718,804 'import':93,127,249,307,374,378,427,431,438,614,618,662,728 'index':358,363 'input':908 'input.pdf':163,216,510,518,528,546,552,560,592,596,712,733 'instal':611 'instruct':43,87,845 'j':283,291,711 'javascript':22,66,827 'l':526 'layout':247,515,517 'len':105 'letter':375,384,387,428,444 'lib':811,831 'librari':13,23,57,67,118,828 'limit':870 'line':17,61,409,500,792 'load':668 'match':879 'merg':122,535,583,762,793 'merged.pdf':152,542,589 'meta':193 'meta.author':202 'meta.creator':210 'meta.subject':206 'meta.title':198 'metadata':188 'miss':916 'multipl':422 'mypassword':575 'n':646,653,654 'need':31,75,836 'next':818 'normal':473,493 'ocr':631,798 'offici':3 'one':771 'open':151,176,232,695,749 'oper':10,54,121 'output':155,157,184,186,236,238,588,599,699,701,713,753,755,888 'output.pdf':561 'output.txt':511,519,529 'output_prefix-000.jpg':720 'output_prefix-001.jpg':721 'overview':47,869 'ownerpassword':747 'page':104,111,144,148,149,166,173,174,178,212,219,229,230,257,275,294,319,423,478,482,490,522,530,539,544,547,553,558,566,633,643,673,678,685,689,692,693,737,741,742,766,767,772,797 'page.extract':115,261,280,323,778,783 'page.merge':688 'page.rotate':222 'pagebreak':435,477 'pages':383,443 'pages1-5.pdf':550 'pages6-10.pdf':556 'panda':308 'paragraph':433,451,463,481,487 'password':572,574,723,744 'path':621,629 'pd':310 'pd.concat':354 'pd.dataframe':338 'pdf':2,8,36,44,52,80,98,133,141,159,181,255,272,315,369,403,420,495,623,807,810,830,841 'pdf-lib':809,829 'pdf-offici':1 'pdf.pages':259,278,321 'pdf2image':613,617 'pdfimag':706,710 'pdfplumber':239,250,777,782 'pdfplumber.open':252,269,312 'pdfreader':94,100,129,140,162,191,215,663,671,680,729,732 'pdfs':123,367,536,607,763,769,786,800 'pdftk':579,584,591,595 'pdftotext':502,509,516,523 'pdfwriter':95,128,131,171,218,664,683,730,735 'per':773 'permiss':909 'pip':610 'platypus':790 'poppler':504,708 'poppler-util':503,707 'prefix':714 'preserv':514 'print':102,195,199,203,207,263,288,301,655 'process':9,45,53 'protect':724 'pypdf':92,119,126,661,727,764,770,813 'pypdfium2':822 'pytesseract':612,615,801 'pytesseract.image':648 'python':12,56,90,117,124,160,189,213,248,267,306,371,424,608,659,725 'qpdf':533,537,545,551,559,573,794,795 'quick':88,756 'read':38,82,96 'reader':99,139,161,190,214,679,731 'reader.metadata':194 'reader.pages':106,113,146,169,220,687,739 'refer':757 'reference.md':28,72,825,833,852 'remov':571 'report':452,470 'report.pdf':442 'reportlab':365,406,787 'reportlab.lib.pagesizes':373,426 'reportlab.lib.styles':437 'reportlab.pdfgen':377 'reportlab.platypus':430 'requir':609,907 'review':900 'rotat':211,224,557,562,565,594,597 'rotated.pdf':233,600 'row':298,302 'safeti':910 'save':417 'scan':606,799 'scanned.pdf':630 'scope':881 'see':27,71,814,816,824,832,851 'simpledoctempl':432,441 'skill':857,873 'skill-pdf-official' 'source-sickn33' 'spacer':434,459 'specif':521,895 'split':158,543,590,768 'start':89 'step':819 'stop':901 'stori':447,497 'story.append':456,458,474,476,480,486 'string':650 'style':445,454,472,484,492 'subject':205 'substitut':891 'success':913 'tabl':242,266,279,281,284,287,290,300,304,317,322,324,326,328,330,333,339,342,348,351,356,781,784 'task':602,758,877 'test':897 'text':108,109,114,116,240,245,260,262,264,389,508,513,604,634,641,647,652,656,776,779 'titl':197,450,453,455,457 'tool':18,62,501,760 'topic-agent-skills' 'topic-agentic-skills' 'topic-ai-agent-skills' 'topic-ai-agents' 'topic-ai-coding' 'topic-ai-workflows' 'topic-antigravity' 'topic-antigravity-skills' 'topic-claude-code' 'topic-claude-code-skills' 'topic-codex-cli' 'topic-codex-skills' 'treat':886 'troubleshoot':849 'true':359 'usag':823 'use':11,55,705,855,871 'userpassword':746 'util':505,709 'valid':896 'watermark':658,666,670,690 'watermark.pdf':672 'watermarked.pdf':696 'wb':153,182,234,697,751 'width':385 'workflow':863 'world':395 'writer':130,170,217,682,734 'writer.add':147,172,228,691,740,765 'writer.encrypt':745 'writer.write':156,185,237,700,754","prices":[{"id":"db755582-9122-47c1-8c8c-48641e2569e2","listingId":"8f36eac6-534e-4053-b429-43d751a67df1","amountUsd":"0","unit":"free","nativeCurrency":null,"nativeAmount":null,"chain":null,"payTo":null,"paymentMethod":"skill-free","isPrimary":true,"details":{"org":"sickn33","category":"antigravity-awesome-skills","install_from":"skills.sh"},"createdAt":"2026-04-18T21:42:15.260Z"}],"sources":[{"listingId":"8f36eac6-534e-4053-b429-43d751a67df1","source":"github","sourceId":"sickn33/antigravity-awesome-skills/pdf-official","sourceUrl":"https://github.com/sickn33/antigravity-awesome-skills/tree/main/skills/pdf-official","isPrimary":false,"firstSeenAt":"2026-04-18T21:42:15.260Z","lastSeenAt":"2026-04-23T00:51:22.854Z"}],"details":{"listingId":"8f36eac6-534e-4053-b429-43d751a67df1","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"sickn33","slug":"pdf-official","github":{"repo":"sickn33/antigravity-awesome-skills","stars":34616,"topics":["agent-skills","agentic-skills","ai-agent-skills","ai-agents","ai-coding","ai-workflows","antigravity","antigravity-skills","claude-code","claude-code-skills","codex-cli","codex-skills","cursor","cursor-skills","developer-tools","gemini-cli","gemini-skills","kiro","mcp","skill-library"],"license":"mit","html_url":"https://github.com/sickn33/antigravity-awesome-skills","pushed_at":"2026-04-22T06:40:00Z","description":"Installable GitHub library of 1,400+ agentic skills for Claude Code, Cursor, Codex CLI, Gemini CLI, Antigravity, and more. Includes installer CLI, bundles, workflows, and official/community skill collections.","skill_md_sha":"e9d206fd5186735f02cd0b090f384c775258db43","skill_md_path":"skills/pdf-official/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/sickn33/antigravity-awesome-skills/tree/main/skills/pdf-official"},"layout":"multi","source":"github","category":"antigravity-awesome-skills","frontmatter":{"name":"pdf-official","description":"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."},"skills_sh_url":"https://skills.sh/sickn33/antigravity-awesome-skills/pdf-official"},"updatedAt":"2026-04-23T00:51:22.854Z"}}