| 188 | } |
| 189 | |
| 190 | int main(int argc, char* argv[]) |
| 191 | { |
| 192 | int orig_argc = argc; |
| 193 | |
| 194 | // Initialize loguru |
| 195 | loguru::init(argc, argv); |
| 196 | |
| 197 | try |
| 198 | { |
| 199 | cxxopts::Options options("PDFRenderer", "A program to render PDF pages"); |
| 200 | |
| 201 | // Define the options |
| 202 | options.add_options() |
| 203 | ("i,input", "Input PDF file", cxxopts::value<std::string>()) |
| 204 | ("d,directory","Input directory: render all PDFs found inside it", cxxopts::value<std::string>()) |
| 205 | ("p,page", "Pages to process (default: -1 for all)", cxxopts::value<int>()->default_value("-1")) |
| 206 | ("password", "Password for encrypted files", cxxopts::value<std::string>()) |
| 207 | ("o,output", "Output file or output directory (for -d mode)", cxxopts::value<std::string>()) |
| 208 | ("r,renderer", "Renderer type [NAIVE, BLEND2D] (default: NAIVE)", cxxopts::value<std::string>()->default_value("BLEND2D")) |
| 209 | ("l,loglevel", "Log level [error, warning, info]", cxxopts::value<std::string>()) |
| 210 | ("h,help", "Print usage") |
| 211 | |
| 212 | // ---- render_config ---- |
| 213 | ("render-text", "Render glyph outlines for text cells (default: true)", cxxopts::value<bool>()->implicit_value("true")) |
| 214 | ("draw-text-bbox", "Draw bounding quad around each text cell", cxxopts::value<bool>()->implicit_value("true")) |
| 215 | ("draw-text-basepoint", "Draw the text base point as a small red dot", cxxopts::value<bool>()->implicit_value("true")) |
| 216 | ("fit-glyph-bbox-to-target", |
| 217 | "Uniformly rescale measured glyph outlines so the rendered bbox fits inside the target glyph bbox and matches either its width or height", |
| 218 | cxxopts::value<bool>()->implicit_value("true")) |
| 219 | ("resolve-fonts", "Resolve PDF font names to system fonts (default: true)", cxxopts::value<bool>()->implicit_value("true")) |
| 220 | ("font-similarity-cutoff", "Minimum Jaccard similarity for fuzzy font matching (default: 0.25)", cxxopts::value<float>()) |
| 221 | ("scale", "Canvas scale in multiples of the PDF page size (-1 = disabled)", cxxopts::value<float>()) |
| 222 | ("canvas-width", "Canvas width in pixels (-1 = use page size)", cxxopts::value<int>()) |
| 223 | ("canvas-height", "Canvas height in pixels (-1 = use page size)", cxxopts::value<int>()) |
| 224 | |
| 225 | // ---- decode_config ---- |
| 226 | ("page-boundary", "Page boundary [crop_box, media_box, ...] (default: crop_box)", cxxopts::value<std::string>()) |
| 227 | ("do-sanitization", "Run post-parse sanitization (default: true)", cxxopts::value<bool>()->implicit_value("true")) |
| 228 | ("keep-char-cells", "Keep individual character cells (default: true)", cxxopts::value<bool>()->implicit_value("true")) |
| 229 | ("keep-shapes", "Keep shape items (default: true)", cxxopts::value<bool>()->implicit_value("true")) |
| 230 | ("keep-bitmaps", "Keep bitmap items (default: true)", cxxopts::value<bool>()->implicit_value("true")) |
| 231 | ("max-num-lines", "Cap on number of lines per page (-1 = no cap)", cxxopts::value<int>()) |
| 232 | ("max-num-bitmaps", "Cap on number of bitmaps per page (-1 = no cap)", cxxopts::value<int>()) |
| 233 | ("create-word-cells", "Build word-level cells (default: true)", cxxopts::value<bool>()->implicit_value("true")) |
| 234 | ("create-line-cells", "Build line-level cells (default: true)", cxxopts::value<bool>()->implicit_value("true")) |
| 235 | ("enforce-same-font", "Require same font within a word/line cell (default: true)", cxxopts::value<bool>()->implicit_value("true")) |
| 236 | ("horizontal-cell-tolerance", "Horizontal merge tolerance (default: 1.0)", cxxopts::value<double>()) |
| 237 | ("word-space-factor", "Space-width factor for word merging (default: 0.33)", cxxopts::value<double>()) |
| 238 | ("line-space-factor", "Space-width factor for line merging (default: 1.0)", cxxopts::value<double>()) |
| 239 | ("line-space-factor-with-space", "Space-width factor for line merging with space (default: 0.33)", cxxopts::value<double>()) |
| 240 | ("keep-glyphs", "Keep unmapped GLYPH<...> tokens (default: false)", cxxopts::value<bool>()->implicit_value("true")) |
| 241 | ("keep-qpdf-warnings", "Emit QPDF warnings (default: false)", cxxopts::value<bool>()->implicit_value("true")) |
| 242 | ("extract-font-programs", "Extract embedded font programs for rendering (default: true)", cxxopts::value<bool>()->implicit_value("true")) |
| 243 | ("populate-json", "Populate JSON objects during decode (default: false)", cxxopts::value<bool>()->implicit_value("true")) |
| 244 | ("export-bitmaps", "Export decoded bitmap payloads encountered on each page (default: false)", |
| 245 | cxxopts::value<bool>()->default_value("false")) |
| 246 | ("export-page-pdf", "Export each selected page as a one-page PDF (default: false)", |
| 247 | cxxopts::value<bool>()->default_value("false")); |
nothing calls this directly
no test coverage detected