Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Flatten PDF using OutputServiceClient

spushpendra2000
Level 2
Level 2

Hi,

I am trying to flatten the PDF using the below code.

   OutputServiceClient outputClient = new OutputServiceClient();

                   outputClient.Endpoint.Address = new System.ServiceModel.EndpointAddress("http://172.20.148.143:8080/soap/services/OutputService?blob=mtom");

                   //Enable BASIC HTTP authentication

                   BasicHttpBinding b = (BasicHttpBinding)outputClient.Endpoint.Binding;

                   b.MessageEncoding = WSMessageEncoding.Mtom;

                   outputClient.ClientCredentials.UserName.UserName = "administrator";

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

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

                   b.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;

                   b.MaxReceivedMessageSize = 2000000;

                   b.MaxBufferSize = 2000000;

                   b.ReaderQuotas.MaxArrayLength = 2000000;

                   //Create a BLOB object

                   ConsoleApplication1.ServiceReference1.BLOB inData = new ConsoleApplication1.ServiceReference1.BLOB();

                   //Reference an interactive PDF document

                   string inputFileName = "C:\\ab\\xfa_movies.pdf";

                   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

                   inData.binaryData = byteArray;

                   //Set rendering run-time options 

                   RenderOptionsSpec renderOptions = new RenderOptionsSpec();

                   renderOptions.cacheEnabled = true;

                   //Create a non-interactive PDF document

                   ConsoleApplication1.ServiceReference1.BLOB results = outputClient.transformPDF(

                       inData,

                       TransformationFormat.PDF,

                       PDFARevisionNumber.Revision_1,

                       null,

                       PDFAConformance.A);

                   //Populate a byte array with a BLOB data

                   byte[] outByteArray = results.binaryData;

                   //Create a new file that represents the non-interactive PDF document

                   string FILE_NAME = "C:\\ab\\NonInteractiveLoan.pdf";

                   FileStream fs2 = new FileStream(FILE_NAME, FileMode.OpenOrCreate);

                   //Create a BinaryWriter object

                   BinaryWriter w = new BinaryWriter(fs2);

                   w.Write(outByteArray);

                   w.Close();

                   fs2.Close();

But it is not working. I referred the help where it talks about the usage of  BLOB.MTOM but is dont see this property when i added the webReference.

REgards

Pushpendra

0 Replies