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

Reply
 
LinkBack Thread Tools Display Modes
Old 02-18-2010, 08:53 AM   #51 (permalink)
Registered Member
 
Join Date: Jan 2009
Posts: 4
Default

Quote:
Originally Posted by danielb21 View Post
Spent more time today exploring the [NSString drawInRect:] method to see if I could get it to work, and I now have a working solution. The key is that you have to push the graphics context onto the stack. Below is how it works:

Code:
NSString *string = @"Text to print.";

UIGraphicsPushContext(context);
CGContextTranslateCTM(context, 0, 20);
CGContextScaleCTM(context, 1.0, -1.0);
[string drawInRect:CGRectMake(0, 0, 300, 200) withFont:[UIFont fontWithName:@"Verdana" size:9]];
UIGraphicsPopContext();
So, the above code block pushes the context onto the stack, reverses the coordinates so that the text is drawn correctly, and then uses the drawInRect: withFont: method to draw the text, and finally calls the UIGraphicsPopContext() method.

It's important to note that each time you call UIGraphicsPushContext(context); you must also call the pop context method, otherwise you'll be left with nothing.

Thanks to decay for pushing me to investigate this more and enjoy everyone!
First of all thanks for the tutorial and the code above.
Can anyone tell me how to position a rotated text correctly?
I try this, but it's not correct:
Code:
UIGraphicsPushContext(pdfContext);
	
	CGContextTranslateCTM(pdfContext,txtPos.origin.x, newY);
	CGContextScaleCTM(pdfContext, 1.0, -1.0);
	
	CGAffineTransform textTransform = CGAffineTransformMakeRotation(/*M_PI*2 - */currentAngle);
	CGContextConcatCTM(pdfContext, textTransform);
	
	
	NSString *string =[NSString stringWithCString:text];
	[string drawInRect:CGRectMake(0, 0, txtPos.size.width, txtPos.size.height) withFont:[UIFont fontWithName:@"Helvetica" size:48]];
	
	UIGraphicsPopContext();
Thanks in advance,

Omid
Omid is offline   Reply With Quote
Old 02-18-2010, 05:12 PM   #52 (permalink)
Registered Member
 
Join Date: Jan 2010
Posts: 8
Default

HI @ all

@1 great tutorial

@2 i need some help

i try to draw the content from scrollview to pdf but they draw only the visible content (that that i can see on the screen)not all the content on the scrollview




CGContextTranslateCTM(pdfContext,40,pageRect.size. height);
CGContextScaleCTM(pdfContext,1.0, -1.0);
[scrollView.layer renderInContextdfContext];



thx for help
elgreconiko is offline   Reply With Quote
Old 02-22-2010, 06:52 AM   #53 (permalink)
Registered Member
 
Join Date: May 2009
Posts: 14
Question Download pdf throgh web view how to do?

I can show the pdf file in web view from remote server...but i have to set an action to download the pdf to mobile...In PHP,i tried with force download which is working fine in desktop but not in iPhone...Instead it opens the pdf in webview....
Can anyone plz help me...?
dineshkumarm12 is offline   Reply With Quote
Old 04-28-2010, 11:25 AM   #54 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 7
Default

HEY Friends,

i want to know how to display pdf using Quartz.

i want source code. i messed up with this from a week.

help guys..
banda ban ja is offline   Reply With Quote
Old 05-16-2010, 11:04 PM   #55 (permalink)
Registered Member
 
Join Date: Jul 2009
Posts: 6
Default can't get CIDs for glyphs

Anyone else getting these errors when writing the text to the PDF?

Code:
: CGFont/Freetype: The function `get_subset_format' is currently unimplemented.
: can't get CIDs for glyphs for `Helvetica'.
I've found a thread on some other boards about this, and it sounds somewhat hopeless. The PDFs do view fine in most places, but for example the Google Docs viewer does not display the text. That, and you get a ton of errors in the console if you are writing a lot of text.

