- From: Jones, Mark (BVT) (UK) <mark.jones13@bvtsurfacefleet.com>
- Date: Tue, 8 Sep 2009 17:29:54 +0100
- To: <www-xsl-fo@w3.org>
- Message-ID: <AAF9ADACA20677459DF6D659C1C09FAD019F8CEA@GLKMS2108.GREENLNK.NET>
Hi there, I have a Java Stored Procedure in Oracle that converts a CLOB feed of SVG based XML into a PDF file and stores it as a BFILE. The following code works. Code: CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED DMG."com/aca/pdfwriter" AS package com.aca.pdfwriter; //import Java import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.OutputStream; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.sql.PreparedStatement; import java.sql.Blob; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; //import oracle import oracle.jdbc.pool.OracleDataSource; import oracle.jdbc.OracleResultSet; import oracle.sql.BFILE; import oracle.sql.BLOB; import oracle.sql.CLOB; //import Batik import org.apache.batik.transcoder.Transcoder; import org.apache.batik.transcoder.TranscoderException; import org.apache.batik.transcoder.TranscoderInput; import org.apache.batik.transcoder.TranscoderOutput; import org.apache.batik.gvt.font.GVTGlyphVector; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder; import org.apache.fop.svg.PDFTranscoder; import org.apache.fop.fonts.apps.PFMReader; public class svg2pdf{ public static int convertSVG2PDF(oracle.sql.CLOB svg) throws IOException, TranscoderException,SQLException { InputStream in = null; int seq =0; Transcoder transcoder = new org.apache.fop.svg.PDFTranscoder(); //Setup input //InputStream in = new java.io.FileInputStream(svg); //svg.open(); //in = svg.getBinaryStream(); in = svg.getAsciiStream(); try { TranscoderInput input = new TranscoderInput(in); //get the current connection Connection conn = DriverManager.getConnection("jdbc:default:connection"); conn.setAutoCommit(false); //must be set to false //Get unique sequence number Statement stmt = conn.createStatement(); ResultSet rset = stmt.executeQuery("select TEMP_BLOB_SEQ.nextval from dual"); while (rset.next()) { seq = ((OracleResultSet)rset).getInt(1); } stmt.close(); //Prepare the new blob PreparedStatement pstmt = conn.prepareStatement("insert into temp_blob (unique_id,blobby) values (" + seq + ", ?)"); oracle.sql.BLOB myBlob = oracle.sql.BLOB.createTemporary(conn, true, oracle.sql.BLOB.DURATION_SESSION); //Setup the outputstream OutputStream out = null; out = myBlob.setBinaryStream(0); try { System.out.println("start PDF" ); TranscoderOutput output = new TranscoderOutput(out); //Do the transformation transcoder.transcode(input, output); System.out.println("Generated PDF" ); pstmt.setBlob(1,myBlob); pstmt.execute(); pstmt.close(); } catch (Exception e){ System.out.println(e.getMessage() ); e.printStackTrace(); PreparedStatement xxx = conn.prepareStatement("insert into z (z) values (" + e.getMessage() + ")"); xxx.execute(); xxx.close(); } finally { out.close(); conn.commit(); conn.close(); } } finally { in.close(); //svg.closeFile(); } return seq; } } / ********************************** If I use the following code as my input CLOB the source is successfully transformed to PDF output. Source: <?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"> <svg width="1320px" height="360px" viewBox="0 0 1320 360"> <script type="text/javascript"> <![CDATA[ function ToggleRptValues(){ var div = svgDocument.getElementById('Planned'); if (div != null){ var obj = svgDocument.getElementById('Planned'); vis = obj.getAttribute("style"); if (vis == "visibility:visible") obj.setAttribute("style","visibility:hidden"); else obj.setAttribute("style","visibility:visible"); } div = svgDocument.getElementById('Forecast'); if (div != null){ var obj = svgDocument.getElementById('Forecast'); vis = obj.getAttribute("style"); if (vis == "visibility:visible") obj.setAttribute("style","visibility:hidden"); else obj.setAttribute("style","visibility:visible"); } div = svgDocument.getElementById('Actual'); if (div != null){ var obj = svgDocument.getElementById('Actual'); vis = obj.getAttribute("style"); if (vis == "visibility:visible") obj.setAttribute("style","visibility:hidden"); else obj.setAttribute("style","visibility:visible"); } div = svgDocument.getElementById('Conformant'); if (div != null){ var obj = svgDocument.getElementById('Conformant'); vis = obj.getAttribute("style"); if (vis == "visibility:visible") obj.setAttribute("style","visibility:hidden"); else obj.setAttribute("style","visibility:visible"); } } //]]> </script> <text x="528" y="26" style="text-anchor: middle; font-family:Courier;font-size:12pt;"> CDRL Delivery Performance Report </text> <line x1="267.384615384615384615384615384615384615" y1="36" x2="267.384615384615384615384615384615384615" y2="306" style="stroke: black;" /> <text x="272.384615384615384615384615384615384615" y="46" style="fill:black; stroke-width: 1; font-family:Courier;font-size:10pt;">Today</text> <line x1="100" y1="302.599646486964206805125939019001325674" x2="100" y2="302.599646486964206805125939019001325674" style=" stroke: blue;" /> <line x1="100" y1="302.599646486964206805125939019001325674" x2="165.415384615384615384615384615384615385" y2="218.72425983208130799823243482103402563" style=" stroke: blue;" /> <line x1="165.415384615384615384615384615384615385" y1="218.72425983208130799823243482103402563" x2="230.830769230769230769230769230769230769" y2="117.966416261599646486964206805125939019" style=" stroke: blue;" /> <line x1="230.830769230769230769230769230769230769" y1="117.966416261599646486964206805125939019" x2="296.246153846153846153846153846153846154" y2="93.269111798497569597878921785240830756" style=" stroke: blue;" /> <line x1="296.246153846153846153846153846153846154" y1="93.269111798497569597878921785240830756" x2="361.661538461538461538461538461538461538" y2="79.488731771984091913389306230667255855" style=" stroke: blue;" /> <line x1="361.661538461538461538461538461538461538" y1="79.488731771984091913389306230667255855" x2="427.076923076923076923076923076923076923" y2="67.61732213875386654882898806893504198" style=" stroke: blue;" /> <line x1="427.076923076923076923076923076923076923" y1="67.61732213875386654882898806893504198" x2="492.492307692307692307692307692307692308" y2="58.430402121078214759169244365885992046" style=" stroke: blue;" /> <line x1="492.492307692307692307692307692307692308" y1="58.430402121078214759169244365885992046" x2="557.907692307692307692307692307692307692" y2="49.064516129032258064516129032258064516" style=" stroke: blue;" /> <line x1="557.907692307692307692307692307692307692" y1="49.064516129032258064516129032258064516" x2="623.323076923076923076923076923076923077" y2="40.653115333627927529827662395050817499" style=" stroke: blue;" /> <line x1="623.323076923076923076923076923076923077" y1="40.653115333627927529827662395050817499" x2="688.738461538461538461538461538461538462" y2="36.656208572691117984975695978789217852" style=" stroke: blue;" /> <line x1="688.738461538461538461538461538461538462" y1="36.656208572691117984975695978789217852" x2="754.153846153846153846153846153846153846" y2="36.417587273530711444984533804684047724" style=" stroke: blue;" /> <g id="Planned" style="visibility:visible"> <circle cx="100" cy="302.599646486964206805125939019001325674" r="2" style="stroke: black; fill:blue;" /> <text x="90" y="302.599646486964206805125939019001325674" style="fill:blue; stroke-width: 1; font-family:Courier; font-size:10pt;">57</text> <circle cx="165.415384615384615384615384615384615385" cy="218.72425983208130799823243482103402563" r="2" style="stroke: black; fill:blue;" /> <text x="90" y="302.599646486964206805125939019001325674" style="fill:blue; stroke-width: 1; font-family:Courier; font-size:10pt;">123567890 abcdefg</text> </g> </svg> *************************** However, if I change the hi-lighted bit to output the character 4 or x it throws an error: <text x="90" y="302.599646486964206805125939019001325674" style="fill:blue; stroke-width: 1; font-family:Courier; font-size:10pt;">44123567890 abcdefg</text> ************************* Here is the error java.lang.ArrayIndexOutOfBoundsException at java.lang.System.arraycopy(System.java) at java.awt.geom.GeneralPathIterator.currentSegment(GeneralPathIterator.jav a:104) at java.awt.geom.GeneralPath.append(GeneralPath.java:309) at java.awt.geom.GeneralPath.append(GeneralPath.java:282) at org.apache.batik.gvt.font.AWTGVTGlyphVector.getOutline(Unknown Source) at org.apache.batik.gvt.font.AWTGVTGlyphVector.getBounds2D(Unknown Source) at org.apache.batik.gvt.text.GlyphLayout.getBounds2D(Unknown Source) at org.apache.batik.gvt.renderer.StrokingTextPainter.getBounds2D(Unknown Source) at org.apache.batik.gvt.TextNode.getPrimitiveBounds(Unknown Source) at org.apache.batik.gvt.AbstractGraphicsNode.getTransformedPrimitiveBounds( Unknown Source) at org.apache.batik.gvt.AbstractGraphicsNode.getTransformedBounds(Unknown Source) at org.apache.batik.gvt.CompositeGraphicsNode.getPrimitiveBounds(Unknown Source) at org.apache.batik.gvt.CompositeGraphicsNode.getTransformedPrimitiveBounds (Unknown Source) at org.apache.batik.gvt.AbstractGraphicsNode.getTransformedBounds(Unknown Source) at org.apache.batik.gvt.CompositeGraphicsNode.getPrimitiveBounds(Unknown Source) at org.apache.batik.gvt.CompositeGraphicsNode.getTransformedPrimitiveBounds (Unknown Source) at org.apache.batik.gvt.AbstractGraphicsNode.getTransformedBounds(Unknown Source) at org.apache.batik.gvt.CompositeGraphicsNode.getPrimitiveBounds(Unknown Source) at org.apache.batik.gvt.AbstractGraphicsNode.getBounds(Unknown Source) at org.apache.batik.gvt.AbstractGraphicsNode.paint(Unknown Source) at org.apache.fop.svg.PDFTranscoder.transcode(PDFTranscoder.java:237) at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(Unknown Source) at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(Unknown Source) at com.aca.pdfwriter.svg2pdf.convertSVG2PDF(pdfwriter:84) ********************* I am quite baffled as to how I resolve this. I tried naming standard fonts e.g. Courier, Arial Times Helvitica. But it came down to the same issue each time, it is only when the character 4 or x is displayed as text that the error occurs. Any ideas would be appreciated. Regards Mark Jones Senior Developer 0117 9186327 BVT Surface Fleet Ltd Building 20x, Filton, Bristol, BS34 7QW www.bvtsurfacefleet.com A BAE Systems and VT Group joint venture Registered No. 06160534 ******************************************************************** This email and any attachments are confidential to the intended recipient and may also be privileged. If you are not the intended recipient please delete it from your system and notify the sender. You should not copy it or use it for any purpose nor disclose or distribute its contents to any other person. ********************************************************************
Attachments
- image/gif attachment: image002.gif
Received on Wednesday, 9 September 2009 15:38:09 UTC