Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #11839 Reply

    Jade

    PDF Open Fail from assets folder, and this is a log.

    01-01 18:23:07.960: E/PlugPDF(11347): [ERROR] java.lang.Exception: Failed to open from data. Because,
    01-01 18:23:07.960: E/PlugPDF(11347): Syntax Error: could not find catalog at line 381 (Gf_Error* Pdf_File::repairXref(streams::InputStream*) : ././../../../../../../ext/pdfv/src/file/file_repair.cpp)

    ======================================================================
    SimpleDocumentReader mReader = SimpleReaderFactory.createSimpleViewer(this, listener);
    AssetManager assetManager = getAssets();

    File file = new File(getFilesDir(), “test.pdf”);
    try
    {
    InputStream in = assetManager.open(“test.pdf”);
    OutputStream out = openFileOutput(file.getName(), Context.MODE_WORLD_READABLE);
    byte[] buffer = new byte[1024];
    int read;
    while ((read = in.read(buffer)) != -1)
    {
    out.write(buffer, 0, read);
    }
    in.close();
    in = null;
    out.flush();
    mReader.openData(buffer, buffer.length, “”);
    out.close();
    out = null;
    } catch (Exception e)
    {
    Log.e(“tag”, e.getMessage());
    }

    #11840 Reply

    Dr. Plug
    Moderator

    Hello Jade,

    Thank you for your inquiry.
    In our sample project, there is example that open pdf in asset folder.
    The readAssetFile method in the ReaderActivity class or the ReaderWithControllerActivity class will help you to do that.

    I hope this will be helpful to you.

    Best regards,

    Dr.Plug
    PlugPDF Support

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: how to opern pdf from assets folder(Android SDK)
Your information: