This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Aug 29, 2013, 6:26 AM
41 Posts

convert .xsp page in pdf

  • Category: Server Side JavaScript
  • Platform: All
  • Release: 9.0
  • Role: Developer
  • Tags: Convert pdf
  • Replies: 1

Dear Team,

I am using below code for convert .xsp page in pdf. But get it error in  line.Please suggest where i am wrong.

import java.io.*;
import com.lowagie.text.DocumentException;
import org.xhtmlrenderer.pdf.ITextRenderer;

***************************************************************************

import java.io.*;
import com.lowagie.text.DocumentException;
import org.xhtmlrenderer.pdf.ITextRenderer;

public class FirstDoc {

public static void main(String[] args)
        throws IOException, DocumentException {
    String url= "http://localhost/news.xsp";

    String outputFile = "firstdoc.pdf";
    OutputStream os = new FileOutputStream(outputFile);

    ITextRenderer renderer = new ITextRenderer();
    renderer.setDocument(url);
    renderer.layout();
    renderer.createPDF(os);

    os.close();
}
}

Aug 29, 2013, 8:41 PM
14 Posts
convert .xsp page in pdf

First, it seems you are using an old form of iText. Look at http://itextpdf.com/ for the most recent version. You seem to be importing with "lowagie" which is the basis of my supposition. 

Next, I don't see what line number you are erroring on, but you seem to be trying to use Flying Saucer to convert a rendered webpage to a pdf. Here is a little on that http://www.dayon.nl/content/xhtml-pdf-java-0

My preference (and experience) is that this will generally be fustrating, as what the PDF gets will not always match what you see on a browser - especially with free packages. You will get better results with purchased software, but there are frequently differences between how the browser servers it up and how the PDF rendering engine gets it. I think you will have better success in creating the PDF directly. You can see how to do this here: http://xpages.tv/xtv3.nsf/%24%24OpenDominoDocument.xsp?documentId=F0A8F4D764899C2A88257A05003F3375&action=openDocument

I have blog posts and sample databases http://www.bleedyellow.com/blogs/DominoHerald/entry/pdfs_from_xpages_via_itext_presentation_at_mwlug_2012?lang=en .  You may want to look at some of my other posts on the subject as well. 

Cheers,

Brian


This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal