आप पीडीएफ पेज में पढ़कर एनोटेशन कर सकते हैं, इसे एक नए पीडीएफ ग्राफिक्स संदर्भ पर खींच कर, फिर उस ग्राफिक संदर्भ पर अतिरिक्त सामग्री ड्राइंग कर सकते हैं। यहां कुछ कोड है जो मौजूदा उदाहरण में स्थिति (100.0,100.0) पर 'उदाहरण एनोटेशन' शब्द जोड़ता है। विधि प्राप्त करें PDFFileName मूल पीडी का पथ देता है। getTempPDFFileName नए पीडीएफ का मार्ग लौटाता है, जो मूल प्लस एनोटेशन है।
एनोटेशन को बदलने के लिए, DrawInRect: withFont: method के स्थान पर बस अधिक ड्राइंग कोड जोड़ें। आईओएस के लिए ड्रॉइंग और प्रिंटिंग गाइड देखें कि इसे कैसे करें।
- (void) exampleAnnotation;
{
NSURL* url = [NSURL fileURLWithPath:[self getPDFFileName]];
CGPDFDocumentRef document = CGPDFDocumentCreateWithURL ((CFURLRef) url);// 2
size_t count = CGPDFDocumentGetNumberOfPages (document);// 3
if (count == 0)
{
NSLog(@"PDF needs at least one page");
return;
}
CGRect paperSize = CGRectMake(0.0,0.0,595.28,841.89);
UIGraphicsBeginPDFContextToFile([self getTempPDFFileName], paperSize, nil);
UIGraphicsBeginPDFPageWithInfo(paperSize, nil);
CGContextRef currentContext = UIGraphicsGetCurrentContext();
// flip context so page is right way up
CGContextTranslateCTM(currentContext, 0, paperSize.size.height);
CGContextScaleCTM(currentContext, 1.0, -1.0);
CGPDFPageRef page = CGPDFDocumentGetPage (document, 1); // grab page 1 of the PDF
CGContextDrawPDFPage (currentContext, page); // draw page 1 into graphics context
// flip context so annotations are right way up
CGContextScaleCTM(currentContext, 1.0, -1.0);
CGContextTranslateCTM(currentContext, 0, -paperSize.size.height);
[@"Example annotation" drawInRect:CGRectMake(100.0, 100.0, 200.0, 40.0) withFont:[UIFont systemFontOfSize:18.0]];
UIGraphicsEndPDFContext();
CGPDFDocumentRelease (document);
}
हाय जैक, क्या आपने एनोटेशन किया है? 1. Cygwin + जीसीसी (माइक्रोसॉफ्ट विंडोज) 2. Cygwin + MinGW (माइक्रोसॉफ्ट विंडोज) 3. MSYS + MinGW (माइक्रोसॉफ्ट विंडोज) 3. माइक्रोसॉफ्ट कुलपति ++ (: –