VDual drawing on vGoto Not Centered - RadaeePDF.com
Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
13 Jul 2017
Microsoft has ended support for Windows Phone 8.1
Read More...
Questions about iOS development and PDF
  • Page:
  • 1

TOPIC: VDual drawing on vGoto Not Centered

VDual drawing on vGoto Not Centered 4 years 3 weeks ago #7522

  • kurt_zelda
  • kurt_zelda's Avatar Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 20
  • Karma: 1
  • Thank you received: 0
I’ve a problem on drawing pdf view after selecting a page on thumbnail, function vGoto draw the page on top of screen instead of centering it.
Only after a tap on page pdfview moves on right place (centering into screen).
This is the vGoto code inside the original pdfview.m.

-(void)vGoto:(int)pageno
{
struct PDFV_POS pos;
//it position 0,0 should centered into screen?
NSLog(@"PDFView rect :%f %f %f %f ",self.frame.origin.x, self.frame.origin.y,self.frame.size.width,self.frame.size.height);

pos.x = 0;
pos.y = [m_doc pageHeight:pageno];
pos.pageno = pageno;
[m_view vSetPos:&pos :0 :0];


CGPoint pt;
pt.x = [m_view vGetX]/m_scale;
pt.y = [m_view vGetY]/m_scale;
self.contentOffset = pt;
[self refresh];

}

how can I center it into the screen programmatically?

Please Log in or Create an account to join the conversation.

VDual drawing on vGoto Not Centered 4 years 3 weeks ago #7580

  • emanuele
  • emanuele's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 516
  • Karma: 15
  • Thank you received: 56
Hi,
there are two ways to center the page:
  • instead using [m_view vSetPos:&pos :0 :0] you can calculate x and y to center the page (0,0 is the top-left corner position), and call something like [m_view vSetPos:&pos :centerX :centerY];
  • use pagingEnabled property and scroll to page with scrollView feature; something like:
    CGRect frame = CGRectMake(0, 0, self.contentSize.width/m_doc.pageCount, self.contentSize.height);
    frame.origin.x = frame.size.width * pageno;
    frame.origin.y = 0;
    [self scrollRectToVisible:frame animated:YES];

Please Log in or Create an account to join the conversation.

Last edit: by CBA.

VDual drawing on vGoto Not Centered 4 years 2 weeks ago #7627

  • kurt_zelda
  • kurt_zelda's Avatar Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 20
  • Karma: 1
  • Thank you received: 0
Thank you.
In effect, due to rotation I need to change something (scale, position, ...), but now it's ok.

There is a way to get the "x" position of a particular page (in case of pages of different formats??

Please Log in or Create an account to join the conversation.

Last edit: by Fredy.

VDual drawing on vGoto Not Centered 4 years 2 weeks ago #7633

  • emanuele
  • emanuele's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 516
  • Karma: 15
  • Thank you received: 56
Hi,

I think you should calculate the correct position with the page width and the screen width

Please Log in or Create an account to join the conversation.

VDual drawing on vGoto Not Centered 4 years 2 weeks ago #7634

  • kurt_zelda
  • kurt_zelda's Avatar Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 20
  • Karma: 1
  • Thank you received: 0
I've finally find the method. :woohoo:

I've created a function inside PDFV (and DUAL) for giving the position of the left/top corner of the pdf page and called inside goto like this:

-(void)vGoto:(int)pageno
{
CGPoint pt;
int x=0;
int y=0;
[m_view vGetPDFXY:pageno : &x : &y];
pt.x=x;
pt.y=y;
self.contentOffset=pt;

[self refresh];


}

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Powered by Kunena Forum