We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Display file pdf in android application

Welcome
Our company wants to buy product
Aspose.Pdf for Android

We did the test program
and we have two questions before we buy your product
First, the subject matter


We need in our application on android

open file pdf
On the application server receives the byte array of file pdf

The program has several steps:

1. Convert byte array to file pdf -> docname.pdf

2. Save this file on storage -> getApplicationContext().getFilesDir()

3. Open file in webwiew

There code:

WebView mDocDisplay_wv;

….//init of webview

int ViewSize= mDocDisplay_wv.getWidth();

// select a document and get bytes

File file = new File(getApplicationContext().getFilesDir() + "/docname.pdf" );

RandomAccessFile raf = new RandomAccessFile(file, "r");

FileChannel channel = raf.getChannel();

ByteBuffer bb = ByteBuffer.NEW(channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size()));

raf.close();

// create a pdf doc

PDFFile pdf = new PDFFile(bb);

String html = ""

//loop through the rest of the pages and repeat the above

for(int i = 1; i <= pdf.getNumPages(); i++)

{

PDFPage PDFpage = pdf.getPage(i, true);

float scale = ViewSize / PDFpage.getWidth() * 0.6f;

Bitmap page = PDFpage.getImage((int)(PDFpage.getWidth() * scale), (int)(PDFpage.getHeight() * scale), null, true, true);

ByteArrayOutputStream stream = new ByteArrayOutputStream();

page.compress(Bitmap.CompressFormat.PNG, 100, stream);

stream.close();

byte[] byteArray = stream.toByteArray();

String base64 = Base64.encodeToString(byteArray, Base64.DEFAULT);

html += "
";

}

html += "";

//load the html in the webview à mDocDisplay_wv

mDocDisplay_wv.loadDataWithBaseURL("", html, "text/html","UTF-8", "");

Questopns:

1. How open pdf file from byte array without convert byte array to file and without save on storage?

2. We do not want to scroll horizontally was
therefore determined the scale=0.6f,
but so the file will not be shown clearly.
How can I solve this problem?

Hi there,

Thanks for your inquiry.

mayyakom:

We did the test program

and we have two questions before we buy your product
First, the subject matter



I am afraid Aspose APIs that can be embed in your application to provide related features in your application. These do not provide any GUI. However you may consider our another venture GroupDocs for the viewer.


We are looking into your other question and will get back to you soon.


Best Regards,