package com.dl.common;
|
|
import org.springframework.core.io.ByteArrayResource;
|
import org.springframework.stereotype.Component;
|
|
import java.io.ByteArrayOutputStream;
|
import java.io.IOException;
|
|
import com.itextpdf.html2pdf.HtmlConverter;
|
|
@Component
|
public class PdfGenerator {
|
public ByteArrayResource generatePdfFromHtml(String html) throws IOException {
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
HtmlConverter.convertToPdf(html, outputStream);
|
byte[] bytes = outputStream.toByteArray();
|
return new ByteArrayResource(bytes);
|
}
|
}
|