\[code\]public void onClick(View v) {switch(v.getId()) { case R.id.button1: try { // Setup directories File baseDir = new File("res/layout"); File outDir = new File(baseDir, "/sdcard"); outDir.mkdirs(); // Setup input and output files File xmlfile = new File(baseDir, "activity_main.xml"); File xsltfile = new File(baseDir, "test.xsl"); File pdffile = new File(outDir, "ResultXML2PDF.pdf"); // configure fopFactory as desired FopFactory fopFactory = FopFactory.newInstance(); FOUserAgent foUserAgent = fopFactory.newFOUserAgent(); // configure foUserAgent as desired // Setup output OutputStream out = new java.io.FileOutputStream(pdffile); out = new java.io.BufferedOutputStream(out); try { // Construct fop with desired output format Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out); // Setup XSLT TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(new StreamSource(xsltfile)); // Set the value of a <param> in the stylesheet transformer.setParameter("versionParam", "2.0"); // Setup input for XSLT transformation Source src = http://stackoverflow.com/questions/15854308/new StreamSource(xmlfile); // Resulting SAX events (the generated FO) must be piped through to FOP Result res = new SAXResult(fop.getDefaultHandler()); // Start XSLT transformation and FOP processing transformer.transform(src, res); } finally { out.close(); } System.out.println("Success!"); } catch (Exception e) { e.printStackTrace(System.err); System.exit(-1); } }} \[/code\]Headingi want to convert my xml file including my view to pdf .. my android application must generat this pdf . i use code bellow but when i click on the generator button , the application is closed sudunely , and no file pdf in the sdcard (my xml and xsl file are in layout repertory).