Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8781771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:23:28+00:00 2026-06-13T20:23:28+00:00

How does one get a PDFView to display a PDF without having to resize

  • 0

How does one get a PDFView to display a PDF without having to resize the window or doing a
scroll to force a redraw.

It’s as if a setNeedsDisplay needs to be done, yet that has no effect.

I’ve the simplest app I can think of to display a PDF using a PDFView.

Basically create a new app in Xcode and change the code to be:

// AppDelegate.h
#import <Cocoa/Cocoa.h>
#import <Quartz/Quartz.h>
@interface AppDelegate : NSObject <NSApplicationDelegate>
@property (assign) IBOutlet NSWindow *window;
@property (assign) IBOutlet PDFView *pdfView;
@end

and

// AppDelegate.m
#import "AppDelegate.h"
@implementation AppDelegate
@synthesize window = _window;
@synthesize pdfView = _pdfView;

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    NSURL *pdfURL = [[NSBundle mainBundle] URLForResource:@"TestPage" withExtension:@"pdf"];
    PDFDocument *document = [[PDFDocument alloc] initWithURL: pdfURL];     
    self.pdfView.document = document;
}
@end

I’ve noticed the same behaviour in the Apple code example PDFKitLinker2 where one has to either scroll over the PDF or resize the window to get the PDF to display.

Granted I’m new to the world of Cocoa development but I’ve searched and found no really small examples that show how to display a PDF. What I’ve produced would seem to be correct yet I have doubts given that even PDFKitLinker2 doesn’t seem to be correct.

I’ve created a Git repo of an Xcode project that demonstrates the issue for those that have time to help and/or comment.

git clone git@bitbucket.org:sotapme/pdfview_open.git

Using Xcode Version 4.3.3 (4E3002) – Latest Lion.

Thanks in advance for any help.


A Solution that works.


I found a solution whereby if I create a sub class of PDFView with an empty implementation and then add that as a custom view and wire it up my existing IBOutlet it works.

Makes no sense at all to me 🙁

//DPPDFView.h
#import <Quartz/Quartz.h>
@interface DPPDFView : PDFView
@end

and

//DPPDFView.m
#import "DPPDFView.h"
@implementation DPPDFView
@end

Apple’s docs do say:

PDFView may be the only class you need to deal with for adding PDF functionality to your application. It lets you display PDF data and allows users to select content, navigate through a document, set zoom level, and copy textual content to the Pasteboard. PDFView also keeps track of page history.

You can subclass PDFView to create a custom PDF viewer.

I leave this question and self answer for those that may pass by with similar questions, hoping that it will be a dim beacon of light for them; Also hoping someone with more Cocoa wisdom will point out the error in my thinking.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T20:23:29+00:00Added an answer on June 13, 2026 at 8:23 pm

    I figured this is indeed caused by the PDFview needing a setNeedsDisplay after lazyloading has finished actually loading the PDF document.

    A hack, but adding the below to your – (void)windowDidLoad method at least displays the document properly without needing a resize.

    dispatch_async(dispatch_get_main_queue(), ^{
        [self.myPDFView setNeedsDisplay:YES];
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How does one get the screen resolution of the current monitor? By current monitor,
Does any one know if its possible to animate app.current.mainwindow.width so that you get
How does one get the upper left coordinates of a framework elements bounding rectangle?
In Silverlight, how does one get row data from a DataGrid that is full
In C#, .NET 3.5, in a Windows Forms application... How does one get the
How does one get SEO friendly url's in sunspot?, The method of search form
How does one get the size of the drawing area in a Windows Form?
How does one use tnameserv on OSX? Everytime I start the server, I get
How does one delete data from a map in Go? For example, having m
How does one get the destination point from ItemDragEventArgs ? With Microsoft.Windows.DragEventArgs e it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.