简体   繁体   English

Android上的PdfDocument-使用填充PDF

[英]PdfDocument on Android - filling a PDF with

to my understanding for creating Pdfs on Android starting version 4.4 I can use the PdfDocument class, which generally works like this: 根据我在Android 4.4起始版本上创建Pdfs的理解,我可以使用PdfDocument类,该类通常如下所示:

        PageInfo pageInfo = new PageInfo.Builder(textView.getWidth(), textView.getHeight(), 1).create();
        Page page = document.startPage(pageInfo);
        View content = textview;
        content.draw(page.getCanvas());
        document.finishPage(page);

So basically I am taking my layout, draw it on the canvas, and PdfDocument creates a PDF out of it. 因此,基本上我要使用布局,将其绘制在画布上,然后PdfDocument用它创建一个PDF。 This is working, I would like to know however if it is possible to simply add text as string, for example, without using TextViews etc., and create a PDF out of that? 这是可行的,但是我想知道是否可以仅将文本添加为​​字符串,例如,而无需使用TextViews等,并由此创建PDF?

if it is possible to simply add text as string, for example, without using TextViews etc., and create a PDF out of that? 是否可以简单地将文本添加为​​字符串,例如,而不使用TextViews等,并由此创建PDF?

Not using the Android SDK options. 不使用Android SDK选项。 You can create a PDF out of Web content (via WebView ), a Canvas (whether using views or the native Canvas drawing API), or a Bitmap . 您可以使用Web内容(通过WebView ), Canvas (使用视图或本机Canvas绘图API)或Bitmap来创建PDF。 There are third-party PDF libraries (eg, iText) for other PDF-generation scenarios. 有用于其他PDF生成方案的第三方PDF库(例如,iText)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM