or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

command-line.mdcontext-management.mdcss-processing.mddocument-processing.mdfile-handling.mdindex.mdpdf-features.mdutilities.mdwsgi-integration.md

command-line.mddocs/

0

# Command Line Interface

1

2

Complete command-line interface for batch processing and integration with shell scripts and automated workflows. Provides direct access to xhtml2pdf conversion capabilities from the command line.

3

4

## Capabilities

5

6

### Main Command Interface

7

8

Primary command-line entry points for HTML-to-PDF conversion.

9

10

```python { .api }

11

def command():

12

"""

13

Main command line entry point mapped to CLI commands.

14

15

Available as both 'pisa' and 'xhtml2pdf' commands after installation.

16

Processes sys.argv and performs conversion based on command-line arguments.

17

"""

18

19

def execute():

20

"""

21

Execute command line conversion with argument parsing.

22

23

Handles all command-line options, file processing, and error reporting.

24

Called internally by command() after argument validation.

25

"""

26

```

27

28

### Usage and Help

29

30

```python { .api }

31

def usage():

32

"""

33

Print command line usage information.

34

35

Displays comprehensive help text including all available options,

36

parameter descriptions, and usage examples.

37

"""

38

```

39

40

### Logging Control

41

42

```python { .api }

43

def showLogging(*, debug=False):

44

"""

45

Enable logging output with optional debug level.

46

47

Args:

48

debug (bool): Enable debug-level logging output

49

"""

50

```

51

52

### Utility Functions

53

54

Additional utility functions for file handling and PDF viewing.

55

56

```python { .api }

57

def startViewer(filename):

58

"""

59

Open PDF file with system default viewer.

60

61

Args:

62

filename (str): Path to PDF file to open

63

64

Note:

65

Works on Windows (startfile) and macOS (open command).

66

On other systems, may require manual PDF viewer configuration.

67

"""

68

69

def makeDataURI(data=None, mimetype=None, filename=None):

70

"""

71

Create data URI from binary data.

72

73

Args:

74

data (bytes): Binary data to encode

75

mimetype (str): MIME type for data (optional if filename provided)

76

filename (str): Filename for MIME type detection (optional if mimetype provided)

77

78

Returns:

79

str: data URI string (data:mimetype;base64,encodeddata)

80

81

Raises:

82

RuntimeError: If neither mimetype nor filename is provided

83

"""

84

85

def makeDataURIFromFile(filename):

86

"""

87

Create data URI from file contents.

88

89

Args:

90

filename (str): Path to file to encode

91

92

Returns:

93

str: data URI string containing file content

94

"""

95

```

96

97

## Command Line Usage

98

99

### Basic Conversion

100

101

```bash

102

# Convert HTML file to PDF

103

xhtml2pdf input.html output.pdf

104

105

# Convert from stdin to stdout

106

echo "<html><body><h1>Hello</h1></body></html>" | xhtml2pdf - -

107

108

# Convert URL to PDF

109

xhtml2pdf "https://example.com" output.pdf

110

```

111

112

### Advanced Options

113

114

```bash

115

# With custom CSS and base path

116

xhtml2pdf --css custom.css --base /path/to/resources input.html output.pdf

117

118

# Enable debug output

119

xhtml2pdf --debug input.html output.pdf

120

121

# Force XML parsing mode

122

xhtml2pdf --xml input.xhtml output.pdf

123

124

# Specify character encoding

125

xhtml2pdf --encoding utf-8 input.html output.pdf

126

```

127

128

### HTTP Configuration

129

130

```bash

131

# Disable SSL certificate checking

132

xhtml2pdf --http_nosslcheck https://example.com output.pdf

133

134

# With custom timeout

135

xhtml2pdf --http_timeout 30 https://example.com output.pdf

136

```

137

138

## Available Options

139

140

- `--base, -b`: Specify base path for relative resources

141

- `--css, -c`: Path to custom default CSS file

142

- `--css-dump`: Output default CSS definitions to stdout

143

- `--debug, -d`: Enable debug output

144

- `--encoding`: Character encoding for input

145

- `--help, -h`: Show help message

146

- `--quiet, -q`: Suppress all output messages

147

- `--start-viewer, -s`: Open PDF in default viewer (Windows/macOS)

148

- `--version`: Show version information

149

- `--warn, -w`: Show warning messages

150

- `--xml, --xhtml, -x`: Force XML/XHTML parsing mode

151

- `--html`: Force HTML parsing mode (default)

152

- `--http_nosslcheck`: Disable SSL certificate verification

153

- `--http_key_file`: SSL client key file

154

- `--http_cert_file`: SSL client certificate file

155

- `--http_source_address`: Source address for HTTP connections

156

- `--http_timeout`: HTTP connection timeout in seconds