asked on September 7, 2016 Show version history

Hii all ,

we are reading a PDF File in byte array format through HTTP Web Service in our Workflow.

Aspx .

 

We need to retrieve the PDF Contents now through our SDK Script. 

How can we do the same?? Need your help.

namespace WorkflowActivity.Scripting.SDKScript
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Data.SqlClient;
    using System.Text;
    using System.IO;
    using System.Xml;
    using Laserfiche.RepositoryAccess;

    /// <summary>
    /// Provides one or more methods that can be run when the workflow scripting activity is performed.
    /// </summary>
    public class Script1 : RAScriptClass92
    {
        /// <summary>
        /// This method is run when the activity is performed.
        /// </summary>
        protected override void Execute()
        {
            string token = this.WorkflowApi.GetTokenValueFromNameAsString("EFormtoPDFRequestfromApplitrack_Content", 0);
            //var token2 = GetTokenValue("EFormtoPDFRequestfromApplitrack_Content File");


            // string token = this.WorkflowApi.GetTokenValueFromNameAsString("HTTPWebRequest_Content File", 1);
string base64PDF = null;
using(StringReader stringReader = new StringReader(token))
{
    using(XmlReader reader = XmlReader.Create(stringReader))
    {
        if(!reader.ReadToFollowing("GetFormAsPDF"))
        {
            this.WorkflowApi.TrackWarning("HTTP Response was not valid.");
            return;
        }

        base64PDF = reader.ReadElementContentAsString("GetFormAsPDF", "http://schemas.microsoft.com/ado/2007/08/dataservices");
    }
}

this.SetTokenValue("Base64PDF", base64PDF);
byte[] pdfBytes = Convert.FromBase64String(base64PDF);

DocumentInfo doc = this.BoundEntryInfo as DocumentInfo;
if (doc == null)
{
    this.WorkflowApi.TrackWarning("Entry was not a document.");
    return;
}

using (Stream edocStream = doc.WriteEdoc("application/pdf", pdfBytes.Length))
{
    edocStream.Write(pdfBytes, 0, pdfBytes.Length);
}

doc.Extension = ".pdf";
doc.Save();
        }
    }
}
0 0