如何将字符串(html)转换为pdf文件并在android中发送API

时间:2017-02-02 11:34:59

标签: android pdf

我有一个html字符串。我想将字符串转换为pdf文件并尝试post.Function不返回File.How来解决此问题。

public static void pdf (String html) {

    // step 4
    try {
        Document document = new Document();
        // step 2
        InputStream in = new ByteArrayInputStream(html.getBytes());
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("test.pdf"));
        // step 3
        document.open();
        XMLWorkerHelper.getInstance().parseXHtml(writer, document,
                in);
        document.close();
        Log.e("test",  "PDF Created!" );
    } catch (Exception e) {
        e.printStackTrace();
    }
}  

0 个答案:

没有答案