Highlighted

generatePDFOutput does not return the result, It successfully writes on to the server

azhar0180

21-12-2018

Hello everyone,

I was looking into the generatePDFOutput service using C# .Net, my requirements are to pass XML data file to the XDP and genrate the PDF file the problem currently I am running into is it generate the PDF on the server but and does not send anything to the client,

               PDFOutputOptionsSpec pdfOptions = new PDFOutputOptionsSpec();

                pdfOptions.fileURI = "C:\\temp\\sampleform.pdf";

my requirements are to get the PDF stream back to the client application and unfortunately this is not happening,

                    var outblob=  client.generatePDFOutput(TransformationFormat.PDF,

                        "SampleForm.xdp",

                        "repository:///Applications/DHS_FAST_COSMOS/1.0/eForms/form/",

                        pdfOptions,

                        renderOptions,

                        inData,

                        out generatePDFOutputMetaDataDoc,

                        out generatePDFOutputResultDoc,

                        out outResult);

the output BLOB objects does not has byte streams, My question am I using the correct service? how can i make the server return the PDF bytes.

here is my complete code

var endpointAddress = new System.ServiceModel.EndpointAddress("http://<sever:port>/soap/services/OutputService?blob=mtom");

                OutputServiceClient client = new OutputServiceClient();

                client.Endpoint.Address = endpointAddress;

                BasicHttpBinding binding = (BasicHttpBinding)client.Endpoint.Binding;

                binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;

                binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;

                binding.MaxReceivedMessageSize = 4000000;

                binding.MaxBufferSize = 4000000;

                binding.ReaderQuotas.MaxArrayLength = 4000000;

                binding.MessageEncoding = WSMessageEncoding.Mtom;

                client.ClientCredentials.UserName.UserName = "training";

                client.ClientCredentials.UserName.Password = "password";

                BLOB inData = new BLOB();

                string inputFileName = @"C:\\Temp\sampleform.xml";

                FileStream fs = new FileStream(inputFileName, FileMode.Open);

                //Get the length of the file stream and create a byte array 

                int len = (int)fs.Length;

                byte[] byteArray = new byte[len];

                //Populate the byte array with the contents of the file stream

                fs.Read(byteArray, 0, len);

                //Populate the BLOB object, NOTE the file is successfully writing on the server temp directory

                inData.binaryData = byteArray;

                //Set PDF run-time options

                PDFOutputOptionsSpec pdfOptions = new PDFOutputOptionsSpec();

                pdfOptions.fileURI = "C:\\temp\\sampleform.pdf";

               

                //pdfOptions.fileURI = "/DHS_FAST_COSMOS/1.0/eForms/form/SampleForm.xdp";

                //Set rendering run-time options

                RenderOptionsSpec renderOptions = new RenderOptionsSpec();

                renderOptions.cacheEnabled = true;

                renderOptions.renderAtClient = "Yes";

                renderOptions.PDFAConformance = PDFAConformance.A;

                renderOptions.PDFARevisionNumber = PDFARevisionNumber.Revision_1;

                pdfOptions.lookAhead = 300;

                pdfOptions.recordLevel = 1;

              

                BLOB generatePDFOutputMetaDataDoc = new BLOB();

                BLOB generatePDFOutputResultDoc = new BLOB();

                OutputResult outResult = new OutputResult();

               

                //Create a PDF Document                

              var outblob=  client.generatePDFOutput(TransformationFormat.PDF,

                        "SampleForm.xdp",

                        "repository:///Applications/DHS_FAST_COSMOS/1.0/eForms/form/",

                        pdfOptions,

                        renderOptions,

                        inData,

                        out generatePDFOutputMetaDataDoc,

                        out generatePDFOutputResultDoc,

                        out outResult);

                //trying to populate a byte array with BLOB data, NOTE binaryData is null

                byte[] outByteArray = generatePDFOutputResultDoc.binaryData;

Replies

Highlighted
Highlighted

azhar0180

09-01-2019

Using this C# code service create the valid PDF on the server but it is not streaming back ro the calling application.