Using QuickFix on the command line

On the command line (CLI), pdfToolbox provides the possibility to run a QuickFix without loading the whole pdfToolbox executable, instead, only the part of pdfToolbox is loaded and executed that carries out a QuickFix. This results in significantly shorter launch times. In addition, at least when used/configured accordingly, no files are copied or completely rewritten, again reducing processing time.

In the simplest case, a call on the command line would look like this:

./pdfToolbox --quickfix my_quickfix_config.json my_pdf_file.pdf

Use ./pdfToolbox --help quickfix on the command line for more information (though all other parameters for quickfix are generic pdfToolbox parameters and not specific to QuickFixes).

The second parameter – called my_pdf_file.pdf in the example – specifies the PDF file to process. It is intentional in the example, that no output file is specified. Instead, the original file will be modified (in thee form of an incremental update). This guarantees to fastest possible execution. If an output PDF file is specified, the original PDF will first be copied to the destination, and than that copy of the PDF file be processed 'in situ'.

The first parameter – called my_quickfix_config.json in the example, contains a JSON expression defining the QuickFix instructions to be carried out. The syntax for each QuickFix feature is shown in the article QuickFix features.

Use "Log profile execution" to capture a JSON representation of a QuickFix in pdfToolbox Desktop

The easiest way to construct a QuickFix configuration file as a JSON expression is to create a ProcessPlan with a QuickFix step in pdfToolbox Desktop. Running that Process Plan with "Log profile execution" turned on, the log output will also contain th QuickFix definition as a JSON file:

Use code sample

Another option to create a QuickFix configuration file is to use the code block below, and to edit and adjust it as needed.

JSON code examples with explanations for all QuickFix features

