Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 08-10-2010, 02:51 AM   #1 (permalink)
Registered Member
 
Join Date: Aug 2010
Posts: 14
RUser is on a distinguished road
Default Problem to generate PDF

Hi Devs,
I am trying to generate a PDF which copies content from another PDF. To do so i have implemented following code which works fine for most of PDF but it doesn't work for attached PDF file.


CGContextRef pdfContext;
CFStringRef path;
CFURLRef url;
CFMutableDictionaryRef myDictionary = NULL;
NSInteger pageWidth,pageHeight;
CGPDFPageRef page;

filename = [pdfFilePath UTF8String];
path = CFStringCreateWithCString (NULL, filename,kCFStringEncodingUTF8);

url = CFURLCreateWithFileSystemPath (NULL, path,kCFURLPOSIXPathStyle,0);
CFRelease (path);

myDictionary = CFDictionaryCreateMutable(NULL, 0,&kCFTypeDictionaryKeyCallBacks,&kCFTypeDictionar yValueCallBacks);
struct CGRect pageRect = CGRectMake(0, 0, 768, 960);

CFDictionarySetValue(myDictionary, kCGPDFContextTitle, CFSTR("PDFReaderDemo"));
CFDictionarySetValue(myDictionary, kCGPDFContextCreator, CFSTR("Hello"));
pdfContext = CGPDFContextCreateWithURL(url, &pageRect, myDictionary);

CGContextBeginPage (pdfContext, &pageRect);
CGContextSaveGState(pdfContext);

float fltScaleX = 768.0f/pageWidth;
float fltScaleY = 960.0f/pageHeight;
CGRect drawRect = CGRectMake(0.0f, 0.0f, 768, 960);


CGContextTranslateCTM(pdfContext, 0.0f, 960.0f);
CGContextScaleCTM(pdfContext,fltScaleX, fltScaleY);
struct CGRect mediaBox123 = CGRectMake(0, 0, 768.0, -960.0);

/////////////// Code implemented to copy PDF page from another PDF
page = CGPDFDocumentGetPage (document, i+1);
CGAffineTransform pdfTransform = CGPDFPageGetDrawingTransform(page, kCGPDFMediaBox, mediaBox123, 0, true);
CGContextConcatCTM(pdfContext, pdfTransform);
CGContextClipToRect(pdfContext, drawRect);
CGContextDrawPDFPage(pdfContext, page);
CGContextRestoreGState(pdfContext);
CGContextEndPage(pdfContext);
CGPDFContextClose(pdfContext);

PDF Link: Download Sample1.PDF for free on uploading.com

Thanks in Advance...
RUser is offline   Reply With Quote
Old 08-10-2010, 08:45 AM   #2 (permalink)
iphone developer
 
sivaram's Avatar
 
Join Date: Jun 2010
Location: Chennai
Age: 24
Posts: 32
sivaram is on a distinguished road
Send a message via Skype™ to sivaram
Thumbs up

hi,
i need a help from you. I am developing a pdf viewer application in that i need to search any word inside the pdf if it found i need to go for that page and highlight the word.

Thanks in advance...
sivaram is offline   Reply With Quote
Old 08-11-2010, 03:23 AM   #3 (permalink)
Registered Member
 
Join Date: Aug 2010
Posts: 14
RUser is on a distinguished road
Default

Quote:
Originally Posted by sivaram View Post
hi,
i need a help from you. I am developing a pdf viewer application in that i need to search any word inside the pdf if it found i need to go for that page and highlight the word.

Thanks in advance...
Hi Sivaram,
I have not worked with what your asking for, but PDF Parser may help you...

Help: Quartz 2D Programming Guide: PDF Document Parsing
RUser is offline   Reply With Quote
Old 08-11-2010, 04:30 AM   #4 (permalink)
iphone developer
 
sivaram's Avatar
 
Join Date: Jun 2010
Location: Chennai
Age: 24
Posts: 32
sivaram is on a distinguished road
Send a message via Skype™ to sivaram
Thumbs up

Quote:
Originally Posted by RUser View Post
Hi Sivaram,
I have not worked with what your asking for, but PDF Parser may help you...

Help: Quartz 2D Programming Guide: PDF Document Parsing
hi,
Thank a lot. I am going through that tutorial only but still not getting any idea.
will any one help me to search a word in pdf...
sivaram is offline   Reply With Quote
Old 04-29-2011, 07:46 AM   #5 (permalink)
Registered Member
 
Join Date: Apr 2011
Posts: 3
techster is on a distinguished road
Default

Hi Sivaram

Were you able to achieve this?

I am also trying to do similar things in addition to viewing pdf as well.


TIA
techster is offline   Reply With Quote
Reply

Bookmarks

Tags
iphone, pdf, xcode

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 324
8 members and 316 guests
ilmman, iram91419, linkmx, nadav@webtview.com, Objective Zero, Paul Slocum, stanny, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,656
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, iram91419
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 11:41 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0