Ejemplo n.º 1
0
 public PagePdf(pdf.PdfDocument Pdf, uint PageCount)
 {
     _Pdf       = Pdf ?? throw new ArgumentNullException(nameof(Pdf));
     _PageCount = PageCount;
     if (_PageCount >= _Pdf.PageCount)
     {
         throw new ArgumentOutOfRangeException(nameof(PageCount));
     }
 }
Ejemplo n.º 2
0
        /* A method to open a Remote PDF (The Hunger Games book) from a
         * stream using HttpClient and a URL. */
        public async void openRemote()
        {
            //Begin a new HTTPClient for access to urls
            HttpClient client = new HttpClient();
            //create a stream and wait for the client to get the url
            var stream = await
                         client.GetStreamAsync(txtUri.Text);

            //client.GetStreamAsync("http://www.kkoworld.com/kitablar/suzanna-kollinz-acliq-oyunlari-1-hisse-eng.pdf");
            var memStream = new MemoryStream();
            await stream.CopyToAsync(memStream);

            memStream.Position = 0;
            Windows.Data.Pdf.PdfDocument doc = await Windows.Data.Pdf.PdfDocument.LoadFromStreamAsync(memStream.AsRandomAccessStream());

            //loads in the pdf
            Load(doc);
        }
Ejemplo n.º 3
0
        //A method to Load in the Remote PDF file
        async void Load(Windows.Data.Pdf.PdfDocument pdfDoc)
        {
            PdfPages.Clear();
            //set up the pdf by saying i is less than total no. pages
            for (uint i = 0; i < pdfDoc.PageCount; i++)
            {
                //Set up a new image to render the pdf to the app
                BitmapImage image = new BitmapImage();

                //get i-the pdf doc
                var page = pdfDoc.GetPage(i);

                //Ref:docs.Microsoft.com
                //Provides random access of data in input and output streams
                //that are stored in memory instead of on disk.
                using (InMemoryRandomAccessStream stream = new InMemoryRandomAccessStream())
                {
                    await page.RenderToStreamAsync(stream);

                    await image.SetSourceAsync(stream);
                }
                PdfPages.Add(image);
            }
        }
Ejemplo n.º 4
0
 public BookPdf(pdf.PdfDocument content)
 {
     Content = content ?? throw new ArgumentNullException(nameof(content));
     OnLoaded();
 }