Example #1
0
        public static void SendEmailMessage(IActiveDocument document, string attachfile)
        {
            try
            {
                var description = document.Description;
                if (String.Compare(Path.GetExtension(description), ".pdf", StringComparison.OrdinalIgnoreCase) != 0)
                {
                    description += ".pdf";
                }

                IPostman posty = new CPostmanClass();
                if (posty.CanMailTo)
                {
                    posty.Subject = "";
                    posty.BodyText = "";
                    posty.AddAttachment(attachfile, description, "", "", false, true);
                    posty.CallUpdateDocumentTag = false;
                    posty.FileEmailOnSend = false;
                    posty.ShowProtectUI = false;
                    posty.UseCCField = false;
                    posty.SendEx(false);
                }
                else
                {
                    var sErrMsg = string.Format(CultureInfo.CurrentCulture, Properties.Resources.MAILTO_FAILURE_MESSAGE, Properties.Resources.MAILTO_FAILURE_NOEMAILCLIENT_MESSAGE);
                    throw new Exception(sErrMsg);
                }
                Marshal.ReleaseComObject(posty);
            }
            catch (Exception e)
            {
                Logger.LogError(e);
                throw;
            }
        }
Example #2
0
        void HandleActiveDocumentChanged(IActiveDocument iActiveDocument, IViewContainer iViewContainer, int index)
        {
            System.Diagnostics.Debug.Assert(iViewContainer != null);
            if (index == -1)
            {
                return;
            }
            System.Diagnostics.Debug.Assert(index != -1);

            UserControl userControl = iViewContainer.GetUserControl(index);

            if (userControl == null)
            {
                // Should never happen!
                return;
            }

            if (iViewContainer is DocumentContainer)
            {
                if (ActiveDocumentView != userControl)
                {
                    if (_iActiveDocument != null)
                    {
                        _iActiveDocument.IsActive = false;
                    }
                    _iActiveDocument          = iActiveDocument;
                    _iActiveDocument.IsActive = true;
                    DocumentGotFocus?.Invoke(userControl, null);
                    ActiveDocumentView = userControl;
                    System.Diagnostics.Debug.WriteLine("Active document view: " + userControl.ToString());
                }
            }
        }
        public SelectDocumentsWindow(IActiveDocument activeDocument)
        {
            InitializeComponent();
            this.PreviewKeyDown += HandleEscapeKey;
            DataContext = new CompareViewModel(activeDocument);

            ResetVersionsComboBoxText();
        }
Example #4
0
        public static void Execute(IActiveDocument activeDocument, IPublishPdfOptions options)
        {
            try
            {
                var publisher = new PDFPublisher();
                var publisherOptions = publisher.CreateOptionsObject();
                publisherOptions.ReconstructHyperlinks = true;

                if (!options.PrintAll)
                    publisherOptions.PageRange = options.PageRange;

                if (!options.PrintAll || options.Clean)
                {
                    publisher.PublishFile(activeDocument.CurrentSnapShot, options.Destination, publisherOptions);
                }
                else
                {
                    publisher.PublishDocument(activeDocument.Instance, options.Destination, publisherOptions);
                }

                if (options.PdfFormat)
                {
                    var password = options.OpenPassword == options.ConfirmOpenPassword ? options.OpenPassword : "";
                    publisher.SetPDFPermissions(options.Destination, password, options.DisablePrinting, options.DisableModification,
                        options.DisableCopy, options.DisableNotesModification);
                }
                else
                {
                    publisher.ConvertPDFToPDFA(options.Destination);
                }
            }
            catch (COMException e)
            {
                // 0x800a1066 & 0x8000FFFF comes back as a HRESULT from Word::Document::PrintOut in the case of cancel being
                // clicked in the "warn when saveing with track changes dialog" see TFS 7225
                if ((uint)e.ErrorCode == (uint)0x800a1066 || ((uint)e.ErrorCode == (uint)0x8000FFFF))
                {
                    if (activeDocument.IsFinal)
                    {
                        return;
                    }
                }
                throw new Exception("Unable to convert to PDF: " + e.Message);
            }
            catch (Exception e)
            {
                Logger.LogError(e);
                throw;
            }
            finally
            {
                new Workshare.API.Cleaning.OfficeApplicationCacheControl().ReleaseOfficeApplications();
            }
        }
Example #5
0
        internal override Rectangle GetZone(IActiveDocument activeDocument)
        {
            var browserRect = new Rectangle(0, 0, activeDocument.BrowserSize.Width, activeDocument.BrowserSize.Height);

            if (!browserRect.Contains(Zone))
            {
                throw new CaptureEngineException($"Cropped zone is out of bounds for active document. Current size is {browserRect}", CaptureEngineState.InvalidCaptureZone);
            }

            return(Zone);
        }
Example #6
0
        public PdfSecurityForm(IActiveDocument activeDocument, IPublishPdfOptions options)
            : base(WorkshareFormUtility.DialogLevel.Secondary, WorkshareFormUtility.BrandType.Protect)
        {
            InitializeComponent();
            _activeDocument = activeDocument;
            _options = options;
            BindSecurityProperties();
            InitializeOptionsCounter();

            this.CueBanner(tbPassword, false, "Specify password");
            this.CueBanner(tbPasswordConfirm, false, "Confirm password");
            this.ShowInTaskbar = false;
        }
