Microsoft Windows Phone 8.1 support ends (13 Jul 2017)

Microsoft has ended support for Windows Phone 8.1

Questions about iOS development and PDF

Problem reloading PDF

More
9 years 5 months ago - 9 years 5 months ago #11361 by vicbor
Problem reloading PDF was created by vicbor
Our client just purchased a license and we are currently trying to replace UIWebView with RadaeePDF to just view the PDFs. We have some legacy logic that modifies the PDF (not with Radaee) while it is being displayed so we need to reload it. This worked fine with the UIWebView but we can get the reload part to work with Radaee.

The behavior we are experiencing is the PDF not being redrawn until 10-20 seconds or until the user starts scrolling the view. It seems that the thread is waiting for a mutex to be released, but not sure why is the mutex locked.

This is the code that we use to load (and reload) the PDF:
Code:
PDF_ERR err = 0; [m_view removeFromSuperview]; [m_view vClose]; m_doc = [[PDFDoc alloc] init]; err = [m_doc open:path :pwd]; CGRect rect = [[UIScreen mainScreen]bounds]; m_view = [[PDFView alloc] initWithFrame:CGRectMake(0, 0, rect.size.width, rect.size.height-20-44)]; // Disable vertical & horizontal bouncing m_view.alwaysBounceVertical = NO; m_view.alwaysBounceHorizontal = NO; // Set delegate m_view.delegate = self; [m_view vOpen :m_doc :(id<PDFViewDelegate>)self]; pagecount = [m_doc pageCount]; [self.pdfArea addSubview:m_view]; [m_view vSetPos:&previousPosition];

Basically the notify_render method is not called immediately but instead after 10 seconds or as soon as the user starts scrolling.

Previously we were reusing the view but then, as you can see, we tried to recreate it completely just to see if it solved the issue.

We have tried calling vRenderAsync and vRenderSync without success. We also tried calling PDFView refresh method in order to trigger UIVIew setNeedsDsplay with no luck either.

Is there any way to force the redraw or a better approach to what we are trying to do?

Thanks
Last edit: 9 years 5 months ago by vicbor.
More
9 years 5 months ago #11363 by emanuele
Replied by emanuele on topic Problem reloading PDF
Hi,

if I understood correctly, you have an opened pdf file and in another process you modified it and you want to reload it.
I tried with this sample method in RDPDFViewController and it seems to work correctly:
Code:
- (void)refreshPdf { //get the current page int page = [m_view vGetCurrentPage]; //close the pdf file and reset the m_doc and m_view [self PDFClose]; //reopen the pdf file [self PDFOpen:samePdfPath :@""]; //go to current page [self PDFGoto:page]; }
More
9 years 5 months ago #11364 by tonygd
Replied by tonygd on topic Problem reloading PDF
I have taken a look on this codes but it takes some time to reload like 10 - 20 seconds.
So I did some debugging and i found that after 10-20 seconds after refresh function that you gave, it called this below function

-(void)OnPageRendered:(PDFVCache *)cache{
[self refresh];
}


Can you give us a refresh function that refresh immediately ? Not like this, or did I setup something wrong ?
More
9 years 5 months ago #11367 by emanuele
Replied by emanuele on topic Problem reloading PDF
Hi,

it's possible that you are calling that method in a background thread?
Have you tried to force it on main thread?
Time to create page: 0.412 seconds
Powered by Kunena Forum