• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!
Collapse

You are not logged in or you do not have permission to access this page. This could be due to one of several reasons:

  • You are not logged in. If you are already registered, fill in the form below to log in, or follow the "Sign Up" link to register a new account.
  • You may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
  • If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.

Previously on "HTML to PDF java lib"

Collapse

  • minestrone
    replied
    Eventually got round to getting a test harness working with iText using the XMLworker add on.

    And if I post it here from clientCo I can pick it up tonight and stick it into Plan B

    Cheers

    Code:
    import java.io.ByteArrayInputStream;
    import java.io.ByteArrayOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    
    import com.itextpdf.text.Document;
    import com.itextpdf.text.DocumentException;
    import com.itextpdf.text.pdf.PdfWriter;
    import com.itextpdf.tool.xml.XMLWorkerHelper;
    
    /**
     * 
     * @author XXXX
     *
     */
    public class Test {
    
    	/**
    	 * 
    	 * @param args
    	 * @throws IOException
    	 * @throws DocumentException
    	 */
    	public static void main(String[] args) throws IOException,
    			DocumentException {
    
    		Document document = new Document();
    		ByteArrayOutputStream baos = new ByteArrayOutputStream();
    		PdfWriter writer = PdfWriter.getInstance(document, baos);
    
    		document.open();
    
    		String text = new String( "<html><head></head><body>" +
    				                  "<h1>Title</h1><p>Paragraph</p>" +
    				                  "</body></html>");
    
    		InputStream inputHtmlAsStream = new ByteArrayInputStream(text
    				.getBytes("UTF-8"));
    
    		XMLWorkerHelper.getInstance().parseXHtml(writer, document,
    				inputHtmlAsStream, null);
    
    		document.close();
    
    
    		System.out.println(baos.toString());
    
    	}
    }

    Leave a comment:


  • minestrone
    replied
    Actually I text looks pretty alright, might give that a whirl today.

    Leave a comment:


  • minestrone
    replied
    I have been running around all week, 14 hour days just now. This was going to be a saturday job.

    I'm going to try the apache fop first off, i seem to remeber using that round about 2003. I have used jtidy so it seems a resonable fit, and I don't want to pay. The transform does not do tables but I can live with that.

    Leave a comment:


  • adubya
    replied
    The OP seems to be ignoring all these helpful suggestions, perhaps we shouldn't bother next time

    Leave a comment:


  • eek
    replied
    Originally posted by minestrone View Post
    I have to do a print friendly PDF for a set of dynamic HTML pages. Have done this in the past but not for many years so I am out the loop.

    I am wanting to trap the request, pick up the HTML from the DB, pass it to a library which will sort out wrapping and such like then push the created PDF down the reponse pipe to a pop up.

    Anyone know of anything that will handle this? Does not have to be anything fancy, cheap and easy are the watchwords on this job (just like my tarts).

    Cheers
    itextpdf is the tool I always seem to end up with for doing this stuff. The commercial rates are high tho if you need to give it to others (LGPL licence).

    The other option is pd4ml which is 100 euros or so.

    Leave a comment:


  • someone23
    replied
    HTML to PDF

    Originally posted by minestrone View Post
    I have to do a print friendly PDF for a set of dynamic HTML pages. Have done this in the past but not for many years so I am out the loop.

    I am wanting to trap the request, pick up the HTML from the DB, pass it to a library which will sort out wrapping and such like then push the created PDF down the reponse pipe to a pop up.

    Anyone know of anything that will handle this? Does not have to be anything fancy, cheap and easy are the watchwords on this job (just like my tarts).

    Cheers
    You can convert HTML to PDF using the web service DocRaptor.com. They can also convert xml to excel, though I'm not sure that'll be useful for you. They have a bunch of examples in various languages that you might be able to use.

    Leave a comment:


  • adubya
    replied
    Apache FOP ?

    Will need a bit of work converting HTML to a suitable input format for the FOP processor :-

    HowTo/HtmlToPdf - Xmlgraphics-fop Wiki

    Leave a comment:


  • minestrone
    started a topic HTML to PDF java lib

    HTML to PDF java lib

    I have to do a print friendly PDF for a set of dynamic HTML pages. Have done this in the past but not for many years so I am out the loop.

    I am wanting to trap the request, pick up the HTML from the DB, pass it to a library which will sort out wrapping and such like then push the created PDF down the reponse pipe to a pop up.

    Anyone know of anything that will handle this? Does not have to be anything fancy, cheap and easy are the watchwords on this job (just like my tarts).

    Cheers

Working...
X