xamarin / ios-samples

Xamarin.iOS sample apps
http://docs.microsoft.com/xamarin/ios/
Other
1.59k stars 1.92k forks source link

Certain types of pdfs are not visible . #79

Closed zerocold96 closed 8 years ago

zerocold96 commented 8 years ago

Using the Zoomable pdf viewer worked great at first, but then I noticed a small subsect of pdf that can't be display. I Looked around the code and the one thing I noticed is that CGPDFDocument is reading the file just fine, but when it is time to create the subsampling image the view shows a white page.

I exported the pdfs to pdf on my mac and now the file is bigger and they can be view on the device. Is it a compression issues? or is the formatting for the original pdf different?

// make the initial view 'fit to width'
            CGRect pageRect = page.GetBoxRect (CGPDFBox.Media);
            //scale = Frame.Width / pageRect.Width;
            scale = Frame.Width / pageRect.Width;
            pageRect.Size = new CGSize (pageRect.Width * scale , pageRect.Height * scale);

            // create bitmap version of the PDF page, to be used (scaled)
            // when no other (tiled) view are visible
            UIGraphics.BeginImageContext (pageRect.Size);
            CGContext context = UIGraphics.GetCurrentContext ();
            //CGColorSpace colorSpace = CGColorSpace.CreateDeviceRGB();
            //CGBitmapContext context = new CGBitmapContext(null, (int)pageRect.Size.Width, (int)pageRect.Size.Height, 8, (int)pageRect.Size.Width * 4, colorSpace , CGImageAlphaInfo.PremultipliedLast);

            // fill with white background
            context.SetFillColor (1.0f, 1.0f, 1.0f, 1.0f);
            context.FillRect (pageRect);
            context.SaveState ();
olegoid commented 8 years ago

Hi @zerocold96, could you attach your pdf file?

zerocold96 commented 8 years ago

15b9a77c-a05d-4dcb-9f38-e7423c55474e.pdf

It displays only a white page.

Arpit360 commented 8 years ago

I have reported bug in bugzilla for this issue https://bugzilla.xamarin.com/show_bug.cgi?id=42229

olegoid commented 8 years ago

@zerocold96, I think there's nothing wrong with ZoomingPdfViewer sample. It's desgined to work this way and it seems like document you're using is too large to be displayed correctly with this app. However you can try other samples like QuartzSample where your pdf file displayed correcly.

zerocold96 commented 8 years ago

Yes the quartzsample can read the pdf just fine.... this is odd. I will compare the samples and make notes of the differences. I must make a point of saying that I have other pdf files that do work just fine this way and are about the same size or bigger (both mb and pixels).