Quantcast
Channel: Adobe Community : Popular Discussions - LiveCycle Output
Viewing all articles
Browse latest Browse all 9631

Unable to create / open file

$
0
0

hi

 

i try to create pdf with Output Service API Quick Starts, i copy code in the file in

Web service API so i call my output service.
i have a modele ComdeDynamiq.xdp
i have  a  xml file for merging : PurchaseOrder.xml
i add to url service ?blob=base64
but my method generatePdfOutput don't run at all : no file generate
and in my file output.xml where i put data in generatepdfOutputResultDoc.BinaryData there is :
<?xml version="1.0" encoding="UTF-8"?>
<printResult>
<status>2</status>
<requestId>611e915ba</requestId>
<context>7</context>
<messages>
<message>Unable to create / open file C:\creerPdf\Res.pdf.</message>
</messages>
<printSpec/>
</printResult>
i don't knom what doesn't run in my code?? i give it in attach files? is there somoene which could help me??
thanks
my code is below :

using

 

System;

using

 

System.IO;

using

 

System.Collections;

using

 

System.ComponentModel;

using

 

System.Data;

using

 

System.Configuration;

using

 

System.Web;

using

 

System.Web.Security;

using

 

System.ServiceModel;

using

 

WebReference;

 

///

 

<summary>

///

 

Summary description for outPut

///

 

</summary>

public

 

classTestOutPut

{

 

public TestOutPut()

{

 

//

 

// TODO: Add constructor logic here

 

//

}

 

publicvoid Essai()

{

 

try

{

 

 

// Appel du service output

 

OutputServiceService outPutClient = newOutputServiceService();

outPutClient.Url +=

"?blob=base64";

outPutClient.Credentials =

new System.Net.NetworkCredential("administrator", "password");

 

//creation d'un blob pour stocker les données du fichier

 

BLOB inData = newBLOB();

 

//reference du fichier xml à merger avec le modèle :

 

String inPutFile = @"C:\\creerPdf\\PurchaseOrder.xml";

 

FileStream fs = newFileStream(inPutFile, FileMode.Open);

 

//on récupère la taille du flux du fichier et on crée un tableau de byte :

 

int longueur = (int)fs.Length;

 

Byte[] byteArray = newbyte[longueur];

 

//on remplit le tableau de byte avec le contenu du file stream :

fs.Read(byteArray, 0, longueur);

 

//on rempli le blob

inData.binaryData = byteArray;

 

//option de run time du pdf

 

PDFOutputOptionsSpec pdfOptions = newPDFOutputOptionsSpec();

pdfOptions.fileURI =

"C:\\creerPdf\\Res.pdf";

pdfOptions.lookAhead = 300;

pdfOptions.generateManyFiles =

false;

pdfOptions.recordLevel = 1;

 

//render options :

 

RenderOptionsSpec renderOptions = newRenderOptionsSpec();

renderOptions.cacheEnabled =

true;

 

//Create empty objects to pass as arguments

 

//to the generatePDFOutput method

 

//These objects are populated by the method

 

BLOB generatePDFOutputMetaDataDoc = newBLOB();

 

BLOB generatePDFOutputResultDoc = newBLOB();

 

OutputResult outResult = newOutputResult();

 

//On crée le doc pdf

outPutClient.generatePDFOutput(

TransformationFormat.PDF, "BonCmdeDynamiq.xdp", "C:\\creerPdf\\", pdfOptions, renderOptions, inData, out generatePDFOutputMetaDataDoc, out generatePDFOutputResultDoc, out outResult);

 

//On ecrit les données vers output.pdf

 

//on rempli un tableau de byte avec les données de sortie

 

byte[] outByteArray = generatePDFOutputResultDoc.binaryData;

 

//On crée un nouveau fichier pour stocker les données

 

string FILE_NAME = "C:\\Adobe\\Output.xml";

 

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

 

//on ecrit le flux de données

 

BinaryWriter w = newBinaryWriter(fs2);

w.Write(outByteArray);

w.Close();

fs2.Close();

fs.Close();

}

 

catch(Exception ee)

{

 

Console.WriteLine(ee.Message);

}

 

}

}


Viewing all articles
Browse latest Browse all 9631

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>