Создать кодировку PDF base64 из iText в JavaJAVA

Программисты JAVA общаются здесь
Ответить
Anonymous
 Создать кодировку PDF base64 из iText в Java

Сообщение Anonymous »

Как я могу закодировать PDF-файл, созданный в iText, в base64?
Это мой (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 = ""
+ "[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)

Pom-файл:

Код: Выделить всё

    

com.itextpdf
itextpdf
5.4.2


com.itextpdf.tool
xmlworker
5.4.1


Я застрял, любая помощь приветствуется.

Подробнее здесь: https://stackoverflow.com/questions/469 ... xt-in-java
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «JAVA»