Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am using the itext and xmlworker for creating the pdf form xml/html for that i am using code below

public class XmlWorkerEx implements TagProcessor{
    public static void main(String[] args) throws IOException, DocumentException{
        Document document = new Document();
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("result.pdf"));
        document.open();
        HtmlPipelineContext htmlContext = new HtmlPipelineContext(null);
        htmlContext.setTagFactory(Tags.getHtmlTagProcessorFactory());
        CSSResolver cssResolver = XMLWorkerHelper.getInstance().getDefaultCssResolver(true);
        Pipeline<?> pipeline = new CssResolverPipeline(cssResolver, new HtmlPipeline(htmlContext,new PdfWriterPipeline(document, writer)));
        XMLWorker worker = new XMLWorker(pipeline, true);
        XMLParser p = new XMLParser(worker);
        p.parse(new FileInputStream("form.html"));
        document.close();

    }

and my html

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN">
<html>
<head>
    <style type="text/css">
         .name{ font: 16px georgia ; }
         .fl{float:left;width:100%; font: 16px georgia; }
        .message {margin: 15px 0;width:500px;}
        .sign span{ margin-top:5px; }
    </style>
</head>
<body>
    <div  id="firstname"> Firstname ,</div> 
    <div class="message fl">
            <P> Firstname is informed that This exemption is in accordance with Title 45 of the Code of Federal Regulations Part
            46.102 (d) “a systematic investigation, including research development, testing, and evaluation, </p>
    </div> 

</body>
</html>

now i want to change the content of the div with the id firstname ... how to do that ?

share|improve this question
    
That may be possible, but it's too much work for somebody here to answer that question. It would be easier if you had something like <div><firstname>,</div> instead of <div id="firstname">Firstname,</div>. This sounds very much like a consultancy question; I'm not sure if it's eligible as a question for SO. –  Bruno Lowagie Jun 13 '13 at 14:46
    
I meant <firstname /> and as for the example: I'm writing a book that will be available for free. That's afulltime job. I don't have the energy to offer free consultancy on top of writing that free book. So please find out how to create a custom TagProcessor and how to add it to the TagFactory yourself. Please post that example here yourself. If you're even worn out from your dayjob as I am now, you can always contact paid support at iText Software and they'll help you out if you have a support contract. –  Bruno Lowagie Jun 13 '13 at 16:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.