html 페이지를 pdf로 변환. pdf로 페이지를 변환하면 html 페이지 내용이 A4 페이지에 맞지 않습니다. 나는 전체 HTML 페이지가 누락 된 내용없이 PDF로 변환되기를 원한다.HTML 페이지 축소 및 A4 크기로 변환 pdf
은 이미 PDF
String tempOutFileNameXHTML = "/Users/Common/index" + i + DOT + "xhtml";
String tempOutFileNamePDF = "/Users/Common/index" + i + DOT + PDF;
File targetFile = targetFiles.get(i); // gets all the specified html files
CleanerProperties props = new CleanerProperties();
props.setTranslateSpecialEntities(true);
props.setTransResCharsToNCR(true);
props.setOmitComments(true);
//checking of starting and ending tags are in proper
HtmlCleaner htmlCleaner = new HtmlCleaner(props);
TagNode tagNode = htmlCleaner.clean(targetFile);
PrettyXmlSerializer prettyXmlSerializer = new PrettyXmlSerializer(props);
prettyXmlSerializer.writeToFile(tagNode, tempOutFileNameXHTML, "utf-8");
File xhtmlpath = new File(tempOutFileNameXHTML);
File pdfPath = new File(tempOutFileNamePDF);
com.itextpdf.text.Document pdfDocument = null;
PdfWriter pdfWriter = null;
pdfDocument = new com.itextpdf.text.Document(com.itextpdf.text.PageSize.A4); // TODO handle this
pdfWriter = PdfWriter.getInstance(pdfDocument, new FileOutputStream(pdfPath));
pdfDocument.open();
Font catFont = new Font(Font.FontFamily.TIMES_ROMAN, 25, Font.BOLD);
pdfDocument.add(new Paragraph("Target : " + targetFile.getParentFile().getName(), catFont));
XMLWorkerHelper.getInstance().parseXHtml(pdfWriter, (com.itextpdf.text.Document) pdfDocument,
new FileInputStream(xhtmlpath), null);
pdfDocument.close();
여기에서의 문제 HTML 페이지 폭이 너무 긴 경우, 그것은 A4 크기의 PDF에 맞지입니다으로 HTML로 변환 코드를 데. 어쨌든 축소하거나 pdf로 만들거나 콘텐츠를 잃어 버리지 마십시오. ? 어떻게 할 수 있습니까? HTML 페이지 축소 및 PDF로 변환 할 수 있습니까? 이 작업을 수행하는 방법에 대한 아이디어가 있습니까?
이 게시물을 살펴보십시오. 도움이 될 수 있습니다. http://stackoverflow.com/questions/14089883/how-to-create-several-pages-with-dompdf/14089936#14089936 –