Код: Выделить всё
@RequestMapping(value = "/generatePdfFile", method = RequestMethod.POST)
public ResponseEntity generatePdfFile(String htmlContent, HttpServletResponse response) throws IOException {
try {
logger.info("triggered generatePdfFile API.");
ByteArrayInputStream byteArrayInputStream = convertHtmlToPdfusingFlyingSaucer(htmlContent);
response.setContentType("application/pdf");
response.setHeader("Content-Disposition", "attachment; filename=file.pdf");
IOUtils.copy(byteArrayInputStream, response.getOutputStream());
response.flushBuffer();
logger.info("PDF Generation successful.");
return ResponseEntity.ok("PDF generated successfully.");
} catch (Exception e) {
logger.error("Error generating PDF: {}", e.getMessage());
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed to generate PDF.");
}
}
Код: Выделить всё
server.max-http-request-header-size=4MB
server.tomcat.max-http-request-header-size=4MB
server.max-request-size=4MB
server.max-form-headers=4MB
Код: Выделить всё
this is the error that im getting
HTTP Status 400 – Bad Requestbody {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}HTTP Status 400 – Bad Request
Type[/b] Exception Report
[b]Message[/b] Request header is too large
[b]Description[/b] The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).
[b]Exception[/b]
java.lang.IllegalArgumentException: Request header is too large[b] org.apache.coyote.http11.Http11InputBuffer.fill(Http11InputBuffer.java:770)
org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:442)
org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:264)
org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63)
org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:896)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1744)
org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:63)
java.base/java.lang.Thread.run(Thread.java:833)
Note[/b] The full stack trace of the root cause is available in the server logs.
Apache Tomcat/10.1.19
Код: Выделить всё
@RequestMapping(value = "/generatePdfFile", method = RequestMethod.POST)
public ResponseEntity generatePdfFile(@RequestBody String htmlContent, HttpServletResponse response) throws IOException {}
Подробнее здесь: https://stackoverflow.com/questions/787 ... -too-large
Мобильная версия