public Task <bool> Scann(PdfViewer obj = null)
        {
            scannedDoc = new List <string>();
            PDFViewer  = obj;
            Application.Current.Dispatcher.Invoke((System.Action)(delegate
            {
                obj.Visibility = Visibility.Collapsed;
            }));

            StaticSourcesViewModel.ShowMensajeProgreso("Espere Por Favor, Escaneando...");
            try
            {
                var morePages         = true;
                var commonDialogClass = new CommonDialog();
                var scannerDevice     = commonDialogClass.ShowSelectDevice(WiaDeviceType.ScannerDeviceType, false);
                var pagecount         = 0;

                if (scannerDevice != null)
                {
                    scannerDevice.Properties["Pages"].set_Value(1);
                    scannerDevice.Properties["Document Handling Select"].set_Value(1);

                    var document = new PdfDocument();
                    while (morePages)
                    {
                        try
                        {
                            var scannnerItem = scannerDevice.Items[1];
                            AdjustScannerSettings(scannnerItem, 150, 0, 0, 1250, 1700, 0, 0, WiaImageIntent.ColorIntent);

                            var img = (ImageFile)scannnerItem.Transfer("{B96B3CB1-0728-11D3-9D7B-0000F81EF32E}");
                            if (img != null)
                            {
                                document.Pages.Add(new PdfPage());
                                var xgr  = XGraphics.FromPdfPage(document.Pages[pagecount]);
                                var Ximg = XImage.FromBitmapSource(ConvertScannedImage(img));

                                xgr.DrawImage(Ximg, 0, 0, 595, 842);

                                pagecount++;
                            }

                            WIA.Property documentHandlingSelect = null;
                            WIA.Property documentHandlingStatus = null;

                            foreach (WIA.Property prop in scannerDevice.Properties)
                            {
                                if (prop.PropertyID == 3088)
                                {
                                    documentHandlingSelect = prop;
                                }

                                if (prop.PropertyID == 3087)
                                {
                                    documentHandlingStatus = prop;
                                }
                            }

                            morePages = false;

                            if (documentHandlingSelect != null)
                            {
                                if ((Convert.ToUInt32(documentHandlingSelect.get_Value()) & 0x00000001) != 0)
                                {
                                    morePages = ((Convert.ToUInt32(documentHandlingStatus.get_Value()) & 0x00000001) != 0);
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            if (pagecount <= 0)
                            {
                                Application.Current.Dispatcher.Invoke((System.Action)(delegate
                                {
                                    if (ex.Message == "Exception from HRESULT: 0x80210003")
                                    {
                                        StaticSourcesViewModel.Mensaje("Digitalización", "Revise que la bandeja tenga hojas", StaticSourcesViewModel.enumTipoMensaje.MENSAJE_INFORMACION);
                                    }
                                    else
                                    if (ex.Message == "Value does not fall within the expected range.")
                                    {
                                        StaticSourcesViewModel.Mensaje("Digitalización", "*- Revise que el escáner este encendido.\n*- Revise que el escáner este bien conectado", StaticSourcesViewModel.enumTipoMensaje.MENSAJE_INFORMACION);
                                    }
                                    else
                                    {
                                        StaticSourcesViewModel.Mensaje("Digitalización", "Hay problemas para conectarse con el escaner", StaticSourcesViewModel.enumTipoMensaje.MENSAJE_INFORMACION);
                                    }
                                }));
                            }

                            morePages = false;
                        }
                    }

                    if (pagecount > 0)
                    {
                        fileNamepdf = Path.GetTempPath() + Path.GetRandomFileName().Split('.')[0] + ".pdf";

                        document.Save(fileNamepdf);

                        ScannedDocument = File.ReadAllBytes(fileNamepdf);

                        Application.Current.Dispatcher.Invoke((System.Action)(delegate
                        {
                            obj.LoadFile(fileNamepdf);
                            obj.Visibility = Visibility.Visible;
                        }));
                    }
                }
            }
            catch (Exception ex)
            {
                Application.Current.Dispatcher.Invoke((System.Action)(delegate
                {
                    if (ex.Message.Contains("HRESULT: 0x80210015"))
                    {
                        StaticSourcesViewModel.Mensaje("Digitalización", "*- No tienes ningun escaner instalado.\n*- Revise que el escáner este encendido.\n*- Revise que el escáner este bien conectado", StaticSourcesViewModel.enumTipoMensaje.MENSAJE_INFORMACION);
                    }
                    if (ex.Message.Contains("HRESULT: 0x80070021"))
                    {
                        StaticSourcesViewModel.Mensaje("Digitalización", "Hay problemas para conectarse con el escaner", StaticSourcesViewModel.enumTipoMensaje.MENSAJE_INFORMACION);
                    }
                }));
            }
            StaticSourcesViewModel.CloseMensajeProgreso();
            return(TaskEx.FromResult(true));
        }