在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:iclems/iOS-htmltopdf开源软件地址:https://github.com/iclems/iOS-htmltopdf开源编程语言:Objective-C 95.6%开源软件介绍:iOS-htmltopdfThis class enables simple URL-based PDF creation. Pages are created the exact same way they would be if the user printed the content on an iOS device (very similar as well as OS X print output). Example code: self.PDFCreator = [NDHTMLtoPDF createPDFWithURL:
[NSURL URLWithString:@"http://url.com"]
pathForPDF:[@"~/Documents/demo.pdf" stringByExpandingTildeInPath]
delegate:self
pageSize:kPaperSizeA4
margins:UIEdgeInsetsMake(10, 5, 10, 5)]; or using block syntax self.PDFCreator = [NDHTMLtoPDF createPDFWithURL:[NSURL URLWithString:@"http:/url.com"]
pathForPDF:[@"~/Documents/blocksDemo.pdf" stringByExpandingTildeInPath]
pageSize:kPaperSizeA4 margins:UIEdgeInsetsMake(10, 5, 10, 5)
successBlock:^(NDHTMLtoPDF *htmlToPDF) {
NSLog(@"HTMLtoPDF did succeed (%@ / %@)", htmlToPDF, htmlToPDF.PDFpath);
} errorBlock:^(NDHTMLtoPDF *htmlToPDF) {
NSLog(@"HTMLtoPDF did fail (%@)", htmlToPDF);
}]; You can also use the alternative following code to generate PDF directly from HTML string, without using an URL. This is useful if you want your PDF generator to work offline or if you don't want to write first your code into a local file (you can then use + (id)createPDFWithHTML:(NSString*)HTML pathForPDF:(NSString*)PDFpath delegate:(id <NDHTMLtoPDFDelegate>)delegate pageSize:(CGSize)pageSize margins:(UIEdgeInsets)pageMargins;
+ (id)createPDFWithHTML:(NSString*)HTML baseURL:(NSURL*)baseURL pathForPDF:(NSString*)PDFpath delegate:(id <NDHTMLtoPDFDelegate>)delegate pageSize:(CGSize)pageSize margins:(UIEdgeInsets)pageMargins;
+ (id)createPDFWithHTML:(NSString*)HTML pathForPDF:(NSString*)PDFpath pageSize:(CGSize)pageSize margins:(UIEdgeInsets)pageMargins successBlock:(NDHTMLtoPDFCompletionBlock)successBlock errorBlock:(NDHTMLtoPDFCompletionBlock)errorBlock;
+ (id)createPDFWithHTML:(NSString*)HTML baseURL:(NSURL*)baseURL pathForPDF:(NSString*)PDFpath pageSize:(CGSize)pageSize margins:(UIEdgeInsets)pageMargins successBlock:(NDHTMLtoPDFCompletionBlock)successBlock errorBlock:(NDHTMLtoPDFCompletionBlock)errorBlock; A paper size is only defined by a rect (e.g. Please, be sure to create a property (e.g. Feel free to contact me if you have any question ! |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论