I've done experiments. It looks like the "y" value from
pdfview.currentDestination (in Swift - I don't know much of objc) is the
point of the pdf page at the _top_ of the PDFView, while the "y" value in
the "at:" argument of PDFView.go(to: PDFDestination(page:at:)) is for the
_vertical center_ of the PDFView. I did the following and it looks working.
1. Let y = the y value from PDFView.
2. Let pageIndex = the current page index.
3. Let h = 0.5 * the height of PDFView / its scaleFactor.
4. Let yadj = y - h.
5. If yadj < 0, then (a) increase pageIndex by 1 if I can and get "ymax" as
the height of the page bound for this pageIndex, (b) let yadj = ymax - (h -
y) + (pageBreakMargins top + bottom).
6. Finally, PDFView.go(to: ***, at: CGPoint(x: ***, y: yadj)).
The full "reload" function in my custom "Document" class (in
Document.swift) is this:
var pdf: PDFDocument?
@IBAction func reload(_ id: AnyObject) {
if let url = fileURL {
let wc = windowControllers[0]
let view = (wc.contentViewController as! ViewController).pdfview
!
let curDest = view.currentDestination
var index: Int? = nil
if let page = curDest?.page {
index = view.document?.index(for: page)
}
let point = curDest?.point
view.document = PDFDocument(url: url)
if index != nil && point != nil {
if let doc = view.document {
let y = point!.y
let h = view.bounds.height/view.scaleFactor*0.5
var yadj = y-h
if h > y {
if index! < doc.pageCount - 1 {
index = index! + 1
}
}
if let page = doc.page(at: index!) {
if h > y {
let pbm = view.pageBreakMargins
let ymax = page.bounds(for: .mediaBox).size.
height
yadj = ymax - (h - y) + (pbm.top + pbm.bottom)
}
view.go(to: PDFDestination(page: doc.page(at:
index!)!, at: CGPoint(x: point!.x, y: yadj)))
}
}
}
}
}
On Sun, Oct 1, 2017 at 9:08 PM, José Miguel Figueroa-O'Farrill <
[email protected]> wrote:
> Yes, this is similar to what I’m experiencing. Every reload (even if I
> just recompile without doing any changes) has the following effect: it
> moves the document up by precisely half of the “window” size. (Sorry I’m
> not sure of the precise word: I mean the size of the visible portion of the
> document in the Skim window.) In this way, I can start, say, with Skim
> displaying the last page of a paper, and simply by recompiling and
> reloading I can move up to the first page of the paper. This happens only
> in continuous mode (either single page or double page). I forget whether
> this is the same behaviour as before, though.
>
> Thanks,
> José
>
>
> > On 1 Oct 2017, at 03:31, Chirok Han <[email protected]> wrote:
> >
> > The issue appears slightly differently to me. In my case (Skim version
> 1.4.29 (103)), on High Sierra, the page jumps up by approximately a half of
> the current view until the page divider is located exactly in the middle.
> For example, if I start at the bottom of page 10, after recompiling the
> latex source once or twice depending on the zoom level, the divider of page
> 9 and page 10 is located exactly in the middle.
> >
> > Thanks, again, for the excellent app, by the way.
> >
> > Chirok
> >
> >
> > On Fri, Sep 29, 2017 at 6:16 PM, Christiaan Hofman <[email protected]>
> wrote:
> > Really annoying. Apple told me they fixed this in High Sierra. But
> apparently they broke it in another way at the same time. I have very
> little hope we can fix this.
> >
> > Christiaan
> >
> > ------------------------------------------------------------
> ------------------
> > Check out the vibrant tech community on one of the world's most
> > engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> > _______________________________________________
> > Skim-app-users mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/skim-app-users
> >
> >
> > ------------------------------------------------------------
> ------------------
> > Check out the vibrant tech community on one of the world's most
> > engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> > _______________________________________________
> > Skim-app-users mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/skim-app-users
>
> Prof José Figueroa-O'Farrill
> School of Mathematics
> University of Edinburgh
> PGP Key: 0x6A6BD529 (MIT PGP Key Server)
>
> The University of Edinburgh is a charitable body, registered in Scotland,
> with registration number SC005336.
>
>
>
>
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Skim-app-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/skim-app-users
>
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Skim-app-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-users