And to the couple of people having the EXC_BAD_ACCESS message, you need to add a Picture.png to your resources when you build this example.

jeffro
jeffro37 is offline   Reply With Quote
Old 05-16-2010, 11:08 PM   #56 (permalink)
Registered Member
 
Join Date: Feb 2009
Location: Seattle
Posts: 48
Default

You are quite correct -- Apple's iPhone SDK for creating PDFs is hopeless.

However the open source libharu C library for PDF generation works on iPhone. See the end of this thread...
http://www.iphonedevsdk.com/forum/ip...ds-glyphs.html

Quote:
Originally Posted by jeffro37 View Post
I've found a thread on some other boards about this, and it sounds somewhat hopeless.
pmattf is offline   Reply With Quote
Old 05-25-2010, 11:10 PM   #57 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 1
Default

Quote:
Originally Posted by elgreconiko View Post
HI @ all

@1 great tutorial

@2 i need some help

i try to draw the content from scrollview to pdf but they draw only the visible content (that that i can see on the screen)not all the content on the scrollview




CGContextTranslateCTM(pdfContext,40,pageRect.size. height);
CGContextScaleCTM(pdfContext,1.0, -1.0);
[scrollView.layer renderInContextdfContext];



thx for help
You are capturing the visible content only because your scroll view is sized match the visible content only, which it should be. You need to resize your scrollview to match the content you need to capture before you start the drawing code using something like this:

Code:
self.scrollView.frame = CGRectMake(0, 0, "your content width here", "your content height here");
After you are done drawing make sure to resize your scroll view to back, in this case to the container view:

Code:
self.scrollView.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
t worked on my iPad app. I hope it works for you.
AlmostiPhoneDev is offline   Reply With Quote
Old 05-26-2010, 04:09 AM   #58 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 1
Unhappy How will i send email in pdf format with contents taking from database?

Hi i just registered in the blog to download the helpful PDF creation codes from danielb21. Thanks dan for the helpful job. Can anyone help me in another part.
How will i send email in pdf format with contents taking from database?
topofstack is offline   Reply With Quote
Old 06-23-2010, 08:19 AM   #59 (permalink)
Registered Member
 
Join Date: Jul 2009
Posts: 2
Default Code for pdf viewer

Hello Everyone.

I am new to iphone development please can u mail me the code so i can go through it. i have tried a lot to do it alone.

Thanks,
Sweety
sweetynebhwani is offline   Reply With Quote
Old 07-12-2010, 07:56 PM   #60 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 77
Default

Hi

I need some help.

I'm trying to implement this code in my app but CreatePDFFile crashes when code riches this line: provider = CGDataProviderCreateWithURL (pictureURL) EXC_BAD_ACCESS...

I don't know whats happening.

Where the code search for the png image than wants to include to the pdf flie?
The const char *picture was the name of the file to be included in the pdf?

I hope you can help me.

Thanks
Balillas is offline   Reply With Quote
Old 07-12-2010, 08:08 PM   #61 (permalink)
Registered Member
 
Join Date: Feb 2009
Location: Seattle
Posts: 48
Default

EXC_BAD_ACCESS most often means you are trying to access memory which has already been released. Unfortunately the mistake in your code may not be anywhere near where the crash is actually occuring.

Try searching this forum and/or stackoverflow.com for EXC_BAD_ACCESS, you should find plenty of info on how to approach debugging this.

Quote:
Originally Posted by Balillas View Post
Hi

I need some help.

I'm trying to implement this code in my app but CreatePDFFile crashes when code riches this line: provider = CGDataProviderCreateWithURL (pictureURL) EXC_BAD_ACCESS...

I don't know whats happening.

Where the code search for the png image than wants to include to the pdf flie?
The const char *picture was the name of the file to be included in the pdf?

I hope you can help me.

Thanks
pmattf is offline   Reply With Quote
Old 07-13-2010, 04:35 AM   #62 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 77
Default

