Viewing pdf document in portrait/landscape in page curl with zoom in/zoom out xcode?

1.2k views Asked by At

In my application project for page curl effect,

I'm using this github project UIPageViewController-PDF and I have two types of pdf documents, one document is in portrait view(vertical document) and another document is in landscape view(horizontal document) its getting so many issues while handling this portrait/landscape orientation. If I have a portrait type document and I open it in portrait mode so its view is good but when I rotate my iPad in landscape mode so it doesn't fit in landscape mode. It must be fit to size I guess but the corners of the document is cutting not showing the full view like in portrait. Its a portrait document so viewing in portrait mode is fine but as I rotate my device so it out of the size and go outside the screen so it cuts the document. And same is with landscape document, my landscape document is viewing in landscape mode is perfect but when I rotate it in portrait mode so my landscape document again cut from the corners and full image is not showing. I want to handle it like the UIWebView handled the orientation nicely , it manages both landscape or portrait document in portrait/landscape mode perfectly I hope you guys understand my question.

I'm attaching also the screenshots and a bit of code too.

in ContentViewController in viewDidLoad

- (void)viewDidLoad
{
    [super viewDidLoad];

    UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];

    if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown) {

        NSLog(@"Portrait");
        CGPDFPageRef PDFPage = CGPDFDocumentGetPage(thePDF, [_page intValue]);
        pdfScrollView = [[PDFScrollView alloc] initWithFrame:self.view.frame];
        pdfScrollView = [[PDFScrollView alloc] initWithFrame:CGRectMake(-34.0, -80.0, 770.0, 1085.0)];
        [pdfScrollView setPDFPage:PDFPage];
        [self.view addSubview:pdfScrollView];
        self.view.backgroundColor = [UIColor blackColor];
        self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
        pdfScrollView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
        pdfScrollView.delegate = pdfScrollView;

    } else {
        NSLog(@"Landscape");
        CGPDFPageRef PDFPage = CGPDFDocumentGetPage(thePDF, [_page intValue]);
        pdfScrollView = [[PDFScrollView alloc] initWithFrame:self.view.frame];    //-280, -80, 1063, 1180
        pdfScrollView = [[PDFScrollView alloc] initWithFrame:CGRectMake(-280.0, -40.0, 1024.0, 1024.0)];
        [pdfScrollView setPDFPage:PDFPage];
        [self.view addSubview:pdfScrollView];
        self.view.backgroundColor = [UIColor blackColor];
        self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
        pdfScrollView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
        pdfScrollView.delegate = pdfScrollView;

    }
}

enter image description here

Thanks.

Zeeshan Shaikh

0

There are 0 answers