HowToPrintJobReport - OllisGit/OctoPrint-PrintJobHistory GitHub Wiki
This page gives you some informations how you can customize the "Print Job Reports" (see sample of the Default Single Report below).
Since Version 1.17.0 you can create reports for a single print job, for all print jobs or for selected jobs.
For that reason you can edit two different report templates:
- singlePrintJobReport: Used when you open a print job and click on "Report"
- multiPrintJobReport: Used from the print job overview table. Also used when you only select a single job from the table and click on "only selected (1)".
Hint: The "singlePrintJob" is not included in "multiPrintJobReport"-Template. Theses are independent templates.
There is no WYSIWYG-Editor!
The Report is created with the OctoPrint build in Template Engine Jinja2 (https://jinja.palletsprojects.com/en/3.0.x/templates/)
You can replace the default templates with you own templates.
To do that, you need to do the followong steps:
- Download the default template
- Modify the template with a text editor (don't use ms-word, because we new a "raw" textfile. E.g. use VS Code)
- Upload the template
or you can use Direct Editing
In the plugin settings you can download the currently assigned Report-Template (or reset to the default template, if your custom template is not working).
You can customize the template and upload it again.
You can do whatever you want!
The default template contains css for some paper size (see https://github.com/cognitom/paper-css).
Inside of the article
element you can layout your single page report. If you need a second page, just add a second section
element.
The rendering engine use the template plus a template-context to generate the html output.
Output of a field value could be done like this
<h1>Filename: {{printJobModel.fileName}}</h1>
Because in the template context are python object you can execute methods.
E.g. reportCreationTime
is from type DateTime you can execute the strftime methode {{ reportCreationTime.strftime('%d.%m.%Y %H:%M') }}
You have full access of the "injected" Python-Objects (like PrintJobModel.py)
Context-Name | Type | Sample |
---|---|---|
reportCreationTime | DateTime | {{ reportCreationTime.strftime('%d.%m.%Y %H:%M') }} |
printJobModel | PrintJobModel.py | {{ printJobModel.userName }} |
{{ printJobModel.printStartDateTime.strftime('%Y-%m-%d %H:%M') }} | ||
printJobModelAsJson | JSON-Dictionary of PrintJobModel (see below) | {{ printJobModelAsJson["fileSizeFormatted"] }} |
{{ printJobModelAsJson["filamentModels"]["total"]["spoolName"] }} |
{
"created": "2020-08-30 11:11:00.711574",
"databaseId": 3,
"duration": 258,
"durationFormatted": "4m18s",
"filamentModels": {
"total": {
"calculatedLength": 4540.0,
"calculatedLengthFormatted": "4.54",
"created": "2020-08-30 11:15:27.076053",
"databaseId": 3,
"density": 4.25,
"diameter": 2.75,
"material": "PLA",
"printJob": 3,
"spoolCost": 20.0,
"spoolCostUnit": "2\u20ac",
"spoolName": "Number1",
"toolId": "total",
"usedCost": "0.50",
"usedLength": 1980.0,
"usedLengthFormatted": "1.98",
"usedWeight": "50.06",
"vendor": "MatterMost",
"weight": 2000.0
}
},
"fileName": "3DBenchy.gcode",
"fileOrigin": "local",
"filePathName": "3DBenchy.gcode",
"fileSize": 1885761,
"fileSizeFormatted": "1.8MB",
"fullFileLocation": "/Users/o0632/Library/Application Support/OctoPrint/uploads/3DBenchy.gcode",
"isRePrintable": true,
"noteDeltaFormat": "{\"ops\": [{\"insert\": \"SuperDuper\\n\"}]}",
"noteHtml": "<p>SuperDuper</p>",
"noteText": "SuperDuper\n",
"printEndDateTime": "2020-08-30 11:15:19.254241",
"printEndDateTimeFormatted": "30.08.2020 11:15",
"printStartDateTime": "2020-08-30 11:11:00.711587",
"printStartDateTimeFormatted": "30.08.2020 11:11",
"printStatusResult": "success",
"printedHeight": "10.85 / 47.75",
"printedLayers": "36 / 160",
"slicerSettingsAsText": "; generated by PrusaSlicer 2.1.0+ on 2019-10-25 at 14:44:14 UTC\n; external perimeters extrusion width = 0.45mm\n; perimeters extrusion width = 0.45mm\n; infill extrusion width = 0.45mm\n; solid infill extrusion width = 0.45mm\n; top infill extrusion width = 0.40mm\n; support material extrusion width = 0.35mm\n; first layer extrusion width = 0.42mm\n; z_offset = 0\n; xy_size_compensation = 0\n; wiping_volumes_matrix = 0\n; wiping_volumes_extruders = 70,70\n; wipe_tower_y = 140\n; wipe_tower_x = 180\n; wipe_tower_width = 60\n; wipe_tower_rotation_angle = 0\n; wipe_tower_bridging = 10\n; wipe_tower = 0\n; wipe_into_objects = 0\n; wipe_into_infill = 0\n; wipe = 0\n; variable_layer_height = 1\n; use_volumetric_e = 0\n; use_relative_e_distances = 0\n; use_firmware_retraction = 0\n; travel_speed = 130\n; top_solid_layers = 3\n; top_solid_infill_speed = 15\n; top_infill_extrusion_width = 0.4\n; top_fill_pattern = rectilinear\n; toolchange_gcode = \n; threads = 8\n; thin_walls = 1\n; temperature = 210\n; support_material_xy_spacing = 50%\n; support_material_with_sheath = 1\n; support_material_threshold = 0\n; support_material_synchronize_layers = 0\n; support_material_speed = 60\n; support_material_spacing = 2.5\n; support_material_pattern = rectilinear\n; support_material_interface_speed = 100%\n; support_material_interface_spacing = 0\n; support_material_interface_layers = 3\n; support_material_interface_extruder = 1\n; support_material_interface_contact_loops = 0\n; support_material_extrusion_width = 0.35\n; support_material_extruder = 1\n; support_material_enforce_layers = 0\n; support_material_contact_distance = 0.2\n; support_material_buildplate_only = 0\n; support_material_auto = 0\n; support_material_angle = 0\n; support_material = 1\n; start_gcode = ; ST/ART Cleaning\\nM117 Cleaningg\t\t\t; Indicate nozzle clean in progress on LCD\\nM82 \t\t\t\t\t;set extruder to absolute mode\\nM107 \t\t\t\t\t;start with the fan off\\nG21 \t\t\t\t\t;metric values\\nG90 \t\t\t\t\t;absolute positioning\\nG28 \t\t\t\t\t;Home (X/Y/Z=0)\\nM140 S50\t\t\t\t; Bed-Temp\\n;M109 S205\t\t\t\t; Nozzel-Temp\\nG0 Z15 F9000\\nG0 X20 Y50 Z0.3 F500\t; Startposition for Cleaning in bed\\nG92 E0 \t; Set extruder to zero\\nG1 X80 E25 F500\t\t\t; Extrude for cleaning (or long line X190 E50)\\nG92 E0 \t; Reset extruder to zero end of cleaning run\\nG1 E-3 F500 \t; Retract filiment by 3 mm to reduce string effect\\nG1 Z15\t\t\t\t\t; Save home-position\t\t\t; Z Save-Postion\\nG1 X0 Y0 Z15 F9000\\nG1 F9000\\nM117 Printing...\n; start_filament_gcode = \"; Filament gcode\\n\"\n; standby_temperature_delta = -5\n; spiral_vase = 0\n; solid_infill_speed = 20\n; solid_infill_extrusion_width = 0.45\n; solid_infill_extruder = 1\n; solid_infill_every_layers = 0\n; solid_infill_below_area = 70\n; small_perimeter_speed = 15\n; slowdown_below_layer_time = 5\n; slice_closing_radius = 0.049\n; skirts = 1\n; skirt_height = 1\n; skirt_distance = 6\n; single_extruder_multi_material_priming = 1\n; single_extruder_multi_material = 0\n; silent_mode = 1\n; serial_speed = 250000\n; serial_port = \n; seam_position = aligned\n; retract_speed = 40\n; retract_restart_extra_toolchange = 0\n; retract_restart_extra = 0\n; retract_lift_below = 0\n; retract_lift_above = 0\n; retract_lift = 0\n; retract_length_toolchange = 10\n; retract_length = 2\n; retract_layer_change = 0\n; retract_before_wipe = 0%\n; retract_before_travel = 2\n; resolution = 0\n; remaining_times = 0\n; raft_layers = 0\n; printhost_cafile = \n; printhost_apikey = 6D7D99B778D64876A06317469F32D8DB\n; printer_vendor = \n; printer_variant = \n; printer_technology = FFF\n; printer_settings_id = ANET E10\n; printer_notes = \n; printer_model = \n; print_settings_id = ANET E10\n; print_host = localhost:5000\n; post_process = \n; perimeters = 3\n; perimeter_speed = 60\n; perimeter_extrusion_width = 0.45\n; perimeter_extruder = 1\n; perimeter_acceleration = 0\n; parking_pos_retraction = 92\n; overhangs = 1\n; output_filename_format = [input_filename_base].gcode\n; ooze_prevention = 0\n; only_retract_when_crossing_perimeters = 1\n; nozzle_diameter = 0.4\n; notes = \n; min_skirt_length = 0\n; min_print_speed = 10\n; min_layer_height = 0.12\n; min_fan_speed = 35\n; max_volumetric_speed = 0\n; max_print_speed = 80\n; max_print_height = 270\n; max_layer_height = 0.32\n; max_fan_speed = 100\n; machine_min_travel_rate = 0,0\n; machine_min_extruding_rate = 0,0\n; machine_max_jerk_z = 0.2,0.4\n; machine_max_jerk_y = 10,10\n; machine_max_jerk_x = 10,10\n; machine_max_jerk_e = 2.5,2.5\n; machine_max_feedrate_z = 12,12\n; machine_max_feedrate_y = 500,200\n; machine_max_feedrate_x = 500,200\n; machine_max_feedrate_e = 120,120\n; machine_max_acceleration_z = 500,200\n; machine_max_acceleration_y = 9000,1000\n; machine_max_acceleration_x = 9000,1000\n; machine_max_acceleration_retracting = 1500,1250\n; machine_max_acceleration_extruding = 1500,1250\n; machine_max_acceleration_e = 10000,5000\n; layer_height = 0.3\n; layer_gcode = \n; interface_shells = 0\n; infill_speed = 80\n; infill_overlap = 25%\n; infill_only_where_needed = 0\n; infill_first = 0\n; infill_extrusion_width = 0.45\n; infill_extruder = 1\n; infill_every_layers = 1\n; infill_acceleration = 0\n; host_type = octoprint\n; high_current_on_filament_swap = 0\n; gcode_label_objects = 0\n; gcode_flavor = reprap\n; gcode_comments = 0\n; gap_fill_speed = 20\n; first_layer_temperature = 210\n; first_layer_speed = 30\n; first_layer_height = 0.35\n; first_layer_extrusion_width = 0.42\n; first_layer_bed_temperature = 50\n; first_layer_acceleration = 0\n; fill_pattern = stars\n; fill_density = 20%\n; fill_angle = 45\n; filament_unloading_speed_start = 100\n; filament_unloading_speed = 90\n; filament_unload_time = 0\n; filament_type = PLA\n; filament_toolchange_delay = 0\n; filament_soluble = 0\n; filament_settings_id = \"ANET E10\"\n; filament_ramming_parameters = \"120 100 6.6 6.8 7.2 7.6 7.9 8.2 8.7 9.4 9.9 10.0| 0.05 6.6 0.45 6.8 0.95 7.8 1.45 8.3 1.95 9.7 2.45 10 2.95 7.6 3.45 7.6 3.95 7.6 4.45 7.6 4.95 7.6\"\n; filament_notes = \"\"\n; filament_minimal_purge_on_wipe_tower = 15\n; filament_max_volumetric_speed = 0\n; filament_loading_speed_start = 3\n; filament_loading_speed = 28\n; filament_load_time = 0\n; filament_diameter = 1.75\n; filament_density = 0\n; filament_cost = 0\n; filament_cooling_moves = 4\n; filament_cooling_initial_speed = 2.2\n; filament_cooling_final_speed = 3.4\n; filament_colour = #29B2B2\n; fan_below_layer_time = 60\n; fan_always_on = 0\n; extrusion_width = 0.45\n; extrusion_multiplier = 1\n; extrusion_axis = E\n; extruder_offset = 0x0\n; extruder_colour = \"\"\n; extruder_clearance_radius = 20\n; extruder_clearance_height = 20\n; extra_perimeters = 1\n; extra_loading_move = -2\n; external_perimeters_first = 0\n; external_perimeter_speed = 50%\n; external_perimeter_extrusion_width = 0.45\n; ensure_vertical_shell_thickness = 0\n; end_gcode = M104 S0 \t\t\t\t\t\t;extruder heater off\\nM140 S0 \t\t\t\t\t\t;heated bed heater off (if you have it)\\nG91 \t\t\t\t\t\t\t;relative positioning\\nG1 E-1 F300 \t\t\t\t\t;retract the filament a bit before lifting the nozzle, to release some of the pressure\\nG1 Z+0.5 E-5 X-20 Y-20 F9000 \t;move Z up a bit and retract filament even more\\nG1 Z+10 Y+200 F9000 \t\t\t;NEW: bring bed to the front\\nM84 \t\t\t\t\t\t\t;steppers off\\nG90 \t\t\t\t\t\t\t;absolute positioning\n; end_filament_gcode = \"; Filament-specific end gcode \\n;END gcode for filament\\n\"\n; elefant_foot_compensation = 0\n; duplicate_distance = 6\n; dont_support_bridges = 1\n; disable_fan_first_layers = 3\n; deretract_speed = 0\n; default_print_profile = \n; default_filament_profile = \"\"\n; default_acceleration = 0\n; cooling_tube_retraction = 91.5\n; cooling_tube_length = 5\n; cooling = 1\n; complete_objects = 0\n; clip_multipart_objects = 0\n; brim_width = 0\n; bridge_speed = 60\n; bridge_flow_ratio = 1\n; bridge_fan_speed = 100\n; bridge_angle = 0\n; bridge_acceleration = 0\n; bottom_solid_layers = 3\n; bottom_fill_pattern = rectilinear\n; between_objects_gcode = \n; before_layer_gcode = ;LAYER:[layer_num]\n; bed_temperature = 50\n; bed_shape = 0x0,220x0,220x270,0x270\n; bed_custom_texture = \n; bed_custom_model = \n; avoid_crossing_perimeters = 0\n; estimated printing time (normal mode) = 1h 4m 41s\n; total filament cost = 0.0\n; total filament used [g] = 0.0\n; filament used [cm3] = 10.9\n; filament used [mm] = 4521.7\n",
"snapshotFilename": "20200830-111100.jpg",
"temperatureModels": [
{
"sensorName": "bed",
"sensorValue": "50.0"
},
{
"sensorName": "tool0",
"sensorValue": "210.0"
}
],
"userName": "admin"
}
You can use the upload feature in the plugin settings or you can also use "direct editing".
For direct editing you need the following tools:
- A remote running OctoprintServer
- SFTP-Client
- Text Editor
The following chapters desribes how you setup your environment with teh following tools:
- OctoPrint with OctoPi-Image
- VS Code
- VS Code - Extension: "SFTP - sftp sync extension for VS Code, by liximomo"
- Optional: VS Code - Extension: "Better Jinja, by Samuel Colvin"
- Create an empty folder on your system e.g.
PrintJobReportTemplates
- Install the SFTP Extension in VS Code
- Do a restart and open the newly created folder
- From
Command Pallatte...
choseSFTP: Config
and enter your connection settings (remotePath could be the dafault "/")
{
"name": "myOctoprint",
"host": "192.168.178.37",
"protocol": "sftp",
"port": 22,
"username": "pi",
"remotePath": "/",
"uploadOnSave": true
}
- Click on the
Paper & Cloud
symbol from the left side menu - Doublle click on the newly created connection and after entering the password you can see the directory structure of the PI.
- Navigate to
/home/pi/oprint/lib/python3.7/site-packages/octoprint_PrintJobHistory/templates/
- Right click on
PrintJobHistory_defaultSinglePrintJobReport.jinja2
and selectEdit in local
- Now you can modify the template in VS Code and after saving the file you can direcly see the result in the browser (after reloading the page)
- Open the browser
http://192.168.178.37/plugin/PrintJobHistory/singlePrintJobReport/27