Create pdf inapp iOS [duplicate] - ios

How to generate a PDF file on a user action?

See "Drawing with Quartz" to see how to create a PDF Graphics Context.
Some notes:
"iPhoneOSNote: If you want to create a PDF graphics context in an iPhone application, make sure you also read “Drawing to a Graphics Context in iPhone OS” (page 27)."
"You can write any content to a PDF that’s appropriate for your application—images, text, path drawing—and you can add links and encryption. For more information see “PDF Document Creation, Viewing, and Transforming” (page 177)."

As an example of creating a PDF from the contents of a CALayer, you can refer to the -dataForPDFRepresentationOfLayer method within the CPLayer class in the Core Plot framework. You can do something similar to extract the content from a CALayer-backed UIView, although we had to subclass CALayer in order to get vector elements to render to a PDF properly.

Use this library to generate pdf file by programmatically.
SJ_PDFCreator

Use a web service on a server back end to post the data to - then generate the PDF and return it to the browser/app with the correct mime type to open as a PDF.
ColdFusion could easily do this for you in just a few lines of code.

Related

IOS PDF Reader with search , annotation and bookmarks

I'm trying to do a PDF Reader which have the following features:
bookmarks
zooming
highlight //annotation or just changing the background of the rect
search
what I'm using is vfr/Reader :
https://github.com/vfr/Reader
it have the zooming function and bookmarks
and I want to make it like LazyPDf : https://github.com/lazyprogram/LazyPDFKit
which have annotation function
or make it like github.com/Ink/ThatPDF
which have less annotation functions than lazypdf
and add the search from
github.com/KurtCode/PDFKitten
the problem is that i have been working on it for like a month and I didn't make any progress and I don't know where to start or how to merge those applications together , even though all of them uses CGPDF.
please help me to find a way to make my app or let me know if there is a better free library ,and if i need to learn anything just drop a link in a comment.
Thank you !!
You can use below link for pdf reader.
you can easly use the book mark,zooming,saved pdf,email,print pdf
https://github.com/vfr/Reader
You can use iOS PDFKit:
This reponse will help you

PrawnPDF Flip Entire PDF

I'm using Prawn PDF to create a label that I send to a label printer, but the label prints upside down. This is important as the shipping labels we use come with some print already on it. The setup I'm using (an iPad through a Lantronix xPrintServer to a Zebra Printer) won't allow me to flip it using the drivers.
So I'm wanting to know if there is a way using Prawn (or even just Rails) to flip the entire document (which contains 2+ pages) so it prints out correctly on the labels. The order of the pages isn't essential.
I haven't used Prawn lately, but I'm pretty sure using the rotate method at the top of your code will work. You'll just need to either set the origin to the center of the page, or use translate to reposition the content after rotation. Page 29 in the manual (PDF) has some example code.
You could save the pdf to a file and then use the awesome pdftk to rotate the saved pdf, then send the amended version.
https://www.pdflabs.com/docs/pdftk-cli-examples/
EDIT - pdftk is not a library/plugin/gem, or any kind of Ruby for that matter. It's a command line tool which you would use like this, in your controller, replacing your current "generate and send pdf" code.
#instead of sending the pdf straight to the user, save it to a file
#i'm not sure how to do this in prawn but it can't be difficult
#rotate the original to a new file
`pdftk /path/to/original.pdf cat 1-endsouth output /path/to/rotated.pdf`
#you could test whether the rotated file exists here as an error-check
#then use send_file to send the rotated one as the response.
send_file "/path/to/rotated.pdf", :type => "application/pdf"

ios creating multiple-page pdfs

