There are lots of examples out there of how to get NSScrollView to center its document view. Here are two examples (which are so similar that somebody is copying somebody
The answer above by uchuugaka works very well and, as pointed out, it is very much simpler than older solutions.
The code above calls the function centeredCoordinateUnitWithProposedContentViewBoundsDimensionAndDocumentViewFrameDimension(), but the source for this isn't provided.
The function is trivial, but for completeness here's an an implementation:
CGFloat centeredCoordinateUnitWithProposedContentViewBoundsDimensionAndDocumentViewFrameDimension( CGFloat clipDimension, CGFloat docDimension)
{
CGFloat newOrigin;
newOrigin = roundf((docDimension - clipDimension) / 2.0);
return newOrigin;
}