2011-10-31 94 views
0

在PDF的generatin,創建一個新的頁面,但數據不被寫入到PDF,這是我使用的代碼,請幫我解決這個問題:PDF生成動態數據

   x=50; 
       y=y-20; 
       BOOL isNewPageReq=FALSE; 
       for(int trLisCnt=2;trLisCnt<=4;trLisCnt++){ 
        NSMutableArray *tranListingContArray=[eachSkuAry objectAtIndex:trLisCnt]; 
        for(int dicCnt=0;dicCnt<[tranListingContArray count];dicCnt++){ 
         NSMutableArray *actContents=[tranListingContArray objectAtIndex:dicCnt]; 
         y=y-10; 
         if(y<=40){ //here i am checking the y position 
          y=700;//here i am setting y position for the new page 
          CGContextEndPage(pdfContext);//here i am ending the current page 
          CGContextBeginPage(pdfContext, &pageRect);/*here i am starting a new page,i am ending this              page at end not shown in this*/ 
         } 
         x=50; 
         for(int j=0;j<7;j++){ 
          if((j==0)&&(trLisCnt==2)){ 
           const char *str=[@"SO" UTF8String]; 
           CGContextShowTextAtPoint(pdfContext,x,y,str,strlen(str)); 
           x=x+50; 
          } 
          else if((j==1)&&(trLisCnt==2)){ 
           const char *cont=[[actContents objectAtIndex:3]UTF8String]; 
           CGContextShowTextAtPoint(pdfContext,x,y,cont,strlen(cont)); 
           x=x+50; 

          } 
          else if((j==2)&&(trLisCnt==2)){ 
           const char *cont=[[actContents objectAtIndex:1]UTF8String]; 
           CGContextShowTextAtPoint(pdfContext,x,y,cont,strlen(cont)); 
           x=x+50; 
          } 
          else if((j==3)&&(trLisCnt==2)){ 
           const char *cont=[@"NULL" UTF8String]; 
           CGContextShowTextAtPoint(pdfContext,x,y,cont,strlen(cont)); 
           x=x+110; 
          } 
          else if((j==4)&&(trLisCnt==2)){ 
           const char *cont=[@"NULL" UTF8String]; 
           CGContextShowTextAtPoint(pdfContext,x,y,cont,strlen(cont)); 
           x=x+110; 
          } 
          else if((j==5)&&(trLisCnt==2)){ 
           const char *cont=[@"NULL" UTF8String]; 
           CGContextShowTextAtPoint(pdfContext,x,y,cont,strlen(cont)); 
           x=x+110; 
          } 
          else if((j==6)&&(trLisCnt==2)){ 
           const char *cont=[[actContents objectAtIndex:2]UTF8String]; 
           CGContextShowTextAtPoint(pdfContext,x,y,cont,strlen(cont)); 
           x=x+50; 
          } 
} 
} 

回答

1

您需要設置字體和顏色...

CGContextSelectFont (pdfContext, "Helvetica", 14, kCGEncodingMacRoman); 
CGContextSetTextDrawingMode (pdfContext, kCGTextFill); 
CGContextSetRGBFillColor (pdfContext, 0, 0, 0, 1); 
+0

非常感謝您Lee.I將檢查:) – boopathi

+0

哇這是工作:) – boopathi

+0

很高興能幫助,如果你是幸福的答案也許你可以接受。非常感謝。 –