How would I go about creating a multiple page pdf from a scrolling view? I am trying to convert an invoice pdf and it is much longer than 1 page; not sure how to create more.
also while on this, the pdf also seems to be quite choppy in quality ( very rasterized ) - any tips to improve this? i realize it's not vectorized, hence the choppy look, just looking for a way to make it better? thanks
To create multiple pdf, after creating each page you can convert the entire page to an image an store it in an array, one by one. Then you can show each image from the array as scrollview if thats what you meant.
You can create pdf pages and write it to a file with following function. Call it for each page.
-(void)savePDFImageToDocumentDirectory:(UIImage *)pdfImage withPageNumber:(int )pageNumber{
NSString *tmpPngPath = PDFTempDirectoryPath;
NSString *pageName = [NSString stringWithFormat:#"PDFPage%d.png",pageNumber];
NSString *imagePath = [tmpPngPath stringByAppendingPathComponent:pageName];
[UIImagePNGRepresentation(pdfImage) writeToFile:imagePath atomically:YES];
}
You can follow two approaches tom create pdf. One through html method and the other is from xib files. Html method is fast but pdf will be of less quality. xib method gives you high quality pdf but uses a lot of memory.
If you are happy for the PDF generation to be remote you could use a service like Docmosis cloud services or Aspose to create the Document and stream it back to the device (or email it or both etc).
Typically these PDF tools wouldn't build documents from images like screen shots - you would send the data you want populated instead. This means the quality is very good (and text is selectable etc) and multiple pages is expected making the PDFs more generally useful.
Please note I work for the company that created Docmosis.
Hope that helps.

open source controls to convert rich text formatted code to html markup

I am working on asp.net mvc. I am trying to display the rich text formatted content like,
{\rtf1\ansi\ansicpg1252\uc1\htmautsp\deff2{\fonttbl{\f0\
fcharset0 Times New Roman;}{\f2\fcharset0 Tahoma;}}{\colortbl\red0\green0\blue0;\red255\green255\blue255;}\loch\hi
ch\dbch\pard\plain\ltrpar\itap0{\lang1033\fs24\f2\cf0 \cf
0\ql{\f2 {\ltrch AMANDA WITH RC CALLED AND WANTED TO
VERIFY THAT WE WERE AFFILIATED WITH SHAUN # JAGGYS. LET HER KNOW WE
WERE, SHAUN CALLED RC AS WELL TO VERIFY STATUS OF BD}\li0\ri0\sa0\sb0\fi0\ql\par}
}
}
in the view. Actually this data could come from database table and i need to display it in the editor type control. so is there any open source controls that are able to display rich text format.
Well, I just got done writing a RTF to HTML converter that maintains all embedded media, and creates a MIME multipart message out of it. This is close to what you want to do. Essentially if you aren't interested in writing your own converter, you can look at this CodeProject and use his: http://www.codeproject.com/Articles/27431/Writing-Your-Own-RTF-Converter
There is also descriptions as to how to reach his solution.
On my project we just started ripping apart the RTF document and parsing its contents. Open source and 3rd-Party Libraries weren't an option for me.

How can I create a PDF file programmatically in an iOS application?

How to generate a PDF file on a user action?
See "Drawing with Quartz" to see how to create a PDF Graphics Context.
Some notes:
"iPhoneOSNote: If you want to create a PDF graphics context in an iPhone application, make sure you also read “Drawing to a Graphics Context in iPhone OS” (page 27)."
"You can write any content to a PDF that’s appropriate for your application—images, text, path drawing—and you can add links and encryption. For more information see “PDF Document Creation, Viewing, and Transforming” (page 177)."
As an example of creating a PDF from the contents of a CALayer, you can refer to the -dataForPDFRepresentationOfLayer method within the CPLayer class in the Core Plot framework. You can do something similar to extract the content from a CALayer-backed UIView, although we had to subclass CALayer in order to get vector elements to render to a PDF properly.
Use this library to generate pdf file by programmatically.
SJ_PDFCreator
Use a web service on a server back end to post the data to - then generate the PDF and return it to the browser/app with the correct mime type to open as a PDF.
ColdFusion could easily do this for you in just a few lines of code.

Resources