-
1. Re: Damaged PDF getting generated when size exceeds 4 MB
WASIL Mar 12, 2014 12:48 PM (in response to Vibhaanshu)Are you able to convert this in LiveCycle adminui ?
-Wasil
-
2. Re: Damaged PDF getting generated when size exceeds 4 MB
Vibhaanshu Mar 14, 2014 12:12 AM (in response to WASIL)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.
-
3. Re: Damaged PDF getting generated when size exceeds 4 MB
WASIL Mar 14, 2014 2:20 PM (in response to Vibhaanshu)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
-
4. Re: Damaged PDF getting generated when size exceeds 4 MB
Vibhaanshu Mar 17, 2014 11:32 PM (in response to WASIL)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();
-
5. Re: Damaged PDF getting generated when size exceeds 4 MB
WASIL Mar 19, 2014 8:54 AM (in response to Vibhaanshu)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><PhoneO rEmail>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
-
PreLoanForm.xdp.zip 18.0 K
-
-
6. Re: Damaged PDF getting generated when size exceeds 4 MB
Vibhaanshu Mar 20, 2014 5:21 AM (in response to WASIL)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?
-
7. Re: Damaged PDF getting generated when size exceeds 4 MB
WASIL Mar 20, 2014 5:43 AM (in response to Vibhaanshu)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
-
8. Re: Damaged PDF getting generated when size exceeds 4 MB
Vibhaanshu Mar 21, 2014 5:08 AM (in response to WASIL)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,ServiceC lientFactoryProperties.DSC_EJB_PROTOCOL);
ConnectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, "JBoss");
ConnectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME,"admini strator");
ConnectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_PASSWORD,"passwo rd");
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"));
-
9. Re: Damaged PDF getting generated when size exceeds 4 MB
WASIL Mar 21, 2014 6:35 AM (in response to Vibhaanshu)Although not tested, but this should work fine.
-Wasil
-
10. Re: Damaged PDF getting generated when size exceeds 4 MB
Vibhaanshu Mar 21, 2014 6:38 AM (in response to WASIL)The issue got resolved after removing the below code.
pdfOptions.setLinearizedPDF(true);
Thanks a lot for the help, Wasil.


