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 7083093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:08:08+00:00 2026-05-28T07:08:08+00:00

In the application I’m creating, I load a long page of HTML into a

  • 0

In the application I’m creating, I load a long page of HTML into a webView and then print it to a PDF using the following:

-(void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
{
    if ([frame isEqual:[[self doc] mainFrame]]) 
    {
        NSMutableData *newData = [[NSMutableData alloc] init];
        NSPrintInfo *newInfo = [NSPrintInfo sharedPrintInfo];
        NSView *docView = [[[[self doc] mainFrame] frameView] documentView];

        NSPrintOperation *newPrintOp = [NSPrintOperation PDFOperationWithView:docView insideRect:docView.bounds toData:newData printInfo:newInfo];

        BOOL runPrint = [newPrintOp runOperation];  
        if (!runPrint)
        {
           NSLog(@"Print Failed");
        }
        PDFDocument *newDoc = [[PDFDocument alloc] initWithData:newData];
        [newData release];
        [self setPdf:newDoc];

        //Other code here
        }
    }

The problem is that when I look at newDoc, it is a huge PDF of a single page. What I would prefer would be the printing acting the same as it does from the “save as PDF…” dialog – that is, splitting the PDF into multiple reasonably-sized pages.

Does anyone know how to accomplish this?

I attempted inserting the following after NSPrintInfo *newInfo = [NSPrintInfo sharedPrintInfo];

[newInfo setVerticalPagination:NSAutoPagination];
[newInfo setHorizontalPagination:NSAutoPagination];

NSAutoPagination is described in the docs as the following:

NSAutoPagination
The image is divided into equal-sized rectangles and placed in one column of pages.
Available in Mac OS X v10.0 and later.
Declared in NSPrintInfo.h.

This had no effect on the printed PDF.

  • 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-05-28T07:08:09+00:00Added an answer on May 28, 2026 at 7:08 am

    You get a file with one large page because + PDFOperationWithView: method doesn’t support pagination at all. For that reason calling - setVerticalPagination: or - setHoriziontalPagination: doesn’t change anything.

    You could try use “classical” + printOperationWithView:printInfo: method, configure it to save PDF to temporary location and then create PDFDocument with contents of obtained file. I hope that fragment of code below will help.

    NSMutableDictionary *dict = [[NSPrintInfo sharedPrintInfo] dictionary];
    [dict setObject:NSPrintSaveJob forKey:NSPrintJobDisposition];
    [dict setObject:temporaryFilePath forKey:NSPrintSavePath];
    NSPrintInfo *pi = [[NSPrintInfo alloc] initWithDictionary:dict];
    [pi setHorizontalPagination:NSAutoPagination];
    [pi setVerticalPagination:NSAutoPagination];
    
    NSPrintOperation *op = [NSPrintOperation printOperationWithView:[[[webView mainFrame] frameView] documentView] printInfo:pi];
    [pi release];
    [op setShowsPrintPanel:NO];
    [op setShowsProgressPanel:NO];
    
    if ([op runOperation] ){
        PDFDocument *doc = [[[PDFDocument alloc] initWithURL:[NSURL fileURLWithPath: temporaryFilePath]] autorelease];
        // do with doc what you want, remove file, etc.
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Application configuration: Web application using java first method of creating JAX-WS 2.0 Web Services
My application is connecting to a web service rpc/encoded. Im using Axis 1.4. When
The application prepared by me is using GCM to get push notifications from the
Application Error An error occurred in the application and your page could not be
Application crash due to this reason -[NSConcreteValue doubleValue]: unrecognized selector sent to Following code
Application is crashing on webcore, In our application we are loading HTML5 page on
My application has the session timeout, the application goes to the login page after
Application db connection in web service. i haveto connect the db using that web
Application was built using MS interop, to export .xls to infoPath and vice versa.
Application is sending email by using MFMailComposeViewController , everything works just fine. However after

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.