How to Fetch Design Patent Views Using the Patent‑Disclosure‑Skill Repository
Call fetch_design_views() from tools/patent_reader/extract/fetch_design_views.py to download, parse, and extract the design-view images from any U.S. or CNIPA design patent.
The patent-disclosure-skill repository by handsomestWei provides a modular Python pipeline for retrieving design patent view images. The system breaks down the workflow into composable, stateless utilities that handle PDF acquisition, figure extraction, and view filtering. This article explains how to fetch design patent views using the actual implementation in the source code.
The Core Pipeline Components
The design patent view retrieval system consists of four interconnected modules located under tools/patent_reader/extract/ and tools/shared/:
fetch_patent_pdf.py— Downloads patent PDFs from USPTO or CNIPA public endpoints with built-in caching and retry logicextract_patent_figures.py— Parses PDF pages usingpdfminer.sixandPyMuPDFto extract raster and vector figuresfetch_design_views.py— Orchestrates the pipeline, filters figures to design-view pages only, and returns processable image objectsstep_to_views.py— Optional post-processor that converts raw images into the skill's view-step format for voice-assistant rendering
How fetch_design_views.py Works
The main entry point fetch_design_views() in tools/patent_reader/extract/fetch_design_views.py executes a five-step pipeline:
- Resolves the patent identifier — Accepts US design patent numbers (format
D123456) or CNIPA design numbers - Downloads the PDF — Delegates to
fetch_patent_pdf()with automatic URL construction and caching totmp/ - Parses figures from pages — Calls
extract_patent_figures()to build a page-to-images mapping - Identifies design-view pages — Detects standard "Design View" headings or front-sheet layout patterns
- Returns image objects — Outputs a list of
PIL.Imageobjects or file paths (controlled byas_pathparameter)
Because each helper is pure-Python and stateless, you can integrate the pipeline into CLI tools, AWS Lambda functions, or local development scripts without external dependencies beyond pdfminer.six and PyMuPDF.
Code Examples
Fetch Design Views as PIL Image Objects
from tools.patent_reader.extract.fetch_design_views import fetch_design_views
patent_number = "D123456" # U.S. design patent format
# Returns list of PIL.Image objects; set as_path=True for file paths instead
design_views = fetch_design_views(patent_number)
for i, img in enumerate(design_views, start=1):
img.save(f"design_view_{i}.png")
print(f"Saved design view {i}: {img.size}")
Use Cached Results to Avoid Repeated Downloads
from tools.patent_reader.extract.fetch_design_views import fetch_design_views
# use_cache=True forces retrieval from tmp/ directory; no network calls
design_views = fetch_design_views("D123456", use_cache=True)
print(f"Retrieved {len(design_views)} views from cache")
Integrate with the Skill's View-Step Renderer
from tools.patent_reader.extract.fetch_design_views import fetch_design_views
from tools.shared.step_to_views import step_to_views
images = fetch_design_views("D123456")
view_steps = step_to_views(images)
# view_steps is now formatted for the Alexa skill's dialogue manager
for step in view_steps:
print(f"Step {step['index']}: {step['description']}")
Key Source Files and Their Roles
| File Path | Purpose |
|---|---|
tools/patent_reader/extract/fetch_design_views.py |
Main orchestrator; calls fetch and extract utilities, filters to design views |
tools/patent_reader/extract/fetch_patent_pdf.py |
HTTP client for USPTO/CNIPA PDFs with retry logic and disk caching |
tools/patent_reader/extract/extract_patent_figures.py |
PDF parser that extracts figures using pdfminer.six and PyMuPDF |
tools/shared/step_to_views.py |
Converts raw PIL images into structured view-step dictionaries |
tools/shared/image_gen.py |
Generates Alexa-compatible image responses from processed views |
Error Handling and Edge Cases
The pipeline handles several real-world conditions:
- Network failures —
fetch_patent_pdf.pyimplements exponential backoff retries - Malformed PDFs —
extract_patent_figures.pygracefully skips unparseable pages - Missing design views — Returns empty list with warning when no "Design View" headings detected
- Identifier format validation — Raises
ValueErrorfor unrecognized patent number patterns
Summary
- The primary entry point for fetching design patent views is
fetch_design_views()intools/patent_reader/extract/fetch_design_views.py - The pipeline downloads PDFs, extracts all figures, then filters to design-view pages automatically
- Set
use_cache=Trueto speed up repeated calls during development - Raw images integrate directly with
step_to_views()fromtools/shared/for voice-assistant deployment
Frequently Asked Questions
What patent number formats does fetch_design_views() accept?
The function accepts U.S. design patents in D123456 format and CNIPA (China) design patents using their national numbering system. Invalid formats raise ValueError with a descriptive message. The identifier resolution logic in fetch_design_views.py automatically routes to the appropriate download endpoint.
Where are downloaded PDFs and extracted images cached?
Files are written to the package's tmp/ directory relative to the repository root. The cache key is derived from the patent number hash. You can inspect or clear this directory manually; the code does not implement automatic cache expiration in the current version.
Can I use this pipeline without the Alexa skill components?
Yes. The fetch_design_views() function has no dependency on step_to_views.py or image_gen.py. It returns standard PIL.Image objects that work with any Python image processing workflow, including OpenCV, matplotlib, or custom web services.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →