Hi,
We have a java application which connects to Adobe LiveCycle server(ver9.0) to generate pdf. It generates pdf successfully when the pdf size is less than 4 MB.
Once the size exceeds 4 MB, the OutputResult object is returned but when pdf is opened says 'File is damaged and could not be repaired'. We checked the result of statusDoc function in OutputResult, but there is no error. Also, in ALC server no error is logged.
MaxInLine Size is 64K.
Any help is greatly appreciated.
Views
Replies
Total Likes
Are you able to convert this in LiveCycle adminui ?
-Wasil
Views
Replies
Total Likes
Apologies for the late reply WASIL.
Actually I was trying to gather more data so that I can give more clarity to this group.
Analysis:
If the images are hardcoded in the lca file and then invoked from java, it works(pdf's with more than 4MB size gets generated). But when xml is created dynamically and sent from java to ALC, damaged pdf gets generated.
I see 'pdfparser.XrefTrailerResolver Did not found XRef object pointed to by 'Prev' key at position' in the log file. This only comes when the pdf size exceeds 4 MB.
Views
Replies
Total Likes
Please confirm the API you are using in your Java application e.g. http://help.adobe.com/en_US/livecycle/10.0/ProgramLC/WS624e3cba99b79e12e69a9941333732bac8-7fd2.html
Are you using forms service to merge xml with your form template or PDF generator ?
-Wasil
Views
Replies
Total Likes
Below is the code snippet for pdf generation:
Properties connectionProps = new Properties();
connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, "<<IP Address of machine where ALC server is running>>");
connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL, ServiceClientFactoryProperties.DSC_SOAP_PROTOCOL);
connectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, ServiceClientFactoryProperties.DSC_WEBLOGIC_SERVER_TYPE);
connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, userName);
connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_PASSWORD, pswd);
ServiceClientFactory myFactory = ServiceClientFactory.createInstance(connectionProps);
OutputClient outClient = new OutputClient(myFactory);
InputStream ins = new ByteArrayInputStream(inputSource.getBytes());// inputSource is a String with data in xml format
TransformerFactory factory = TransformerFactory.newInstance();
com.adobe.repository.infomodel.bean.Resource r = repositoryClient.readResource(xsltLocation);
Source xslt = new StreamSource(r.getContent().getDataDocument().getFile());
Transformer transformer = factory.newTransformer(xslt);
Source text = new StreamSource(ins);
ByteArrayOutputStream myOutStream = new ByteArrayOutputStream();
Result updatedText = new StreamResult(myOutStream);
transformer.transform(text, updatedText);
Document inXMDataTransformed = new Document(myOutStream.toByteArray());
PDFOutputOptionsSpec outputOptions = new PDFOutputOptionsSpec();
RenderOptionsSpec pdfOptions = new RenderOptionsSpec();
pdfOptions.setLinearizedPDF(true);
pdfOptions.setAcrobatVersion(AcrobatVersion.Acrobat_9);
//Create a PDF document..here templateName is the name of xdp file
OutputResult outputDocument = outClient.generatePDFOutput(
TransformationFormat.PDF,
templateName,
templateLocation,
outputOptions,
pdfOptions,
inXMDataTransformed
);
byte[] resultByte = outputDocument.getGeneratedDoc().toString().getBytes();
InputStream inputStream = outputDocument.getGeneratedDoc().getInputStream();
Views
Replies
Total Likes
Try this sample code which is working fine at my end (Jboss/ES4) :
package com.adobe.sample;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.InputStream;
import java.util.Properties;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import com.adobe.idp.Document;
import com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
import com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;
import com.adobe.livecycle.output.client.AcrobatVersion;
import com.adobe.livecycle.output.client.OutputClient;
import com.adobe.livecycle.output.client.OutputResult;
import com.adobe.livecycle.output.client.PDFOutputOptionsSpec;
import com.adobe.livecycle.output.client.RenderOptionsSpec;
import com.adobe.livecycle.output.client.TransformationFormat;
public class TestClass {
public static void main(String[] args) {
try {
// Set connection properties required to invoke LiveCycle ES2
Properties connectionProps = new Properties();
connectionProps.setProperty(
ServiceClientFactoryProperties.DSC_DEFAULT_EJB_ENDPOINT,
"jnp://127.0.0.1:1099");
connectionProps.setProperty(
ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,
ServiceClientFactoryProperties.DSC_EJB_PROTOCOL);
connectionProps.setProperty(
ServiceClientFactoryProperties.DSC_SERVER_TYPE, "JBoss");
connectionProps.setProperty(
ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME,
"administrator");
connectionProps.setProperty(
ServiceClientFactoryProperties.DSC_CREDENTIAL_PASSWORD,
"password");
String sampleXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><LoanApp><Name>LiveCycle</Name><LoanAmount>250000</LoanAmount><PhoneOrEmail>1231231234</PhoneOrEmail></LoanApp>";
// Create the service client factory
ServiceClientFactory myFactory = ServiceClientFactory
.createInstance(connectionProps);
OutputClient outClient = new OutputClient(myFactory);
InputStream ins = new ByteArrayInputStream(sampleXml.getBytes());// inputSource
// is
// a
// String
// with
// data
// in
// xml
// format
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer();
Source text = new StreamSource(ins);
ByteArrayOutputStream myOutStream = new ByteArrayOutputStream();
Result updatedText = new StreamResult(myOutStream);
transformer.transform(text, updatedText);
Document inXMDataTransformed = new Document(
myOutStream.toByteArray());
PDFOutputOptionsSpec outputOptions = new PDFOutputOptionsSpec();
outputOptions.setFileURI("C:\\Adobe\\LoanArchive.pdf");
RenderOptionsSpec pdfOptions = new RenderOptionsSpec();
pdfOptions.setLinearizedPDF(true);
pdfOptions.setAcrobatVersion(AcrobatVersion.Acrobat_9);
OutputResult outputDocument = outClient.generatePDFOutput(
TransformationFormat.PDF,
"PreLoanForm.xdp",
"repository:///Applications/FirstAppSolution/1.0/",
outputOptions,
pdfOptions,
inXMDataTransformed
);
/*byte[] resultByte = outputDocument.getGeneratedDoc().toString()
.getBytes();
InputStream inputStream = outputDocument.getGeneratedDoc()
.getInputStream();*/
Document resultData = outputDocument.getStatusDoc();
File myFile = new File("C:\\Adobe\\OutputLog.xml");
resultData.copyToFile(myFile);
} catch (Exception e) {
System.out.println("Exception thrown while trying to read the file"
+ e.getMessage());
}
}
}
-Wasil
Views
Replies
Total Likes
Thanks, Wasil.
I can generate pdf with your code but the behaviour was same (error in pdf) when I sent my xml request and the pdf size reached more than 4 MB.
What I did was, saved images in repository and mentioned the image uri in the xml file.
Is there a way to debug what is wrong in the xml request that is submitted to ALC server?
Views
Replies
Total Likes
Please test your form and xml(with reference to images in repository) with OutputIVS :http://blogs.adobe.com/LiveCycleHelp/2009/04/output_ivs_a_useful_output_es.html
http://filon.us/slava/testing-adobe-livecycle-form-with-outputivs/
-Wasil
Views
Replies
Total Likes
Thanks, Wasil. PDF got generated from OutputIVS.
But when invoked from standalone java programme, it still gives damaged pdf file. Do you see any issue in the below code.
Properties ConnectionProps = new Properties();
ConnectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_EJB_ENDPOINT,"jnp://<<Ip of ALC server>>:1099");
ConnectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_EJB_PROTOCOL);
ConnectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, "JBoss");
ConnectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME,"administrator");
ConnectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_PASSWORD,"password");
ServiceClientFactory myFactory = ServiceClientFactory.createInstance(ConnectionProps);
ResourceRepositoryClient repositoryClient = new ResourceRepositoryClient(myFactory);
ConvertPdfServiceClient serviceClient = new ConvertPdfServiceClient(myFactory);
String fileName = "<<data file>>";
Document inXMDataTransformed = new Document(new File(fileName), false);
PDFOutputOptionsSpec outputOptions = new PDFOutputOptionsSpec();
RenderOptionsSpec pdfOptions = new RenderOptionsSpec();
pdfOptions.setLinearizedPDF(true);
pdfOptions.setAcrobatVersion(AcrobatVersion.Acrobat_9);
OutputClient outClient = new OutputClient(myFactory);
String templateName = "<<xdp name>>";
String templateLocation = "<<repository location>>";
OutputResult outputDocument = outClient.generatePDFOutput(TransformationFormat.PDF, templateName, templateLocation,
outputOptions, pdfOptions, inXMDataTransformed);
outputDocument.getGeneratedDoc().copyToFile(new File("D:\\" + System.currentTimeMillis() + ".pdf"));
Views
Replies
Total Likes
Although not tested, but this should work fine.
-Wasil
Views
Replies
Total Likes
The issue got resolved after removing the below code.
pdfOptions.setLinearizedPDF(true);
Thanks a lot for the help, Wasil.
Views
Replies
Total Likes