Quote:
Originally Posted by pmattf View Post
EXC_BAD_ACCESS most often means you are trying to access memory which has already been released. Unfortunately the mistake in your code may not be anywhere near where the crash is actually occuring.

Try searching this forum and/or stackoverflow.com for EXC_BAD_ACCESS, you should find plenty of info on how to approach debugging this.
I'm sure that the problem it's the initializing of one or two vars in the code, probably related to name or path where the image.png was stored.

What about my last two questions? What can you tell me about?

Thanks
Balillas is offline   Reply With Quote
Old 07-13-2010, 05:01 AM   #63 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 77
Default

OK!!! Solved... the problem was that the const char *picture is the file name of a Picture.png that first you must include in the resources folder of the project.

How can I get a picture.png that It's stored to my Documents Directory? There is a function like CFBundleCopyResourceURL that allows to do this?

Thanks
Balillas is offline   Reply With Quote
Old 07-13-2010, 12:11 PM   #64 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 77
Default

Quote:
Originally Posted by Balillas View Post
OK!!! Solved... the problem was that the const char *picture is the file name of a Picture.png that first you must include in the resources folder of the project.

How can I get a picture.png that It's stored to my Documents Directory? There is a function like CFBundleCopyResourceURL that allows to do this?

Thanks
Finally I use the UIImage that I have in a UIImageView instead of a image stored in my documents directory.

I use this code:

Code:
        // This code block will create an image that we then draw to the page
	CGImageRef *image=[imageSelected CGImage];	
        CGContextDrawImage (pdfContext, CGRectMake(200, 200, 207, 385),image);
        CGImageRelease (image);
	// End image code
The var imageSelected comes from the UIImageView.image;

Thanks again

Last edited by Balillas; 07-13-2010 at 12:13 PM.
Balillas is offline   Reply With Quote
Old 07-29-2010, 11:02 AM   #65 (permalink)
Registered Member
 
Join Date: Jun 2010
Posts: 4
Default New Line Problem

I am unable to insert new line in my pdf :-s
it doesn't recognize the character \n,
asifali is offline   Reply With Quote
Old 08-03-2010, 08:42 AM   #66 (permalink)
Registered Member
 
ganeshiiphone's Avatar
 
Join Date: Jul 2010
Posts: 2
Default pdf creating file

Quote:
Originally Posted by danielb21 View Post
Good afternoon everyone!

I have written an intro to PDF tutorial for those that are interested in PDF interactivity within your iPhone apps. This first tutorial, shows how to simply create a PDF that contains an image, some text and a border around the page.

Ok, on to the goods! There are two custom methods in the PDFViewController.m file that you will be looking at mostly. The first is CreatePDFFile. This method does exactly what it says - creates a PDF file. The second method is called createPDF, and is an IBAction method hooked to an UIButton in IB. Upon touching the button this method calls our CreatePDFFile method.

Important - there is no output after clicking the button, meaning you will not see the resulting PDF displayed on the phone. I can create a second tutorial for that purpose, but it seemed like most people were only interested in the creation of the file.

In order to view the resulting PDF go to:
Users/YourUserName/Library/Application Support/iPhone Simulator/User/Applications

In this directory sort by Date Modified. If the example project here was the last app that you ran it will be at the top of this directory. Simply navigate to the documents directory of the PDF example app and you will be able to see the PDF it creates.

Let me know if you have any questions!

P.S. So it seems that the example project was larger than the allowed size for attachments. I will get the whole project up on the web for download soon, but in the meantime I have included the class files which is all you should need.


Hi can u pls send me the code for this task.

Just send this to : visu4u_149@yahoo.com

Thanks in advance.
ganeshiiphone is offline   Reply With Quote
Old 08-23-2010, 02:53 AM   #67 (permalink)
Registered Member
 
Join Date: Aug 2010
Posts: 6
Default How to access the url's int pdf?

