2012-03-27 67 views
0

我想提出一个PDF的应用程序中,我得到的问题初学者在iphone,制作PDF,我在做什么错

// make pdf 
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
    NSString *documentsDirectory = [paths objectAtIndex:0]; 
    BOOL isFileCreated; 

    if(isPortrait) 
    { 
     isFileCreated = UIGraphicsBeginPDFContextToFile([NSString stringWithFormat:@"%@/test.pdf",documentsDirectory],CGRectMake(self.m_ScrollView.frame.origin.x, self.m_ScrollView.frame.origin.y-340, self.m_ScrollView.frame.size.width, self.m_ScrollView.contentSize.height), nil); 

    } 
    else 
    { 
     isFileCreated = UIGraphicsBeginPDFContextToFile([NSString stringWithFormat:@"%@/test.pdf",documentsDirectory],CGRectMake(self.m_ScrollView.frame.origin.x, self.m_ScrollView.frame.origin.y-250, self.m_ScrollView.frame.size.width, self.m_ScrollView.contentSize.height), nil); 
    } 

    if(isFileCreated) 
    { 
     UIGraphicsBeginPDFPage(); 
     [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; 
     UIGraphicsEndPDFContext(); 
    } 

此代码创建只有一半的PDF。目前显示在屏幕上,其余的pdf缺失,目前没有在屏幕上显示。我该怎么办? 在此先感谢。

+0

我在这里使用UIGraphicsGetCurrentContext()方法。我认为它只呈现当前显示区域。有没有办法渲染所有的视图。 – Bond 2012-03-27 13:24:59

回答