小编Raf*_*ael的帖子

创建完整长度的RecyclerView PDF

我想创建活动的“整页” PDF。该视图包含一个RecyclerView,其中包含许多项。

我可以使用Recyclerview的完整尺寸,但是仅从当前视图绘制文件。这是我的代码:

    public void tela (){ // create a new document
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)

    {
        PdfDocument document = new PdfDocument();

        getScreenshotFromRecyclerView(mRecyclerView);
        content = mRecyclerView;
        content.setBackgroundColor(Color.parseColor("#303030"));


        PdfDocument.PageInfo pageInfo = new PdfDocument.PageInfo.Builder(wil,
                height, 1).create();

    // create a new page from the PageInfo
        PdfDocument.Page page = document.startPage(pageInfo);

    // repaint the user's text into the page
        content.draw(page.getCanvas());

    // do final processing of the page
        document.finishPage(page);

    // saving pdf document to sdcard
        SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy - HH-mm-ss",Locale.getDefault());
        String pdfName = "Revisões_" …
Run Code Online (Sandbox Code Playgroud)

android pdf-generation android-studio android-recyclerview

6
推荐指数
1
解决办法
4508
查看次数