【发布时间】:2017-07-27 05:50:04
【问题描述】:
问题已在此处提出:create PDF of RecyclerView in FULL length 而且我也有同样的问题,因为我还没有找到解决方案,我想生成完整长度的 RecyclerView 内容的 PDF。 但没有找到解决方案。
我已经尝试了所有可用的解决方案以及从 RecycleView 生成 PDF 的所有可能方法。
我已经尝试过的解决方案:
https://gist.github.com/PrashamTrivedi/809d2541776c8c141d9a
Take a screenshot of RecyclerView in FULL length
Convert Listview Items into a single Bitmap Image
已经尝试了上面提到的所有解决方案,但其中任何一个都不能与我一起工作并出现错误,有时宽度和高度问题或有时得到空白的白色位图作为输出不知道为什么。
问题:
我有带有 HTML 内容的 RecyclerView 以及内容之间的图像。
将跟随屏幕视为带有内容的 RecyclerView。
RecyclerView 中的内容与上图相同,包含 100 多个项目。
RecyclerView 项目布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fresco="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.facebook.drawee.view.SimpleDraweeView
android:id="@+id/leftImage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:adjustViewBounds="true"
android:maxHeight="350dp"
fresco:actualImageScaleType="fitCenter"
fresco:placeholderImage="@color/white" />
<jp.wasabeef.richeditor.RichEditor
android:id="@+id/editor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/margin10dp"
android:layout_marginRight="@dimen/margin10dp"
android:layout_weight="1"
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false" />
<com.facebook.drawee.view.SimpleDraweeView
android:id="@+id/rightImage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:adjustViewBounds="true"
android:maxHeight="350dp"
fresco:actualImageScaleType="fitCenter"
fresco:placeholderImage="@color/white" />
</LinearLayout>
更新
因为我正在处理 PDF 以从视图生成 PDF,但无法生成 PDF,所以我发布了这个问题。
但是现在,我找到了使用 Webview 生成 PDF 的解决方案,您可以看到我对这个问题的回答已标记为已接受。
根据我找到的解决方案,我创建了一个库来从任何字符串或任何 HTML 内容生成 PDF。
PDF 生成器库: PDF-Generator
谢谢
【问题讨论】:
-
您是否尝试将当前显示屏幕保存为图像并附加所有图像以制作单个 pdf?
-
@Divyesh 这不起作用,因为它是一个回收器视图——整个显示器不在屏幕上。视图被回收
-
@Divyesh 请正确阅读问题。
-
但计算滚动位置,当该位置变为顶部时,拍摄另一张屏幕图像,依此类推
-
@Divyesh:感谢您的关注和回复,但如果您有解决方案请提供,我不知道该怎么做。
标签: android pdf printing android-recyclerview