HTML to PDF / DOCX / RTF Java converter library › Forums › PD4ML v3 Archived Forums (Read Only) › Troubleshooting › Out of memory error while converting a dxl file
- This topic has 12 replies, 2 voices, and was last updated May 15, 2013
17:05:02 by PD4ML.
-
AuthorPosts
-
February 13, 2013 at 07:36#26814
Hi ,
I am getting an out of memory erro while converting a dxl file to PDF File.
Kindly help to resolve the issue.DXL file attached as txt file.Note:sometimes the DXL file converted to PDF but in the resulting PDF File I have the below text see the attachement.This is a multipart message in MIME format
ContentElement(pd4content) [Dear Mr. Sharma and Mr. Singh,] {line-height=1.2000000476837158, white-space=pre, font-family=[Ljava.lang.String;@7f017f01, display=block, font-size=13}
ContentElement(pd4content) [Thank you for your email below, this is great news! Please proceed to ] {line-height=scale (1.2000000476837158), white-space=pre, font-family=[Ljava.lang.String;@7f017f01, display=block, font-size=13}[2/13/13 12:42:54:114 IST] 0000001b SystemErr R java.lang.OutOfMemoryError
[2/13/13 12:42:54:114 IST] 0000001b SystemErr R at java.util.ArrayList.newElementArray(Unknown Source)
[2/13/13 12:42:54:114 IST] 0000001b SystemErr R at java.util.ArrayList.growAtEnd(Unknown Source)
[2/13/13 12:42:54:114 IST] 0000001b SystemErr R at java.util.ArrayList.add(Unknown Source)
[2/13/13 12:42:54:114 IST] 0000001b SystemErr R at org.zefer.html.doc.bb.super(Unknown Source)
[2/13/13 12:42:54:114 IST] 0000001b SystemErr R at org.zefer.html.doc.bb.super(Unknown Source)
[2/13/13 12:42:54:114 IST] 0000001b SystemErr R at org.zefer.html.doc.view.d.o00000(Unknown Source)
[2/13/13 12:42:54:114 IST] 0000001b SystemErr R at org.zefer.html.doc.bb.super(Unknown Source)
[2/13/13 12:42:54:114 IST] 0000001b SystemErr R at org.zefer.html.doc.view.d.o00000(Unknown Source)
[2/13/13 12:42:54:114 IST] 0000001b SystemErr R at org.zefer.html.doc.bb.super(Unknown Source)
[2/13/13 12:42:54:114 IST] 0000001b SystemErr R at org.zefer.html.doc.d.super(Unknown Source)February 15, 2013 at 14:34#29211In most of the cases “This is a multipart message in MIME format” means the email message includes 2 content versions: HTML and text-only.
I tested your DXL with PD4ML v381 – the build suppresses “This is a multipart message in MIME format”, however still outputs both content versions as PDF.
OutOfMemory error usually can be handled with an overriding of Max Heap Size JVM parameter (i.e. -Xmx512m). But first I would recommend to give a try to PD4ML v381 – since v380fx5 you currently use – we addressed a number of DXL converting issues.
April 6, 2013 at 09:39#29212hi,
I tried v381 pro but still out of memory error persist.I increased my JVM heap memory upto 1.5 GB after that i am not able to.Could you kindly let me know what is the max JVM heap memory to set to get rid off this type of out of memory error?
Thanks
April 10, 2013 at 11:20#29213Could you please update on this issue.
April 16, 2013 at 12:45#29214Please update.
April 22, 2013 at 09:35#29215Please provide an update on this issue.
April 22, 2013 at 14:11#29216Please check if your Lotus agent (or standalone converter) calls extractAttachments( String dxl ) and after the call the attachment is replaced with something like that:
file:/…/Temp/attachment13685.Undertaking.pdf April 23, 2013 at 10:36#29217No there is nothing like that.
April 23, 2013 at 14:22#29218So it seems extractAttachments() method call takes no effect.
Make sure the method code is in the most actual state (and invoked from your code):
[language=java:1wluxbkf]public static final String extractAttachments( String body ) throws IOException {
if (body != null) {
int index01 = body.indexOf( “” ); index02 = body.indexOf( ““, index01 + 1 );
String fileName = “bin”;
int name01 = body.lastIndexOf(“name='”, index02);
if ( name01 > 0 ) {
name01 += 6;
int name02 = body.indexOf(''', name01);
if ( name02 > 0 ) {
fileName = body.substring(name01,name02);
}
}int endtag = body.indexOf( “>”, index01 + 1 );
String fileContent = body.substring( endtag + 1, index02 );
byte[] bytes = Base64.decode( fileContent );File file = File.createTempFile(“attachment”, “.” + fileName);
FileOutputStream fos = new FileOutputStream(file);
fos.write(bytes);String tmpFileName = file.toURI().toString();
sb.append( tmpFileName );
sb.append( “” );index02 += 11;
index01 = body.indexOf( “May 6, 2013 at 06:56#29219Hi ,
I am not sure where you want me to add the above portion of the code.Looking at the code it seems to be like you are creating the file in temp folder and adding some temprefrence tag to the html body.But after adding if you could give the details of what we need to do this return value it would be very helpful.
I also don’t want to store the file in temp loaction I just want to store the file in some file path other than temp folder.I will also give the code snippet of what I currenlty do to convert DXL to PDF and to extract attachements from the converted PDF File.
I am using below method to conver the html to pdf.
pd4ml.render(new StringReader(inputHTML), fos, new URL("file:."), "utf-8");
The inputHTML for the above function is framed as below.The contents of the DXL file is XMl source and the Pd4ml.xsl as xsl soruce.The below function returns the html content needed to pass to the above render function.try {<br /> java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();<br /> <br /> javax.xml.transform.Source xmlSource = new javax.xml.transform.stream.StreamSource(new StringReader(xml));<br /> javax.xml.transform.Source xsltSource = new javax.xml.transform.stream.StreamSource(new StringReader(xsl));<br /> javax.xml.transform.Result result = new javax.xml.transform.stream.StreamResult(baos);<br /> <br /> javax.xml.transform.TransformerFactory transFact = javax.xml.transform.TransformerFactory.newInstance();<br /> <br /> javax.xml.transform.Transformer trans = transFact.newTransformer(xsltSource);<br /> <br /> trans.transform(xmlSource, result);<br /> <br /> return baos.toString("utf-8");<br /> }
After the PDF file has been rendered I am extracting the attachement from that PDF file.
Kindly let me know if I have to do in some alrternate way.
May 7, 2013 at 16:31#29220extractAttachments() is intended to extract base64-encoded bulky data chunks from DXL (and replace with a reference to a TMP file), before the DXL is passed to XSLT transformer – otherwise it causes XSLT transformer to consume a lot of memory and to lose performance.
extractAttachments() deals with DXL not as with XML, but as with a long string. So it is sensitive to some XML formatting. The version I posted searches/replaces attachments more-less stable. You may use PdfAgent(R7).java or Dxl2Pdf.java extractAttachments() as a usage template (I thought your code is derived from one of the Java classes).
PD4ML may deal equally with attachments originally embedded in DXL or with references to extracted attachments. With the references it is asa a rule more performant.
May 13, 2013 at 05:47#29221Where is these java files located (PdfAgent(R7).java or Dxl2Pdf.java) can you please provide the link?
May 15, 2013 at 17:05#29222Dxl2Pdf.java can be found in the package:
http://pd4ml.com/dxl2pdf.2013.03.zipPdfAgentR7.java
http://pd4ml.com/i/PdfAgentR7.java -
AuthorPosts
The forum ‘Troubleshooting’ is closed to new topics and replies.