我怎么能将伊塔特地区生成的PDF文档编成基64?
这是我的(java)法典。
App.java
public class App {
public static void main(String[] args) throws DocumentException, IOException {
// step 1
Document document = new Document();
// step 2
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("pdf.pdf"));
// step 3
document.open();
String str = "<html><head></head><body style="font-size:12.0pt; font-family:Times New Roman">"
+ "<a href= http://www.rgagnon.com/howto.html ><b>Real s HowTo</b></a>" + "<h1>Show your support</h1>"
+ "<p>It DOES cost a lot to produce this site - in ISP storage and transfer fees</p>"
+ "<p>TEST POLSKICH ZNAKÓW: u0104u0105u0106u0107u00d3u00f3u0141u0142u0179u017au017bu017cu017du017eu0118u0119</p>"
+ "<hr/>"
+ "<p>the huge amounts of time it takes for one person to design and write the actual content.</p>"
+ "<p>If you feel that effort has been useful to you, perhaps you will consider giving something back?</p>"
+ "<p>Donate using PayPalu017d</p>" + "<p>Contributions via PayPal are accepted in any amount</p>"
+ "<p><br/><table border= 1 ><tr><td>Java HowTo</td></tr><tr>"
+ "<td style= background-color:red; >Javascript HowTo</td></tr>"
+ "<tr><td>Powerbuilder HowTo</td></tr></table></p>" + "</body></html>";
XMLWorkerHelper worker = XMLWorkerHelper.getInstance();
InputStream is = new ByteArrayInputStream(str.getBytes(StandardCharsets.UTF_8));
worker.parseXHtml(writer, document, is, Charset.forName("UTF-8"));
// step 5
document.close();
System.out.println("PDF Created!");
}
}
iText 图书馆用户(xmlworker e itextpdf)
www.un.org/Depts/DGACM/index_spanish.htm Pom file:
<dependencies>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.4.2</version>
</dependency>
<dependency>
<groupId>com.itextpdf.tool</groupId>
<artifactId>xmlworker</artifactId>
<version>5.4.1</version>
</dependency>
</dependencies>
任何帮助都受到欢迎。