HI, Im able to load the pdf or read a pdf but im not able to access the url links in the pdf....could u hel;p me?
vijayajay17 is offline   Reply With Quote
Old 08-23-2010, 04:49 AM   #68 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 1
Default make table in pdf

Hi,
does anyone know how to implement a multicolumn table in pdf , with an header and many lines, taking the values from a database.


thanks in advance for any tips,

andrea
Andrea is offline   Reply With Quote
Old 09-25-2010, 11:56 PM   #69 (permalink)
Registered Member
 
Join Date: Jun 2010
Posts: 8
Default Reading a pdf

Quote:
Originally Posted by danielb21 View Post
Hey Chase,

There is another tutorial that I wrote that shows exactly how to do this. You'll find it a little further down in the tutorials section.

Thanks,
Dan
Hey Dan,

Thank you for the tutorial of creating a pdf can you please send a link for the tutorial of reading a pdf too.

Thanks,
Ankur
akki2010 is offline   Reply With Quote
Old 10-05-2010, 08:24 AM   #70 (permalink)
Big - M
 
Join Date: Oct 2010
Posts: 1
Lightbulb Thanks alot...

Quote:
Originally Posted by danielb21 View Post
Hi decay,

Have you actually done what you are suggesting successfully or just basing your response on documentation provided by Apple? If you have, it would be greatly appreciated if you post your solution with a working example here and I will add it as a part of the tutorial with appropriate credit to you.

My experience with [NSString drawInRect:] in a PDFContext has been that it will not draw, citing an "invalid context". Had that not been the case I would have been using that all along.

Thanks,
Dan

*EDIT* Figured out how to use this, refer to post #25.
Hi danielb21,

Thanks for the wonderful tutorial...It helped me alot..
meetpriyagupta is offline   Reply With Quote
Old 10-15-2010, 04:35 PM   #71 (permalink)
Registered Member
 
Join Date: Aug 2008
Posts: 175
Default

Quote:
Originally Posted by prameshu View Post
Thanks for the great tutorial. It helps me a lot. Finally I need to display the € currency symbol. In stead of Euro symbol, the pDF file shows some other unrecognized characters. Could you help me in this regard......

thanks,
Ramesh.
Did you ever figure this out? I cannot get euro to work either. Any ideas?
RockStrongo is offline   Reply With Quote
Old 10-15-2010, 06:16 PM   #72 (permalink)
Anil Kumar
 
Join Date: Oct 2010
Location: India
Posts: 4
Default Extract Text from PDF

For beginners the thread is very good, but do anybody have experience in extracting text from PDF to build index for a large content app.
anilkumar2010 is offline   Reply With Quote
Old 10-17-2010, 12:42 AM   #73 (permalink)
Registered Member
 
Join Date: Oct 2010
Location: Minneapolis, Minnesota
Age: 33
Posts: 1
Default

Need help, am stuck with a table format,I need several columns but a header and a sub header..please help how to work out this in pdf
clerraford is offline   Reply With Quote
Old 10-25-2010, 03:02 AM   #74 (permalink)
sm
 
Join Date: Aug 2010
Posts: 30
Smile hi daniel

your PDF tutorial is too good thanks for that
smithadharan is offline   Reply With Quote
Old 10-25-2010, 03:05 AM   #75 (permalink)
sm
 
Join Date: Aug 2010
Posts: 30
Default hi daniel

Your PDF creation tutorial is too good
smithadharan 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 On
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 351
19 members and 332 guests
ADY, Alsahir, Dani77, e2applets, JasonR, keeshux, mer10, Monstertaco, piesia, prchn4christ, Promo Dispenser, Robiwan, sebasx, sly24, Touchmint, twerner, zulfishah
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,880
Threads: 89,228
Posts: 380,759
Top Poster: BrianSlick (7,129)
Welcome to our newest member, @sandris
Powered by vBadvanced CMPS v3.1.0

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