Troubleshooting

Troubleshooting

FontSource, DataSource, and PdfPlugin Raise NotImplementedError When Instantiated Directly

FontSource, DataSource, and PdfPlugin are abstract base classes. Each declares one hook method that the base implementation raises NotImplementedError for by design, and expects a concrete subclass to override:

Base classAbstract hookUse one of these concrete subclasses instead
FontSourceget_font_definitions()FileFontSource, FolderFontSource, MemoryFontSource, SystemFontSource
DataSourceread_bytes() / write_bytes()FileDataSource, StreamDataSource, ByteArrayDataSource
PdfPluginprocess()Merger, Optimizer, Splitter, TextExtractor

If you see NotImplementedError raised from one of these three base classes, the fix is almost always to swap in the matching concrete class. For font discovery, register a concrete source with FontRepository instead of using FontSource directly:

import aspose_pdf

aspose_pdf.FontRepository.add_source(
    aspose_pdf.FolderFontSource("./fonts", scan_subdirectories=True)
)

The same pattern applies to low-code plugins — build a PluginOptions subclass with concrete DataSource inputs/outputs and run it through a concrete plugin, not PdfPlugin itself:

import aspose_pdf

options = aspose_pdf.MergeOptions()
options.add_input(aspose_pdf.FileDataSource("part1.pdf"))
options.add_input(aspose_pdf.FileDataSource("part2.pdf"))
options.add_output(aspose_pdf.FileDataSource("merged.pdf"))
aspose_pdf.Merger().process(options)

Shading.color_at() Raises NotImplementedError on a Bare Shading Instance

Shading — the base class for bounded-region color sampling used by PDF shading patterns — implements color_at() and pattern_color_at() by delegating to an internal _color_at() hook that has no default body. In normal use you never construct Shading yourself: the library’s own PDF parser builds the correct internal subclass for each supported ShadingType when it encounters a shading resource, and returns None for shading types it does not recognize rather than falling back to the base class. The NotImplementedError is only reachable if application code instantiates Shading directly and calls color_at() or pattern_color_at() without subclassing it to provide a real _color_at() implementation.

See Also