iPhone 응용 프로그램에서 UITextView를 사용하여 사용자의 일부 콘텐츠를 얻은 다음 해당 UITextView에서 PDF 파일을 변환하고 로컬 디렉토리에 저장하려고했지만이 사실을 알지 못했습니다.UITextView를 iPhone의 Pdf 파일로 변환 하시겠습니까?
0
A
답변
0
3
여기에 코드를입니다
- (void) generatePdfWithFilePath: (NSString *)thefilePath
{
UIGraphicsBeginPDFContextToFile(thefilePath, CGRectZero, nil);
NSInteger currentPage = 0;
BOOL done = NO;
do
{
// Mark the beginning of a new page.
UIGraphicsBeginPDFPageWithInfo(CGRectMake(0, 0, pageSize.width, pageSize.height), nil);
// Draw a page number at the bottom of each page.
currentPage++;
[self drawPageNumber:currentPage];
//Draw a border for each page.
[self drawBorder];
//Draw text fo our header.
[self drawHeader];
//Draw a line below the header.
[self drawLine];
//Draw some text for the page.
[self drawText];
//Draw an image
[self drawImage];
done = YES;
}
while (!done);
// Close the PDF context and write the contents out.
UIGraphicsEndPDFContext();
}
- (void) drawText
{
CGContextRef currentContext = UIGraphicsGetCurrentContext();
CGContextSetRGBFillColor(currentContext, 0.0, 0.0, 0.0, 1.0);
NSString *textToDraw = yourtextview.text // use your textfield or textview here
UIFont *font = [UIFont systemFontOfSize:14.0];
CGSize stringSize = [textToDraw sizeWithFont:font
constrainedToSize:CGSizeMake(pageSize.width - 2*kBorderInset- 2*kMarginInset, pageSize.height - 2*kBorderInset - 2*kMarginInset)
lineBreakMode:UILineBreakModeWordWrap];
CGRect renderingRect = CGRectMake(kBorderInset + kMarginInset, kBorderInset + kMarginInset + 50.0, pageSize.width - 2*kBorderInset - 2*kMarginInset, stringSize.height);
[textToDraw drawInRect:renderingRect
withFont:font
lineBreakMode:UILineBreakModeWordWrap
alignment:UITextAlignmentLeft];
}
+0
답장을 보내 주셔서 감사합니다. – SampathKumar
+0
안녕하세요, 받아 들일 수 내 대답은 당신을 위해 유용합니다 :) – abhishekkharwar
관련 문제
- 1. HTML 파일을 Iphone의 PDF 파일로 변환
- 2. .txt 파일을 즉시 .pdf 파일로 변환 하시겠습니까?
- 3. UIImage를 PDF 파일로 변환
- 4. 투명 PDF 파일로 변환
- 5. 여러 PDF 파일을 하나의 PDF 파일로 변환
- 6. 그리드 뷰에서 PDF 파일로 변환
- 7. .jrxml 파일을 .pdf 파일로 변환
- 8. jpeg 그림을 pdf 파일로 변환
- 9. .mm 파일을 iphone의 .m 파일로 변환
- 10. pdf 파일을 단일 이미지 파일로 변환 하시겠습니까? (페이지 상단에 페이지)
- 11. plist를 CSV 파일로 변환 하시겠습니까?
- 12. 문자열을 xml 파일로 변환 하시겠습니까?
- 13. system.drawing.drawing2d.graphics를 .avi 파일로 변환 하시겠습니까?
- 14. Summary.glm을 CSV 파일로 변환 하시겠습니까?
- 15. PDF 파일을 단일 HTML 파일로 변환
- 16. PHP 파일에서 HTML을 PDF 파일로 변환
- 17. Aspose.Pdf 파일로 Excel (.xml) 파일 변환 PDF
- 18. iphone에서 .doc 형식을 Pdf 파일로 변환
- 19. java를 사용하여 .mht 파일을 PDF 파일로 변환
- 20. PHP 변수로 HTML을 PDF 파일로 작성 하시겠습니까?
- 21. iPhone의 PDF 하이퍼 링크
- 22. Unix : PDF 파일과 이미지를 PDF 파일로 결합 하시겠습니까?
- 23. 애플의 mailComposer UITextView를 복제 하시겠습니까?
- 24. pdf를 doc 파일로 변환
- 25. AutocadDWG를 PDF 파일로 변환하는 방법?
- 26. rtf 파일을 chm 파일로 변환 하시겠습니까? hlp 파일을 chm 파일로 변환 하시겠습니까?
- 27. 원시 이진 데이터를 이미지 파일로 변환 하시겠습니까?
- 28. html FileReader : blob을 이미지 파일로 변환 하시겠습니까?
- 29. CAF 파일을 Java의 WAV 파일로 변환 하시겠습니까?
- 30. .jar을 OSX 실행 파일로 변환 하시겠습니까?
귀하의 샘플 코드도 훨씬 적은 당신이 원하는 무슨 말, 컴파일되지 않습니다. –
답장을 보내 주셔서 감사합니다 – SampathKumar
텍스트 파일을 PDF 파일로 변환하는 방법. – SampathKumar