Skip to content

Create a new page into pdf file.. #2

Open

Description

@meetdoshi1992

Hi akisute ,

I can not able to create a 2nd page into PDF file using this library. Can you please give me some hint for this.?

Thanks,

Activity

  1. akisute commented on Oct 4, 2016

    @akisute
    Owner

    @meetdoshi1992
    Hi there! 😄

    My library is just merely a thin wrapper of libHaru, so I guess something is wrong with your usage of libHaru API. Here's a simple tutorial of libHaru usage:
    http://libharu.sourceforge.net/how_to_use.html

    As far as I can see, you may just call HPDF_AddPage() each time after you have drawn your page content, like this:

    // Create a data context
    PDFService_userData userData;
    HPDF_Doc pdf = HPDF_New(PDFService_defaultErrorHandler, &userData);
    userData.pdf = pdf;
    userData.service = self;
    userData.filePath = filePath;
    
    // Add page 1
    LOG(@"[libharu] Adding page 1");
    HPDF_Page page1 = HPDF_AddPage(pdf);
    LOG(@"[libharu] SetSize page 1");
    HPDF_Page_SetSize(page1, HPDF_PAGE_SIZE_A4, HPDF_PAGE_LANDSCAPE);
    
    // Draw something in page 1...
    // After you're done
    
    // Add page 2
    LOG(@"[libharu] Adding page 2");
    HPDF_Page page2 = HPDF_AddPage(pdf);
    LOG(@"[libharu] SetSize page 2");
    HPDF_Page_SetSize(page2, HPDF_PAGE_SIZE_A4, HPDF_PAGE_LANDSCAPE);
    
    // And draw something in page 2...
    // and so on...
    // Once you're done drawing all pages you need, then
    
    // Save the drawn PDF file to a specified path
    pathCString = [filePath cStringUsingEncoding:1];
    LOG(@"[libharu] SaveToFile filePath:%@\n pathCString:%s", filePath, pathCString);
    HPDF_SaveToFile(pdf, pathCString);
    
    

    ...but something could be wrong. Would you mind copy&paste your code here so I can consult further?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions