protected ApplicationPrinterControllerBase() { using (new WsActivationContext()) { m_publisher = new CDocumentPublisherClass(); } }
public static void ConvertPDFToPDFA(string filename) { try { IDocumentPublisher8 publisher = new CDocumentPublisherClass(); publisher.ConvertPDFToPDFA(filename); } catch (Exception e) { throw new Exception("Unable to convert to PDF/A: " + e.Message); } }
private void InternalExecute(object threadstate) { IDocumentPublisher8 publisher = null; ThreadState Result = threadstate as ThreadState; CustomiseRegionalSetting convert = new CustomiseRegionalSetting(); try { PerformanceCounters.Instance.StartTimer(PerformanceCounters.CounterType.PDF); using (WsActivationContext wsac = new WsActivationContext()) { publisher = new CDocumentPublisherClass(); m_outputFile = GetPdfFilename(m_streamProperties["FileName"]); Publish(publisher, m_inputFile, m_outputFile); if ((bool)m_actionPropertySet[PdfActionStringTable.ConvertToPDFA].Value) publisher.ConvertPDFToPDFA(m_outputFile); else publisher.SetPermission(m_outputFile, (string) m_actionPropertySet[PdfActionStringTable.Password].Value, (bool) m_actionPropertySet[PdfActionStringTable.ProhibitPrinting].Value, (bool) m_actionPropertySet[PdfActionStringTable.ProhibitEdit].Value, (bool) m_actionPropertySet[PdfActionStringTable.ProhibitCopy].Value, (bool) m_actionPropertySet[PdfActionStringTable.ProhibitComments].Value); m_streamProperties["FileName"] = m_outputFile; // Can't just assign the DisplayName property, PDFAction removes any path info from it, // we need to keep the path info because it describes the structure of zip files, ie if its in a folder in a zip its DisplayName would be "SomeFolder\\Document.docx" // If we loose "somefolder\\" we loose where in the zip the file came from. string newOutputPath = Path.Combine(Path.GetDirectoryName(m_streamProperties["DisplayName"]), Path.GetFileName(m_outputFile)); m_streamProperties["DisplayName"] = newOutputPath; TryDeleteFiles(m_inputFile); if (Result != null) Result.ThreadStateResult = true; } } catch (COMException ex) { Logger.LogError(ex); if (Result != null) Result.ExceptionCaught = ex; } catch (Exception ex) { Logger.LogError(ex); if (Result != null) Result.ExceptionCaught = ex; } finally { convert.RestoreCulture(); if (null != publisher) { Marshal.ReleaseComObject(publisher); } } }
public static void SetPermissions(string filename, Workshare.Pdf.Combine.Coordinator.PdfSecurityOptions options) { IDocumentPublisher6 publisher = new CDocumentPublisherClass(); publisher.SetPermission(filename, options.Password, options.DisablePrinting, options.DisableModification, options.DisableCopy, options.DisableComments); }