Ejemplo n.º 1
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();
            }
        }
Ejemplo n.º 2
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;
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
 public TaskSavePdf(IPublishPdfOptions options, IActiveDocument activeDocument)
 {
     _options = options;
     _activeDocument = activeDocument;
 }