PDF生成动态数据

问题描述:

在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; 
          } 
} 
} 

您需要设置字体和颜色...

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

非常感谢您Lee.I将检查:) – boopathi

+0

哇这是工作:) – boopathi

+0

很高兴能帮助,如果你是幸福的答案也许你可以接受。非常感谢。 –