Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
guptashiv
Contributor
Contributor

XML to PDF conversion not working for 40+ records

I am trying to fetch records from DB and creating an XML file.

Now, to convert this XML into a PDF file, I have created a routine which uses a style sheet (.xsl) and XML file and uses apache FOP framework and makes a  transformer call to create pdf. 

 

Its working fine upto 40 records, but is taking a long time for more records.

Can anyone suggest how to resolve this issue.

 

Regards,

Shivangi gupta

Labels (2)
3 Replies
Anonymous
Not applicable

It's very difficult to help without more details about your routine. The only thing I can think of is that it is a memory issue. Is your method for doing this a static method? If not, it might be an idea to convert it to a static method.

guptashiv
Contributor
Contributor
Author

Hi rhall_2_0,

Please find below the routine. 

 

public class pdf{

public static void pdfMethod(String dependentFilePath, String fileOutputXML, String fileOutputPDF) {

OutputStream out=null;

try{

String filePathFlow=dependentFilePath;

StreamSource xmlSource=new StreamSource(new File(fileOutputXML));

FopFactory fopFactory = FopFactory.newInstance(new File(filePathFlow+File.separator+"fop.xconf"));

FOUserAgent foUserAgent = fopFactory.newFOUserAgent();

out= new java.io.FileOutputStream(fileOutputPDF);

out= new java.io.BufferedOuputStream(out);

Fop fop= fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out);

TransformerFactory factory = TransformerFactory .newInstance();

String styleSheetFilePath= dependentFilePath+File.separator+"pdf.xsl";

Transformer transformer = factory.newTransformer(new StreamSource (new File(styleSheetFilePath)));

Result res = new SAXResult(fop.getDefaultHandler());

transformer.transform(xmlSource,res);

}catch (Exception e)

{ e.printStackTrace();

}

finally{

IOUtils.closeQuietly(out);

}

}

}

 

Anonymous
Not applicable

There is clearly a lot going on during the conversion. You will need to add some logging I think to identify where the code slows down. I suspect that this is a memory issue. Have you tried adding more memory to the job?