pdf2svg wrapper¶
tinyvdiff.pdf2svg
¶
PDF2SVG
¶
Wrapper for the pdf2svg command line tool.
__init__(executable_path=None)
¶
Initialize PDF2SVG wrapper.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
executable_path
|
str | None
|
Optional path to pdf2svg executable. If None, will attempt to locate it. |
None
|
Raises:
Type | Description |
---|---|
FileNotFoundError
|
If pdf2svg executable from the canonical locations can't be found, or if a custom path is provided but does not exist. |
convert(input_path, output_path=None, page=None)
¶
Convert PDF to SVG using pdf2svg.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_path
|
str | Path
|
Path to input PDF file. |
required |
output_path
|
str | Path | None
|
Optional path for output SVG file. If None, uses input path with .svg extension. |
None
|
page
|
int | None
|
Optional page number to convert (starting from 1). |
None
|
Returns:
Type | Description |
---|---|
Path
|
Path to generated SVG file |
Raises:
Type | Description |
---|---|
CalledProcessError
|
If pdf2svg conversion fails. |
ValueError
|
If page number is less than 1. |
FileNotFoundError
|
If input file doesn't exist. |
is_available()
classmethod
¶
Check if pdf2svg is available on the system.
Returns:
Type | Description |
---|---|
bool
|
True if pdf2svg executable can be found, False otherwise. |