iPhonePDF
iPhonePDF copied to clipboard
Create a new page into pdf file..
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,
@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?