{
	"quickfixes": [
// "rename_spot"
//		"operator": "regex|begins_with|contains|does_not_begin_with|does_not_contain|does_not_end_with|ends_with|equal_to|is_contained_in|is_not_contained_in|unequal_to"
//		"old_spot":<text>
//		"new_spot":<text>
		{
			"quickfix": "rename_spot",
			"version": 1.0,
			"instructions": [
				{
					"operator": "regex",
					"old_spot": ".*",
					"new_spot": "Prefix_$0"
				}
			]
		},
// "adjust_spot"
//		"operator": "regex|begins_with|contains|does_not_begin_with|does_not_contain|does_not_end_with|ends_with|equal_to|is_contained_in|is_not_contained_in|unequal_to"
//		"old_spot":<text>
//		"new_spot":<text>
//		"alt": "DeviceGray|DeviceRGB|DeviceCMYK|Lab_D50|Lab_D65|sRGB|<icc-profil-file-path>"
//		"c0":<number>
//		"c1":<number>
//		"c2":<number>
//		"c3":<number>
		{
			"quickfix": "adjust_spot",
			"version": 1.0,
			"instructions": [
				{
					"operator": "equal_to",
					"old_spot": "Pantone 101 C alt",
					"new_spot": "Cyan",
					"alt": "DeviceCMYK",
					"c0": 1.0,
					"c1": 0,
					"c2": 0,
					"c3": 0
				}
			]
		},
// "merge_spot"
//		"operator1": "regex|begins_with|contains|does_not_begin_with|does_not_contain|does_not_end_with|ends_with|equal_to|is_contained_in|is_not_contained_in|unequal_to"
//		"master_spot":<text>
//		"operator2": "regex|begins_with|contains|does_not_begin_with|does_not_contain|does_not_end_with|ends_with|equal_to|is_contained_in|is_not_contained_in|unequal_to"
//		"slave_spot":<text>
		{
			"quickfix": "merge_spot",
			"version": 1.0,
			"instructions": [
				{
					"operator1": "equal_to",
					"master_spot": "Orange",
					"operator2": "equal_to",
					"slave_spot": "PANTONE 485 CVC"
				}
			]
		},
// "adjust_pages_tree"
//		"pages_size": <integer(5-5000)>"
		{
			"quickfix": "adjust_pages_tree",
			"version": 1.0,
			"instructions": [
				{
					"pages_size": 100
				}
			]
		},
// "remove_page_box"
//		"page_selector": "all|even|odd|<splitscheme_expression>"
//		"which_box": "CropBox|BleedBox|TrimBox|ArtBox"
		{
			"quickfix": "remove_page_box",
			"version": 1.0,
			"instructions": [
				{
					"page_selector": "even",
					"which_box": "BleedBox"
				},
				{
					"page_selector": "odd",
					"which_box": "TrimBox"
				}
			]
		},
// "set_mediabox_to_origin"
//		"page_selector": "all|even|odd|<splitscheme_expression>"
		{
			"quickfix": "set_mediabox_to_origin",
			"version": 1.0,
			"instructions": [
				{
					"page_selector": "all"
				}
			]
		},
// "apply_rotate_key"
//		"page_selector": "all|even|odd|<splitscheme_expression>"
		{
			"quickfix": "apply_rotate_key",
			"version": 1.0,
			"instructions": [
				{
					"page_selector": "all"
				}
			]
		},
// "set_page_box"
//		"page_selector": "all|even|odd|<splitscheme_expression>"
//		"which_box": "CropBox|BleedBox|TrimBox|ArtBox"
//		"from_box_or_absolute": "CropBox|BleedBox|TrimBox|ArtBox|absolute"
//		"left": <number>
//		"bottom": <number>
//		"right": <number>
//		"top": <number>
//		"unit": "pt|mm|inch"
//		"when": "always|if_missing"
		{
			"quickfix": "set_page_box",
			"version": 1.0,
			"instructions": [
				{
					"page_selector": "all",
					"which_box": "TrimBox",
					"from_box_or_absolute": "BleedBox",
					"left": -100,
					"bottom": -100,
					"right": -100,
					"top": -100,
					"unit": "pt",
					"when": "always"
				}
			]
		},
// "set_page_box_by_dimensions"
//		"page_selector": "all|even|odd|<splitscheme_expression>"
//		"which_box": "CropBox|BleedBox|TrimBox|ArtBox"
//		"relative_to": "lower_left_corner|left_center|upper_left_corner|top_center|lower_right_corner|right_center|upper_right_corner|upper_right_corner|bottom_center|center"
//		"from_box_or_origin": "CropBox|BleedBox|TrimBox|ArtBox|origin"
//		"hor_offset": <number>
//		"vert_offset": <number>
//		"width": <number>
//		"width_is_relative": true|false
//		"height": <number>
//		"height_is_relative": true|false
//		"unit": "pt|mm|inch"
//		"when": "always|if_missing"
		{
			"quickfix": "set_page_box_by_dimensions",
			"version": 1.0,
			"instructions": [
				{
					"page_selector": "all",
					"which_box": "TrimBox",
					"relative_to": "center",
					"from_box_or_origin": "BleedBox",
					"hor_offset": 0,
					"vert_offset": 0,
					"width": 50,
					"width_is_relative": true,
					"height": 20,
					"height_is_relative": true,
					"unit": "pt",
					"when": "always"
				}
			]
		},
// "scale_pages"
//		"page_selector": "all|even|odd|<splitscheme_expression>"
//		"short_edge": <number>
//		"long_edge": <number>
//		"unit": "percent|pt|mm|inch"
//		"page_scale_mode": "fit_from_inside_add_white_space|fit_from_inside_scale_page_edge_proportionally|fit_from_outside_cut_page|fit_from_outside_scale_page_edge_proportionally|stretch_to_fill"
		{
			"quickfix": "scale_pages",
			"version": "1.0",
			"instructions": [
				{
					"page_selector": "all",
					"short_edge": 100,
					"long_edge": 80,
					"unit": "mm",
					"page_scale_mode": "fit_from_inside_add_white_space"
				}
			]
		},
// "enlarge_pages"
//		"page_selector": "all|even|odd|<splitscheme_expression>"
//		"which_edges": "left|bottom|right|top|left_and_right|top_and_bottom|all"
//		"enlarge_by": <number>
//		"unit": "pt|mm|inch"
		{
			"quickfix": "enlarge_pages",
			"version": "1.0",
			"instructions": [
				{
					"page_selector": "all",
					"which_edges": "all",
					"enlarge_by": 10,
					"unit": "mm"
				}
			]
		},
// "scale_page_content_only"
//		"page_selector": "all|even|odd|<splitscheme_expression>"
//		"relative_to": "lower_left_corner|left_center|upper_left_corner|top_center|lower_right_corner|right_center|upper_right_corner|upper_right_corner|bottom_center|center"
//		"scale_to_percent": <number>
		{
			"quickfix": "scale_page_content_only",
			"version": "1.0",
			"instructions": [
				{
					"page_selector": "all",
					"relative_to": "lower_left_corner",
					"scale_to_percent": 75
				}
			]
		},
// "rotate_pages"
//		"page_selector": "all|even|odd|<splitscheme_expression>"
//		"rotate_by": <number>
		{
			"quickfix": "rotate_pages",
			"version": "1.0",
			"instructions": [
				{
					"page_selector": "all",
					"rotate_by": 90
				}
			]
		},
// "flip_pages"
//		"page_selector": "all|even|odd|<splitscheme_expression>",
//		"flip_direction": "horizontally|vertically"
		{
			"quickfix": "flip_pages",
			"version": "1.0",
			"instructions": [
				{
					"page_selector": "all",
					"flip_direction": "horizontally"
				}
			]
		},
// "auto_correct_page_boxes"
//		"page_selector": "all|even|odd|<splitscheme_expression>",
		{
			"quickfix": "auto_correct_page_boxes",
			"version": "1.0",
			"instructions": [
				{
					"page_selector": "all"
				}
			]
		},
// "insert_empty_page"
//		"page_selector": "all|even|odd|<splitscheme_expression>",
//		"where": "before|after"
		{
			"quickfix": "insert_empty_page",
			"version": "1.0",
			"instructions": [
				{
					"page_selector": "all",
					"where": "before"
				}
			]
		},
// "duplicate_page"
//		"page_selector": "all|even|odd|<splitscheme_expression>",
		{
			"quickfix": "duplicate_page",
			"version": "1.0",
			"instructions": [
				{
					"page_selector": "2"
				}
			]
		},
// "remove_page"
//		"page_selector": "all|even|odd|<splitscheme_expression>",
		{
			"quickfix": "remove_page",
			"version": "1.0",
			"instructions": [
				{
					"page_selector": "odd"
				}
			]
		},
// "set_ocg_visibility"
//		"operator": "regex|begins_with|contains|does_not_begin_with|does_not_contain|does_not_end_with|ends_with|equal_to|is_contained_in|is_not_contained_in|unequal_to"
//		"ocg_name": "<optional_content_group_name_(layer)>",
//		"interpret_ocg_name_as_processsing_steps_name": true|false <optional: default false>,
//		"visibility": "on|off"
		{
			"quickfix": "set_ocg_visibility",
			"version": "1.0",
			"instructions": [
				{
					"operator": "equal_to",
					"ocg_name": "Structural:Bleed",
					"interpret_ocg_name_as_processsing_steps_name": true,
					"visibility": "on"
				}
			]
		},
// "set_processing_steps_metadata_for_ocg"
//		"operator": "regex|begins_with|contains|does_not_begin_with|does_not_contain|does_not_end_with|ends_with|equal_to|is_contained_in|is_not_contained_in|unequal_to"
//		"ocg_name": "<optional_content_group_name_(layer)>",
//		"processing_steps_group": "<custom>|Structural|Dimensions|Braille|Legend|Positions|White|Varnish",
//		"processing_steps_type": "<custom>|Cutting|PartialCutting|ReversePartialCutting|Creasing|ReverseCreasing|CuttingCreasing|ReverseCuttingCreasing|PartialCuttingCreasing|ReversePartialCuttingCreasing|Drilling|Gluing|FoilStamping|ColdFoilStamping|Embossing|Debossing|Perforating|Bleed|VarnishFree|InkFree|InkVarnishFree|Folding|Punching|Stapling|Hologram|Barcode|ContentArea|CodingMarking|Imprinting"
		{
			"quickfix": "set_processing_steps_metadata_for_ocg",
			"version": "1.0",
			"instructions": [
				{
					"operator": "equal_to",
					"ocg_name": "Cutline",
					"processing_steps_group": "Structural",
					"processing_steps_type": "Cutting"
				}
			]
		},
// "embed_outputintent"
//		"outputintent_name": "<internal use>",
//		"outputintent_filepath": "<file_path_to_pdf_file_with_valid_output_intent_information>",
//		"outputintent_type": "A|E|X|AE|AX|EX|AEX|X5n",
//		"retain_existing_outputintent": true|false
		{
			"quickfix": "embed_outputintent",
			"version": "1.0",
			"instructions": [
				{
					"outputintent_name": "",
					"outputintent_filepath": "C:\\user\\Max\\OutputIntent\\ISOUncoated(ECI).pdf",
					"outputintent_type": "X",
					"retain_existing_outputintent": false
				}
			]
		},
// "remove_outputintents"
		{
			"quickfix": "remove_outputintents",
			"version": "1.0",
			"instructions": [
				{
				}
			]
		},
// "inject_dpart"
//		"grouping_expression": "all|even|odd|<splitscheme_expression>",
//		"node_name": "<NodeNameList entry>",
		{
			"quickfix": "inject_dpart",
			"version": "1.0",
			"instructions": [
				{
					"grouping_expression": "3*",
					"node_name": "photobook"
				}
			]
		}
	]
}