asked on October 16, 2015
•
Show version history
Hello,
I cannot manage to have this script working that attaches a pdf eDoc to a document already stored in the repository, whereby the workflow (9.2.1.227) has to generate the pdf as the electronic counterpart of the document's pages.
The script is a mixture of Ed Heaney's code snippet as well as Devin Goble's. At this stage the script creates a non-empty memory stream and manages to attach a pdf file but the latter is empty (0 byte):
... despite the document has 1 page:
protected override void Execute() { var de = new DocumentExporter(); //Convert the documents to PDF and store in a memory stream var ms = new System.IO.MemoryStream(); DocumentInfo docInfo = Document.GetDocumentInfo(this.BoundEntryId, this.RASession); de.ExportPdf(docInfo, docInfo.AllPages, PdfExportOptions.IncludeText, ms); this.SetTokenValue("MemoryStreamCount", ms.Length); //Don't want anybody else messing around while we're working docInfo.Lock(LockType.Exclusive); using (Stream edocStream = docInfo.WriteEdoc("application/pdf", ms.ToArray().Length)) { edocStream.Write(ms.ToArray(), 0, 0); } docInfo.Extension = ".pdf"; //Important docInfo.Save(); //Cleanup docInfo.Unlock(); docInfo.Dispose(); }
Thanks in advance for advising,
Stéphane
0
0