标签: androidpdfviewer

PDF 立即打开和关闭

在我的应用程序中,我将 pdf 下载到下载文件夹,并尝试使用以下代码打开。

String FileName="CardsDecks";
File imagePath = new File(this.getFilesDir(), "Download");
File newFile = new File(imagePath, FileName+ ".pdf");
Uri contentUri = FileProvider.getUriForFile(this, "com.cards.mycards.fileprovider", newFile);

Intent intent =new Intent(Intent.ACTION_VIEW)                                
    .setDataAndType(contentUri, "application/pdf")
    .addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

Intent intent1 = Intent.createChooser(intent, "Open File");

startActivity(intent1);
Run Code Online (Sandbox Code Playgroud)

清单文件中的提供程序定义

<provider
            android:name="androidx.core.content.FileProvider"
            android:authorities="com.cards.mycards.fileprovider"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/provider_paths" />
</provider>
Run Code Online (Sandbox Code Playgroud)

provider_paths.xml

<paths>
    <files-path name="CardsDecks" path="." />
</paths>
Run Code Online (Sandbox Code Playgroud)

该应用程序仅显示用于打开文件的驱动器 pdf 查看器和 word 选项,而不显示手机中的 pdf 查看器。

当我单击驱动器 pdf 查看器时,它会立即打开和关闭。我已经检查了下载文件夹中的文件,文件存在于其中,其中包含内容。

请帮助以上。

java android android-pdf-api androidpdfviewer

8
推荐指数
1
解决办法
592
查看次数

Android从布局视图创建和打印pdf

我正在尝试从xml布局视图创建PDF文件.我在该布局中有一个列表视图,根据子项添加项目和设置高度.PDF正在创建但不填写整个页面.我试过的是,

 PdfDocument.PageInfo pageInfo = new PdfDocument.PageInfo.Builder(2250, 1400, 1).create();

        // start a page
        PdfDocument.Page page = document.startPage(pageInfo);


        // draw something on the page
        LayoutInflater inflater = (LayoutInflater)
                getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View content = inflater.inflate(R.layout.pdf_layout, null);

        content.measure(2250, 1400);
        content.layout(0,0, 2250, 1400);

        tvName = (TextView)content.findViewById(R.id.tvName);
        tvDate = (TextView)content.findViewById(R.id.tvDate);
        tvAge = (TextView)content.findViewById(R.id.tvAge);
        tvGender = (TextView)content.findViewById(R.id.tvGender);
        tvPhone = (TextView)content.findViewById(R.id.tvPhone);
        lvList = (ListView)content.findViewById(R.id.lvList);
        lvList.setAdapter(adapter);
        Utils.setListViewHeight(lvList, CreatePDFDemo.this);

        tvName.setText(name);
        tvAge.setText(age + "Y");
        tvGender.setText(gender);
        tvPhone.setText(phone);

        content.draw(page.getCanvas());

        // finish the page
        document.finishPage(page);
        // add more pages
        // write the document content
        try …
Run Code Online (Sandbox Code Playgroud)

pdf android pdf-generation android-layout androidpdfviewer

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

barteksc/AndroidPdfViewer 海量 APK 大小

我们包含此AndroidPdfViewer 库以支持在应用程序中查看 PDF 报告。它导致 APK 大小从 4.7Mb 大幅增加到 20.1Mb。

有没有办法减小这个尺寸。让我知道在哪里以及需要修改哪些内容来帮助或解决这个问题。

我熟悉 proguard 并为我的应用程序配置它并取得了一定的成功。

android apk androidpdfviewer

5
推荐指数
1
解决办法
3781
查看次数

将文本/注释添加到现有 PDF 文件中并在 android 中查看/渲染输出

我正在使用pdf 编辑器

我使用基于 iText 的OpenPDF核心对 pdf 文件进行了更改

我正在使用AndroidPdfViewer查看 Pdf 文件

我的问题是:

  1. 将新的注释(如文本或标签或图标)添加到现有的 pdf 文件中。 (已解决

  2. 在注释添加到 pdf 文件后立即显示新更改。(已解决

  3. 将用户点击转换为 Pdf 文件坐标以根据用户点击位置添加新注释。

  4. 在添加的注释上获取点击事件并读取添加到该注释中的元数据,例如:读取在图标注释上设置的标签哈希 ID。(已解决

  5. 从 PDF 文件中删除添加的注释。

任何帮助表示赞赏

更新

================================================== ======================

解决方案 1:添加注释

  • 这是我将图标注释添加到现有 pdf 文件的代码片段。

public static void addWatermark(Context context, String filePath) throws FileNotFoundException, IOException {

        // get file and FileOutputStream
        if (filePath == null || filePath.isEmpty())
            throw new FileNotFoundException();

        File file = new …
Run Code Online (Sandbox Code Playgroud)

pdf android itext androidpdfviewer openpdf

5
推荐指数
1
解决办法
583
查看次数