-2

i am unable to find correct source code for this.while i am downloading and adding the source code I am getting errors like class cannot find create class.of course i added some of the jars are in library also.please provide some proper and useful code for that.

user5829627
  • 11
  • 1
  • 3

1 Answers1

1

To convert pdf to images use android-pdfview and following code

DecodeServiceBase decodeService = new DecodeServiceBase(new PdfContext());
decodeService.setContentResolver(mContext.getContentResolver());

// a bit long running
decodeService.open(Uri.fromFile(pdf));

int pageCount = decodeService.getPageCount();
for (int i = 0; i < pageCount; i++) {
PdfPage page = decodeService.getPage(i);
RectF rectF = new RectF(0, 0, 1, 1);

// do a fit center to 1920x1080
double scaleBy = Math.min(AndroidUtils.PHOTO_WIDTH_PIXELS / (double)     page.getWidth(), //
        AndroidUtils.PHOTO_HEIGHT_PIXELS / (double) page.getHeight());
int with = (int) (page.getWidth() * scaleBy);
int height = (int) (page.getHeight() * scaleBy);

// you can change these values as you to zoom in/out
// and even distort (scale without maintaining the aspect ratio)
// the resulting images

// Long running
Bitmap bitmap = page.renderBitmap(with, height, rectF);

try {
    File outputFile = new File(mOutputDir, System.currentTimeMillis() + FileUtils.DOT_JPEG);
    FileOutputStream outputStream = new FileOutputStream(outputFile);

    // a bit long running
    bitmap.compress(Bitmap.CompressFormat.JPEG, 100, outputStream);

    outputStream.close();
} catch (IOException e) {
    LogWrapper.fatalError(e);
}
}

You should perform this task in background e.g. AsyncTask

Muhammad Hamza Shahid
  • 956
  • 1
  • 15
  • 23