private static void StreamPDF(string XMLFile, string XSLTFile) { // Load the style sheet. XslCompiledTransform xslt = new XslCompiledTransform(); xslt.Load(XMLFile); XmlDocument objSourceData = new XmlDocument(); //Load the Source XML Document objSourceData.Load(XSLTFile); // Execute the transform and output the results to a file. MemoryStream ms = new MemoryStream(); xslt.Transform(objSourceData, null, ms); //Convert the Byte Array from MemoryStream to SByte Array sbyte[] inputFOBytes = ToSByteArray(ms.ToArray()); InputSource inputFoFile = new org.xml.sax.InputSource(new ByteArrayInputStream(inputFOBytes)); ByteArrayOutputStream bos = new java.io.ByteArrayOutputStream(); org.apache.fop.apps.Driver dr = new org.apache.fop.apps.Driver(inputFoFile, bos); dr.setRenderer(org.apache.fop.apps.Driver.RENDER_PDF); dr.run(); //Convert the SByte Array to Byte Array to stream to the Browser byte[] getBytes = ToByteArray(bos.toByteArray()); MemoryStream msPdf = new MemoryStream(getBytes); Response.ContentType = "application/pdf"; Response.AddHeader("Content-disposition", "filename=output.pdf"); Response.OutputStream.Write(getBytes, 0, getBytes.Length); Response.OutputStream.Flush(); Response.OutputStream.Close(); }
public int Generate(Stream source, Stream output) { var jIn = new InputSource(GetReader(source)); OutputStream jOut = new StreamOutputStream(output); var driver = new Driver(jIn, jOut); driver.setRenderer(Driver.RENDER_PDF); driver.run(); var pageCount = driver.getResults().getPageCount(); jOut.flush(); return pageCount; }
public static __XDocument Parse(string text) { var r = default(__XDocument); try { // http://stackoverflow.com/questions/33262/how-do-i-load-an-org-w3c-dom-document-from-xml-in-a-string // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6238729 var f = javax.xml.parsers.DocumentBuilderFactory.newInstance(); var b = f.newDocumentBuilder(); var s = new InputSource(new StringReader(text)); var doc = b.parse(s); r = new __XDocument { InternalDocument = doc, InternalValue = doc }; } catch { // X:\jsc.svn\examples\java\hybrid\Test\TestJVMCLRXElementParse\TestJVMCLRXElementParse\Program.cs // X:\jsc.svn\examples\javascript\LINQ\test\auto\TestSelect\TestAndroidOrderByThenGroupBy\Application.cs Console.WriteLine("XDocument Parse error: " + new { text }); //throw new NotSupportedException(); throw; } return r; }
/** * Parse the content of the given input source as an XML document * and return a new DOM {@link Document} object. * An <code>IllegalArgumentException</code> is thrown if the * <code>InputSource</code> is <code>null</code> null. * * @param is InputSource containing the content to be parsed. * @exception IOException If any IO errors occur. * @exception SAXException If any parse errors occur. * @see org.xml.sax.DocumentHandler * @return A new DOM Document object. */ public abstract Document parse(InputSource isJ);
/** * Parse the content of the given file as an XML document * and return a new DOM {@link Document} object. * An <code>IllegalArgumentException</code> is thrown if the * <code>File</code> is <code>null</code> null. * * @param f The file containing the XML to parse. * @exception IOException If any IO errors occur. * @exception SAXException If any parse errors occur. * @see org.xml.sax.DocumentHandler * @return A new DOM Document object. */ public Document parse(java.io.File f) { // throws SAXException, IOException { if (f == null) { throw new java.lang.IllegalArgumentException ("File cannot be null"); } String escapedURI = FilePathToURI.filepath2URI (f.getAbsolutePath ()); if (DEBUG) { java.lang.SystemJ.outJ.println ("Escaped URI = " + escapedURI); } InputSource inJ = new InputSource (escapedURI); return parse (inJ); }
/** * Parse the content of the given URI as an XML document * and return a new DOM {@link Document} object. * An <code>IllegalArgumentException</code> is thrown if the * URI is <code>null</code> null. * * @param uri The location of the content to be parsed. * @return A new DOM Document object. * @exception IOException If any IO errors occur. * @exception SAXException If any parse errors occur. * @see org.xml.sax.DocumentHandler */ public Document parse(String uri) { //throws SAXException, IOException { if (uri == null) { throw new java.lang.IllegalArgumentException ("URI cannot be null"); } InputSource inJ = new InputSource (uri); return parse (inJ); }
/** * Parse the content of the given <code>InputStream</code> as an * XML document and return a new DOM {@link Document} object. * An <code>IllegalArgumentException</code> is thrown if the * <code>InputStream</code> is null. * * @param is InputStream containing the content to be parsed. * @param systemId Provide a base for resolving relative URIs. * @return A new DOM Document object. * @exception IOException If any IO errors occur. * @exception SAXException If any parse errors occur. * @see org.xml.sax.DocumentHandler */ public Document parse(java.io.InputStream isJ, String systemId) { //throws SAXException, IOException { if (isJ == null) { throw new java.lang.IllegalArgumentException ("InputStream cannot be null"); } InputSource inJ = new InputSource (isJ); inJ.setSystemId (systemId); return parse (inJ); }
/// <summary> /// Parse the content of the given input source as an XML document /// and return a new DOM <A HREF="../../../org/w3c/dom/Document.html" title="interface in org.w3c.dom"><CODE>Document</CODE></A> object. /// </summary> abstract public Document parse(InputSource @is);