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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:52:06+00:00 2026-06-12T07:52:06+00:00

I am creating pdf File using the screen shots taking programatically from webView. But

  • 0

I am creating pdf File using the screen shots taking programatically from webView.

But main problem is that below code does not insert page break its only creating whole page.

Please tell me how to insert pageBreak or create multiple page in pdf.

- (void) drawPdf
{
    CGSize pageSize = CGSizeMake(612, webViewHeight);
    NSString *fileName = @"Demo.pdf";
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *pdfFileName = [documentsDirectory stringByAppendingPathComponent:fileName];

    UIGraphicsBeginPDFContextToFile(pdfFileName, CGRectZero, nil);
    UIGraphicsBeginPDFPageWithInfo(CGRectMake(0, 0, pageSize.width, pageSize.height), nil);

    // Mark the beginning of a new page.
    //UIGraphicsBeginPDFPageWithInfo(CGRectMake(0, 0, pageSize.width, pageSize.height), nil);

    double currentHeight = 0.0;

    for (int index = 1; index <= imageName ; index++)
    {

        NSString *pngPath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%d.png", index]];
        UIImage *pngImage = [UIImage imageWithContentsOfFile:pngPath];

        [pngImage drawInRect:CGRectMake(0, currentHeight, pageSize.width, pngImage.size.height)];        
        currentHeight += pngImage.size.height;

    }
UIGraphicsEndPDFContext();

}
  • 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-12T07:52:07+00:00Added an answer on June 12, 2026 at 7:52 am
    - (void) drawPdf
    {
        CGSize pageSize = CGSizeMake(612, webViewHeight);
        NSString *fileName = @"Demo.pdf";
        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
        NSString *documentsDirectory = [paths objectAtIndex:0];
        NSString *pdfFileName = [documentsDirectory stringByAppendingPathComponent:fileName];
    
        UIGraphicsBeginPDFContextToFile(pdfFileName, CGRectZero, nil);
    
    
        // Mark the beginning of a new page.
        //UIGraphicsBeginPDFPageWithInfo(CGRectMake(0, 0, pageSize.width, pageSize.height), nil);
    
        double currentHeight = 0.0;
    
        for (int index = 1; index <= imageName ; index++)
        {
          UIGraphicsBeginPDFPageWithInfo(CGRectMake(0, 0, pageSize.width, pageSize.height), nil);
         //Above line would work to make page break
    
            NSString *pngPath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%d.png", index]];
            UIImage *pngImage = [UIImage imageWithContentsOfFile:pngPath];
    
            [pngImage drawInRect:CGRectMake(0, 0, pageSize.width, pngImage.size.height)];        
            currentHeight += pngImage.size.height;
    
        }
    UIGraphicsEndPDFContext();
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are creating PDF documents on the fly from the database using PDFsharp .
I'm using html2fpdf for creating PDF documents. Now once I have created that, I
I'm using code to create a PDF File. Works. But: I want my whole
After creating a PDF file in PHP Using DOMPDF, I need to redirect user
I'm creating PDF files with PHP using TCPDF. I have a small problem with
I tried creating a pdf file out of another one(in my local drive) using
I am working on creating thumbnail image from the first page of pdf file.
I have the following acceptance criteria for creating a pdf file from my asp.net
Language : ASP.NET/VB.NET I am creating pdf file using itextsharp library. On my development
I am creating a pdf report file using a xsl. On the header I

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.