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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Tutorials > Tutorial Requests

Reply
 
LinkBack Thread Tools Display Modes
Old 01-02-2009, 12:43 PM   #1 (permalink)
Registered Member
 
Join Date: Sep 2008
Posts: 48
Default Tutorial Request:Creating a PDF file in iPhone app

I can see in the Quartz 2D Programming Guide that you can indeed create PDF files on the iPhone. I can't quite get my head around the sample function Apple has provided and would love to see a tutorial that simply shows how to create a PDF file that draws an image and some text in, and save it to the iPhone.

Thanks in advance!
danielb21 is offline   Reply With Quote
Old 01-02-2009, 01:58 PM   #2 (permalink)
iPhone App Developer
 
chbeer's Avatar
 
Join Date: Sep 2008
Location: Berlin, Germany
Posts: 229
Default

I would do the following steps:
  1. Learn C and Objective-C
  2. Learn Cocoa
  3. Investigate / Learn the iPhone framework
  4. Build your PDF program

HTH
__________________
Learn vocabularies on iPhone? iVocabulary!
chbeer is offline   Reply With Quote
Old 01-02-2009, 09:52 PM   #3 (permalink)
Registered Member
 
Join Date: Sep 2008
Posts: 48
Default Solved It

After spending a few more hours on this, I have it working. If there is anyone that is interested I will work on a tutorial, though it probably won't be a fancy screencast or anything.

Also chbeer, please don't assume that people are ignorant just because they ask a question. I wasn't asking for an application to be built for me. I simply thought a tutorial on this might be helpful as I'm sure I'm not the only one that has had or will have this question in the future.
danielb21 is offline   Reply With Quote
Old 01-03-2009, 03:36 AM   #4 (permalink)
iPhone App Developer
 
chbeer's Avatar
 
Join Date: Sep 2008
Location: Berlin, Germany
Posts: 229
Default

Quote:
Originally Posted by danielb21 View Post
Also chbeer, please don't assume that people are ignorant just because they ask a question. I wasn't asking for an application to be built for me. I simply thought a tutorial on this might be helpful as I'm sure I'm not the only one that has had or will have this question in the future.
I don't assume people are ignorant or something. I don't assume anything.

I just think you should spend more time yourself into learning (that's what you've done now) instead of asking others to spend their precious time for writing tutorials.
__________________
Learn vocabularies on iPhone? iVocabulary!
chbeer is offline   Reply With Quote
Old 01-03-2009, 02:33 PM   #5 (permalink)
New Member
 
Join Date: Jan 2009
Posts: 4
Red face Kidding?

Quote:
Originally Posted by chbeer View Post
I don't assume people are ignorant or something. I don't assume anything.

I just think you should spend more time yourself into learning (that's what you've done now) instead of asking others to spend their precious time for writing tutorials.
You have to be kidding me?

This is iPhone Dev SDK site, and this particular category is Tutorial Requests oh wait no your going to have a go at some for asking for a tutorial in a tutorial request category. Is it just me or are you wrong?

not being mean but don't bite peoples head off because they ask for something!!!

Superchild
Superchild is offline   Reply With Quote
Old 01-03-2009, 03:33 PM   #6 (permalink)
iPhone App Developer
 
chbeer's Avatar
 
Join Date: Sep 2008
Location: Berlin, Germany
Posts: 229
Default

Oh, I wasn't aware there is such forum. Then I must admit that I was very wrong... sorry!
__________________
Learn vocabularies on iPhone? iVocabulary!
chbeer is offline   Reply With Quote
Old 01-03-2009, 05:06 PM   #7 (permalink)
New Member
 
Join Date: Jan 2009
Posts: 4
Default

Quote:
Originally Posted by chbeer View Post
Oh, I wasn't aware there is such forum. Then I must admit that I was very wrong... sorry!
I did go over the top a bit , soz for that.
Superchild is offline   Reply With Quote
Old 02-07-2009, 06:06 PM   #8 (permalink)
Asa
New Member
 
Join Date: Feb 2009
Location: Bangkok, Thailand
Posts: 45
Default please make a tutorial

SuperChild,

I agree this section is for newbies wanting to learn.... I would be interested if you made a tutorial. Have been wondering how to interact with a PDF file natively.

THanks!
Asa is offline   Reply With Quote
Old 02-09-2009, 07:55 PM   #9 (permalink)
Registered Member
 
Join Date: Sep 2008
Posts: 48
Default

Ok everyone,

I have been so busy working on my apps that I forgot to get this tutorial written and up, so sorry about that. I am dedicating tomorrow to creating this tutorial first thing. I'll start with just creating a PDF file that has text, an image, basic shapes and whatnot. If we need to get more advanced from there I'll be happy to help.

See you all tomorrow!
danielb21 is offline   Reply With Quote
Old 06-01-2009, 05:34 PM   #10 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 30
Default

By any chance did you create the PDF tutorial?

Thanks!
sunfire is offline   Reply With Quote
Old 07-14-2009, 12:32 PM   #11 (permalink)
New Member
 
Join Date: Jul 2009
Posts: 2
Default

danielb21: Looks like you haven't had time to get that tutorial done, but any sample code you can post would be much appreciated. Thanks!

/afb
ablock is offline   Reply With Quote
Old 07-14-2009, 12:37 PM   #12 (permalink)
Registered Member
 
Join Date: Sep 2008
Posts: 48
Default

Quote:
Originally Posted by ablock View Post
danielb21: Looks like you haven't had time to get that tutorial done, but any sample code you can post would be much appreciated. Thanks!

