@Operation(summary="Change the size of a PDF page/document",description="This operation takes an input PDF file and the size to scale the pages to in the output PDF file.")
@Parameter(description="The input PDF file",required=true)@RequestParam("fileInput")MultipartFilefile,
@Parameter(description="The scale of pages in the output PDF. Acceptable values are A0-A10, B0-B9, LETTER, TABLOID, LEDGER, LEGAL, EXECUTIVE.",required=true,schema=@Schema(type="String",allowableValues={"A0","A1","A2","A3","A4","A5","A6","A7","A8","A9","A10","B0","B1","B2","B3","B4","B5","B6","B7","B8","B9","LETTER","TABLOID","LEDGER","LEGAL","EXECUTIVE"}))@RequestParam("pageSize")StringtargetPageSize,
@Parameter(description="The scale of the content on the pages of the output PDF. Acceptable values are floats.",required=true,schema=@Schema(type="float"))@RequestParam("scaleFactor")floatscaleFactor)
throwsIOException{
Map<String,PageSize>sizeMap=newHashMap<>();
// Add A0 - A10
sizeMap.put("A0",PageSize.A0);
sizeMap.put("A1",PageSize.A1);
sizeMap.put("A2",PageSize.A2);
sizeMap.put("A3",PageSize.A3);
sizeMap.put("A4",PageSize.A4);
sizeMap.put("A5",PageSize.A5);
sizeMap.put("A6",PageSize.A6);
sizeMap.put("A7",PageSize.A7);
sizeMap.put("A8",PageSize.A8);
sizeMap.put("A9",PageSize.A9);
sizeMap.put("A10",PageSize.A10);
// Add B0 - B9
sizeMap.put("B0",PageSize.B0);
sizeMap.put("B1",PageSize.B1);
sizeMap.put("B2",PageSize.B2);
sizeMap.put("B3",PageSize.B3);
sizeMap.put("B4",PageSize.B4);
sizeMap.put("B5",PageSize.B5);
sizeMap.put("B6",PageSize.B6);
sizeMap.put("B7",PageSize.B7);
sizeMap.put("B8",PageSize.B8);
sizeMap.put("B9",PageSize.B9);
// Add other sizes
sizeMap.put("LETTER",PageSize.LETTER);
sizeMap.put("TABLOID",PageSize.TABLOID);
sizeMap.put("LEDGER",PageSize.LEDGER);
sizeMap.put("LEGAL",PageSize.LEGAL);
sizeMap.put("EXECUTIVE",PageSize.EXECUTIVE);
if(!sizeMap.containsKey(targetPageSize)){
thrownewIllegalArgumentException("Invalid pageSize. It must be one of the following: A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10");