Example #7
0
        public static void Execute(IActiveDocument activeDocument, IPublishPdfOptions options)
        {
            var instance = new OfficeCleaner();
            instance.ExcludedMetadataTypes = new MetadataTypeCollection(options.ExcludedMetadata);

            instance.ExcludedFieldTypes = new FieldTypeCollection(PolicyBridge.GetCommonExcludedFieldTypes());
            instance.AdvancedFieldExclusionList = PolicyBridge.GetAdvancedExcludedFields();
            instance.CustomPropertyExclusionList = PolicyBridge.GetAdvancedExcludedCustomProperties();
            instance.DocumentVariableExclusionList = PolicyBridge.GetAdvancedExcludedDocumentVariables();
            instance.FieldDeletionList = PolicyBridge.GetFieldDeletetionList();
            instance.TreatFootNotesAsMetadata = PolicyBridge.TreatFootNotesAsMetadata();
            instance.CleanFile(activeDocument.CurrentSnapShot);
        }
        internal override Rectangle GetZone(IActiveDocument activeDocument)
        {
            try
            {
                int x =
                    (int)
                    Math.Round(Convert.ToDouble(activeDocument.RunJs($"$('{Selector}').offset().left;"),
                                                CultureInfo.InvariantCulture));

                int y =
                    (int)
                    Math.Round(Convert.ToDouble(activeDocument.RunJs($"$('{Selector}').offset().top;"),
                                                CultureInfo.InvariantCulture));

                int width =
                    (int)
                    Math.Round(Convert.ToDouble(activeDocument.RunJs($"$('{Selector}').innerWidth();"),
                                                CultureInfo.InvariantCulture));

                int height =
                    (int)
                    Math.Round(Convert.ToDouble(activeDocument.RunJs($"$('{Selector}').innerHeight();"),
                                                CultureInfo.InvariantCulture));

                return(new Rectangle(x, y, width, height));
            }
            catch (FormatException ex)
            {
                throw new CaptureEngineException("Bad jQuery Selector.", ex, CaptureEngineState.InvalidCaptureZone);
            }
            catch (GeckoJavaScriptException ex)
            {
                throw new CaptureEngineException(
                          "Bad jQuery Selector. Error while running javascript selector. (Maybe the captured page doesn't have jQuery 1.2.6 +)",
                          ex, CaptureEngineState.InvalidCaptureZone);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        private static Image ReadBitmap(GeckoWebBrowser webBrowser, CaptureZone captureZone, IActiveDocument activeDocument)
        {
            webBrowser.Stop();

            var rectangle = captureZone.GetZone(activeDocument);

            if (rectangle.Width == 0 || rectangle.Height == 0)
            {
                throw new CaptureEngineException($"Selected zone is 0 area {rectangle}", CaptureEngineState.InvalidCaptureZone);
            }

            try
            {
                return(webBrowser.GetBitmap(
                           (uint)rectangle.X,
                           (uint)rectangle.Y,
                           (uint)rectangle.Width,
                           (uint)rectangle.Height));
            }
            catch (InvalidOperationException)
            {
                throw new CaptureEngineException("Out of memory. Result bitmap size is too large",
                                                 CaptureEngineState.InternalError);
            }
        }
Example #10
0
 internal override Rectangle GetZone(IActiveDocument activeDocument)
 {
     return(new Rectangle(0, 0, activeDocument.BrowserSize.Width, activeDocument.BrowserSize.Height));
 }
Example #11
0
 public TaskSavePdf(IPublishPdfOptions options, IActiveDocument activeDocument)
 {
     _options = options;
     _activeDocument = activeDocument;
 }
Example #12
0
 internal abstract Rectangle GetZone(IActiveDocument activeDocument);
        internal override Rectangle GetZone(IActiveDocument activeDocument)
        {
            string rawResult = string.Empty;

            try
            {
                activeDocument.RunJs(CallBackImplementation);

                string callableCallBackName = CallBackName.Trim();

                if (!callableCallBackName.EndsWith("()"))
                {
                    callableCallBackName = $"{callableCallBackName}()";
                }

                rawResult = activeDocument.RunJs(
                    $"var callresult_____ = {callableCallBackName};" +
                    $"callresult_____.x + ';' + callresult_____.y + ';' + " +
                    $"callresult_____.width + ';' + callresult_____.height");

                if (rawResult == null)
                {
                    throw new CaptureEngineException($"Error while calling {callableCallBackName}",
                                                     CaptureEngineState.InvalidCaptureZone);
                }

                string [] arrayResult = rawResult.Split(';');

                int x      = int.Parse(arrayResult[0]);
                int y      = int.Parse(arrayResult[1]);
                int width  = int.Parse(arrayResult[2]);
                int height = int.Parse(arrayResult[3]);

                return(new Rectangle(x, y, width, height));
            }
            catch (FormatException fex)
            {
                throw new CaptureEngineException($"Result returned by {CallBackName} does not contains " +
                                                 $"at least one of these following properties: x, y, width, height. Or, " +
                                                 $"one of these properties does not have integer value. {rawResult}",
                                                 fex, CaptureEngineState.InvalidCaptureZone);
            }
            catch (GeckoJavaScriptException ex)
            {
                throw new CaptureEngineException($"Error while running {nameof(UserDefinedJavascriptZone)}"
                                                 , ex, CaptureEngineState.InvalidCaptureZone);
            }

            catch (GeckoException)
            {
                // Can't forward GeckoException because it's not serializable

                throw new CaptureEngineException($"Error while running {nameof(UserDefinedJavascriptZone)}"
                                                 , null, CaptureEngineState.InvalidCaptureZone);
            }
            catch (CaptureEngineException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new CaptureEngineException("Internal error"
                                                 , ex, CaptureEngineState.InternalError);
            }
        }
Example #14
0
 internal override Rectangle GetZone(IActiveDocument activeDocument)
 {
     return(activeDocument.DocumentSize);
 }