magick input.jpg \
-resize 7440x10524 \
-crop 3x3@ +repage \
-units PixelsPerInch -density 300 \
tile_%02d.jpg
Here is the complete LibreOffice Basic macro code, incorporating all the requested features: Exports as PDF. Exports only the defined Print Area ( A1:I37 ). Uses the sheet "Report card t-1" . Names the PDF file based on the value in cell B7 . Loops through roll numbers 1 to 40. You need to copy and paste this entire code block into your LibreOffice Basic IDE module. Complete PDF Export Macro Basic Sub ExportAllReportsToPDF_FinalFix() ' --- CONFIGURATION --- Const START_ROLL As Integer = 1 Const END_ROLL As Integer = 40 ' 1. The name of the sheet that contains the report card Const SHEET_NAME As String = "Report card t-1" ' 2. The named range for the cell that holds the roll number (used for VLOOKUP) Const ROLL_CELL_NAME As String = "RollNoCell" ' 3. The EXACT cell range of your report card print area Const PRINT_AREA As String = "A1:I37" ' 4. Set you...