- Posts: 36
- Thank you received: 0
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
Rendering of preview of page
- petr.sklenicka
- Topic Author
- Offline
- Junior Member
-
Less
More
IP: 192.168.0.71
11 years 2 months ago - 11 years 2 months ago #8265
by petr.sklenicka
Rendering of preview of page was created by petr.sklenicka
Hi,
I have a problem with rendering previews of pages. There is a one page in my PDF document, which causes hard crash when rendering preview of this page. The rendering of previews works fine for all other pages, but this one page causes some hard error.
This is a link for this page: www.dropbox.com/s/fw2j5occ3ss3ojb/Page.pdf?dl=0
I am able to display this page, but I am not able to render the preview of this page.
Can you please give me an advice, what is wrong or how can I solve it?
Many thanks, Petr.
UPDATE:
I am using the newest version of native library.
I have a problem with rendering previews of pages. There is a one page in my PDF document, which causes hard crash when rendering preview of this page. The rendering of previews works fine for all other pages, but this one page causes some hard error.
This is a link for this page: www.dropbox.com/s/fw2j5occ3ss3ojb/Page.pdf?dl=0
I am able to display this page, but I am not able to render the preview of this page.
Can you please give me an advice, what is wrong or how can I solve it?
Many thanks, Petr.
UPDATE:
I am using the newest version of native library.
Last edit: 11 years 2 months ago by sanyu erisa. Reason: Add some information
IP: 192.168.0.71
11 years 2 months ago #8266
by radaee
Replied by radaee on topic Rendering of preview of page
how you rendering previews of pages?
may you give piece of codes?
may you give piece of codes?
- petr.sklenicka
- Topic Author
- Offline
- Junior Member
-
Less
More
- Posts: 36
- Thank you received: 0
IP: 192.168.0.71
11 years 2 months ago #8267
by petr.sklenicka
Replied by petr.sklenicka on topic Rendering of preview of page
I am using this piece of code:
where method renderThumb looks like this:
and code for render method:
Then, I need to save preview into the file. I am using this: www.androidpdf.mobi/forum/Android-develo...f-page-into-the-file
Code:
PDFVPage page = mPages[numberOfPage];
...
// get width and height of page
...
// Rendering process
page.thumbPrepare(width, height, scale);
Bitmap bitmap = mRenderThread.renderThumb(page.m_thumb, width, height);
page.m_thumb.clear();
if (bitmap != null) {
return bitmap;
} else {
throw new IOException("The bitmap has not been rendered");
}
where method renderThumb looks like this:
Code:
public Bitmap renderThumb(PDFVThumb thumb, int width, int height) {
return thumb.render(width, height);
}
and code for render method:
Code:
protected Bitmap render(int width, int height) {
m_page = m_doc.GetPage(m_pageno);
if (m_bmpw > 0 && m_bmph > 0) {
try {
Bitmap bmp = Bitmap.createBitmap(width, height, Config.ARGB_8888);
bmp.eraseColor(0xFFFFFFFF);
Matrix mat = new Matrix(m_scale, -m_scale, 0, m_bmph);
m_page.RenderToBmp(bmp, mat);
mat.Destroy();
return bmp;
} catch (Exception e) {
return null;
}
}
return null;
}
Then, I need to save preview into the file. I am using this: www.androidpdf.mobi/forum/Android-develo...f-page-into-the-file
IP: 192.168.0.71
11 years 2 months ago - 11 years 2 months ago #8268
by radaee
Replied by radaee on topic Rendering of preview of page
codes modified so much...
in last version, there are no PDFVThumb class.
i think codes like this:
in last version, there are no PDFVThumb class.
i think codes like this:
Code:
protected Bitmap render(int width, int height)
{
Page page = m_doc.GetPage(m_pageno);
if (m_bmpw > 0 && m_bmph > 0) {
try {
Bitmap bmp = Bitmap.createBitmap(width, height, Config.ARGB_8888);
bmp.eraseColor(0xFFFFFFFF);
Matrix mat = new Matrix(m_scale, -m_scale, 0, m_bmph);
page.RenderToBmp(bmp, mat);
mat.Destroy();
page.Close();
return bmp;
} catch (Exception e) {
if(bmp != null) bmp.recycle();
page.Close();
return null;
}
}
if(bmp != null) bmp.recycle();
page.Close();
return null;
}
Last edit: 11 years 2 months ago by .
Time to create page: 0.394 seconds