/afb
Hey afb, that tutorial has actually been up for quite a while. You'll find it here:
PDF Creation Tutorial

Enjoy!
Dan
danielb21 is offline   Reply With Quote
Old 07-14-2009, 12:42 PM   #13 (permalink)
New Member
 
Join Date: Jul 2009
Posts: 2
Default

Awesome, thanks!
ablock is offline   Reply With Quote
Old 08-03-2009, 01:17 AM   #14 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 5
Default Displaying User input in the PDF

[quote=danielb21;102822]Hey afb, that tutorial has actually been up for quite a while. You'll find it here:
PDF Creation Tutorial

Thanks for making the tutorial...such a HUGE help.

I had a question

in your tutorial I create a global NSString *nameText in PDFViewController.m

and in viewDidLoad method set it to

nameText = [NSString stringWithFormat:@"%@", nameField.text];

then use

CGContextSelectFont (pdfContext, "Helvetica", 24, kCGEncodingMacRoman);
CGContextSetTextDrawingMode (pdfContext, kCGTextFill);
CGContextSetRGBFillColor (pdfContext, 0, 0, 0, 1);
const char *text2 = [nameText UTF8String];
CGContextShowTextAtPoint (pdfContext, 50, 375, text2, strlen(text2));

in void CreatePDFFile (CGRect pageRect, const char *filename)

when I run the app in the simulator and press the button app crashes and Xcode gives a obj_msgSend error.

Im trying to get it so the user can input a string in a textfield and have it displayed in the pdf but the error always occurs unless, I declare the nameText string in the void CreatePDFFile but then reads an error of nameField.text (undeclared first use in this function) when it was defined globally and working in other parts of the view and will not build.

any help or ideas would greatly be appreciated.
palian3 is offline   Reply With Quote
Old 08-03-2009, 09:38 AM   #15 (permalink)
Registered Member
 
Join Date: Sep 2008
Posts: 48
Default

Hey Palian,

In order to really diagnose what's happening I would have to see all of the code, both in your header and main files. If you don't want to post it here you can PM me and include it.

Thanks!
Dan
danielb21 is offline   Reply With Quote
Old 08-03-2009, 09:50 AM   #16 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 5
Default thanks

Quote:
Originally Posted by danielb21 View Post
Hey Palian,

In order to really diagnose what's happening I would have to see all of the code, both in your header and main files. If you don't want to post it here you can PM me and include it.

Thanks!
Dan
Ill email you my whole project. so you can see it in its entirety.

my email is

palian

3

@

gmail

.com

if you email me I will replay with the project.

thanks again.
palian3 is offline   Reply With Quote
Old 06-25-2010, 03:07 AM   #17 (permalink)
Registered Member
 
Join Date: Apr 2009
Posts: 8
Default

oh nevermind

Last edited by iferret; 06-25-2010 at 03:11 AM. Reason: there's no delete button.
iferret is offline   Reply With Quote
Old 09-04-2010, 07:26 AM   #18 (permalink)
Registered Member
 
Join Date: Aug 2009
Posts: 1
Default

Thank you so much for you tutorial on PDF Creation.

It has helped me immensely.

I have one problem that I just can't get me head round, and I hope you can help. I trust you a busy man so hopefully its not too difficult. I have tried everything but without luck.

I would like to replace a line of code from void CreatePDFFile (CGRect pageRect, const char *filename) which draws text, but only programmed text.

const char *text ="To";
CGContextShowTextAtPoint (pdfContext, 57, 735, text, strlen(text));

To this:

name= [NSString stringWithFormat:@"%@", invoiceContractor.text];
const char *text = [name UTF8String];
CGContextShowTextAtPoint (pdfContext, 245, 810, text, strlen(text));

The later would display text from a user inputted textfield. The problem is that I get a 'invoiceContractor' undeclared warning at build time.

The 'invoiceContractor' textfield has been declared in the .h file and synthesized in the .m file and works in other delegate methods in the .m file just fine.

I would appreciate any help with this that you may have.

Thanking you in advance,

Ants
cableguy69 is offline   Reply With Quote
Old 04-15-2011, 03:57 AM   #19 (permalink)
Registered Member
 
Join Date: Jan 2011
Location: pune
Age: 26
Posts: 7
Default

i also have the same problem if u solve pls tell me


Quote:
Originally Posted by cableguy69 View Post
Thank you so much for you tutorial on PDF Creation.


It has helped me immensely.

I have one problem that I just can't get me head round, and I hope you can help. I trust you a busy man so hopefully its not too difficult. I have tried everything but without luck.

I would like to replace a line of code from void CreatePDFFile (CGRect pageRect, const char *filename) which draws text, but only programmed text.

const char *text ="To";
CGContextShowTextAtPoint (pdfContext, 57, 735, text, strlen(text));

To this:

name= [NSString stringWithFormat:@"%@", invoiceContractor.text];
const char *text = [name UTF8String];
CGContextShowTextAtPoint (pdfContext, 245, 810, text, strlen(text));

The later would display text from a user inputted textfield. The problem is that I get a 'invoiceContractor' undeclared warning at build time.

The 'invoiceContractor' textfield has been declared in the .h file and synthesized in the .m file and works in other delegate methods in the .m file just fine.

I would appreciate any help with this that you may have.

Thanking you in advance,

Ants
sadaf is offline   Reply With Quote
Reply

Bookmarks

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
» Stats
Members: 158,885
Threads: 89,230
Posts: 380,765
Top Poster: BrianSlick (7,129)
Welcome to our newest member, bookesp
Powered by vBadvanced CMPS v3.1.0

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