Exemplo n.º 1
0
        public void Dispose()
        {
            if (_prePage != null)
            {
                _prePage.Dispose();
            }

            _getPage = null;
        }
Exemplo n.º 2
0
        private void rilasciaRisorsePaginaPrecendete(int pageNumber)
        {
            // Sulla prima pagina non ho ancora nulla da fare
            if (pageNumber == 0)
            {
                return;
            }

            // Libero un pò di memoria, ammesso di fare ancora in tempo.
            foreach (IImmagine immagine in immaginiPaginaPrecedente)
            {
                immagine.Dispose();
            }
            immaginiPaginaPrecedente.Clear();

            if (lastLoadedPage != null)
            {
                lastLoadedPage.Dispose();
                lastLoadedPage = null;
            }

            // Qualche cabala + incantesimi
            // FormuleMagiche.rilasciaMemoria();
            // Dopo il passaggio a .net 4.6 e sqlite aggiornato, questo non funziona più e si pianta
            //			FormuleMagiche.attendiGcFinalizers();
            //			FormuleMagiche.rilasciaMemoria();
        }
 public override void Dispose()
 {
     base.Dispose();
     if (_OriginalPage != null)
     {
         _OriginalPage.Dispose();
         _OriginalPage = null;
     }
 }
Exemplo n.º 4
0
        public override DocumentPage GetPage(int page_zero_based)
        {
            // Hackity hack
            WPFDoEvents.DoEvents();

            if (null != last_document_page)
            {
                last_document_page.Dispose();
                last_document_page = null;
            }

            int page = page_from + page_zero_based;

            StatusManager.Instance.UpdateStatus("PDFPrinter", String.Format("Printing page {0} of {1}", page_zero_based + 1, this.PageCount), page_zero_based + 1, this.PageCount, true);

            // Render a page at 300 DPI...
            using (Image image = Image.FromStream(new MemoryStream(pdf_renderer.GetPageByDPIAsImage(page, 300))))
            {
                PDFOverlayRenderer.RenderAnnotations(image, pdf_document, page, null);
                PDFOverlayRenderer.RenderHighlights(image, pdf_document, page);
                PDFOverlayRenderer.RenderInks(image, pdf_document, page);
                BitmapSource image_page = BitmapImageTools.CreateBitmapSourceFromImage(image);
                image_page.Freeze();

                DrawingVisual dv = new DrawingVisual();
                using (DrawingContext dc = dv.RenderOpen())
                {
                    // Rotate the image if its orientation does not match the printer
                    if (
                        page_size.Width < page_size.Height && image_page.Width > image_page.Height ||
                        page_size.Width > page_size.Height && image_page.Width < image_page.Height
                        )
                    {
                        image_page = new TransformedBitmap(image_page, new RotateTransform(90));
                        image_page.Freeze();
                    }

                    dc.DrawImage(image_page, new Rect(0, 0, page_size.Width, page_size.Height));
                }

                ++total_pages_printed;

                last_document_page = new DocumentPage(dv);
                return(last_document_page);
            }
        }
Exemplo n.º 5
0
        public override DocumentPage GetPage(int pageNumber)
        {
            pageNumber = pageNumber + _pageRange.PageFrom - 1;

            if (_prevPage != null)
            {
                _prevPage.Dispose();
            }

            double w = _doc.Pages[pageNumber].Width;
            double h = _doc.Pages[pageNumber].Height;

            if (PageRotation(_doc.Pages[pageNumber]) == PageRotate.Rotate270 ||
                PageRotation(_doc.Pages[pageNumber]) == PageRotate.Rotate90)
            {
                var t = w; w = h; h = t;
                PrinterTicket.PageOrientation = PageOrientation.ReverseLandscape;
            }

            var visual = new DrawingVisual();
            var page   = new DocumentPage(visual);

            page.PageDestroyed += Page_PageDestroyed;
            RenderPage(pageNumber, visual);
            _prevPage = page;


            if (PagePrinted != null)
            {
                var args = new PagePrintedEventArgs(pageNumber - _pageRange.PageFrom + 1, _pageCount);
                PagePrinted(this, args);
                if (args.Cancel)
                {
                    _pageCount = 0;
                }
            }

            return(page);
        }