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 = ""
+ "[url=http://www.rgagnon.com/howto.html]Real's HowTo[/b][/url]" + "Show your support"
+ "
It DOES cost a lot to produce this site - in ISP storage and transfer fees
"
+ "
TEST POLSKICH ZNAKÓW: \u0104\u0105\u0106\u0107\u00d3\u00f3\u0141\u0142\u0179\u017a\u017b\u017c\u017d\u017e\u0118\u0119
"
+ ""
+ "
the huge amounts of time it takes for one person to design and write the actual content.
"
+ "
If you feel that effort has been useful to you, perhaps you will consider giving something back?
"
+ "
Donate using PayPal\u017d
" + "
Contributions via PayPal are accepted in any amount
"
+ "
Java HowTo"
+ "Javascript HowTo"
+ "Powerbuilder HowTo
" + "";
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 и itextpdf)
Как я могу закодировать PDF-файл, созданный в iText, в base64?[b] Это мой (Java) код
[b]App.java[/b]
[code]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 = "" + "[url=http://www.rgagnon.com/howto.html]Real's HowTo[/b][/url]" + "Show your support" + " It DOES cost a lot to produce this site - in ISP storage and transfer fees " + " TEST POLSKICH ZNAKÓW: \u0104\u0105\u0106\u0107\u00d3\u00f3\u0141\u0142\u0179\u017a\u017b\u017c\u017d\u017e\u0118\u0119 " + "" + " the huge amounts of time it takes for one person to design and write the actual content. " + " If you feel that effort has been useful to you, perhaps you will consider giving something back? " + " Donate using PayPal\u017d " + " Contributions via PayPal are accepted in any amount " + " Java HowTo" + "Javascript HowTo" + "Powerbuilder HowTo " + "";
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!");
} [/code]
Зависимости библиотеки iText (xmlworker и itextpdf)