|
@@ -12,6 +12,7 @@ import com.ruoyi.common.core.domain.pdf.PdfProperty; |
|
|
import com.ruoyi.common.core.domain.pdf.ShoulderItem; |
|
|
import com.ruoyi.common.core.domain.pdf.ShoulderItem; |
|
|
import com.ruoyi.common.utils.StringUtils; |
|
|
import com.ruoyi.common.utils.StringUtils; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
import org.springframework.http.MediaType; |
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
import java.io.ByteArrayOutputStream; |
|
|
import java.io.ByteArrayOutputStream; |
|
@@ -94,9 +95,11 @@ public class PdfUtils<statistic> { |
|
|
// 5. 关闭文档 |
|
|
// 5. 关闭文档 |
|
|
document.close(); |
|
|
document.close(); |
|
|
// 6. 将PDF输出到浏览器 |
|
|
// 6. 将PDF输出到浏览器 |
|
|
response.setContentType("application/pdf"); |
|
|
|
|
|
|
|
|
response.setContentType(MediaType.APPLICATION_PDF_VALUE); |
|
|
response.setCharacterEncoding("utf-8"); |
|
|
response.setCharacterEncoding("utf-8"); |
|
|
response.setContentLength(baos.size()); |
|
|
response.setContentLength(baos.size()); |
|
|
|
|
|
response.setHeader("Pragma", "public"); |
|
|
|
|
|
response.setHeader("Cache-Control", "public, must-revalidate"); |
|
|
response.setHeader("Content-Disposition", "inline; filename=example.pdf"); |
|
|
response.setHeader("Content-Disposition", "inline; filename=example.pdf"); |
|
|
response.getOutputStream().write(baos.toByteArray()); |
|
|
response.getOutputStream().write(baos.toByteArray()); |
|
|
response.getOutputStream().flush(); |
|
|
response.getOutputStream().flush(); |
|
|