Microsoft Windows Phone 8.1 support ends (13 Jul 2017)

Microsoft has ended support for Windows Phone 8.1

Questions about Android development and PDF

How to convert page to bitmap?

More
IP: 113.196.174.254 2 years 3 weeks ago #15861 by Chunwen
I use below code to open a pdf file. How can I convert specific page to Bitmap? Can I convert in the background?
For example, I want to generate 5 bitmaps from page 3 to page 7. How can I do it?


private com.radaee.reader.PDFGLLayoutView m_view;
com.radaee.pdf.Document m_doc = new com.radaee.pdf.Document();
com.radaee.util.PDFFileStream stream = new com.radaee.util.PDFFileStream();


m_view = new com.radaee.reader.PDFGLLayoutView(m_Activity);

com.radaee.pdf.Global.Init(m_Activity);

stream.open(m_pdf_path);

int ret = m_doc.OpenStream(stream, null);

m_view.PDFOpen(m_doc, null, DefaultLayout.this);

m_view.PDFSetView(3);
More
IP: 113.196.174.254 2 years 3 weeks ago - 2 years 3 weeks ago #15862 by Chunwen
I solved by myself


for(int i = 0; i< totalPage; i++) {
int pageWidth = (int) m_doc.GetPageWidth(i);
int pageHeight = (int) m_doc.GetPageHeight(i);
Page page = m_doc.GetPage(i);

Bitmap bitmap = Bitmap.createBitmap(pageWidth, pageHeight, Bitmap.Config.ARGB_8888);

float m_ratio = 1;
com.radaee.pdf.Matrix mat = new com.radaee.pdf.Matrix(m_ratio, -m_ratio, 0, pageHeight * m_ratio);
page.RenderPrepare(bitmap);
page.RenderToBmp(bitmap, mat);
BMP bmp = new BMP();
bmp.Create(bitmap);
bmp.MulAlpha();//for transparent background.
bmp.Free(bitmap);
try {
FileOutputStream fout = new FileOutputStream("/sdcard/test"+i+".png");
bitmap.compress(Bitmap.CompressFormat.PNG, 0, fout);
fout.close();
} catch (Exception e) {
}

mat.Destroy();
page.Close();
}
Last edit: 2 years 3 weeks ago by Chunwen.
More
IP: 87.16.11.43 2 years 2 weeks ago #15863 by support
If you need more details take a look here  www.radaeepdf.com/support/knowledge-base?view=kb&kbartid=98
 
Time to create page: 0.403 seconds
Powered by Kunena Forum