Hello,

does somebody ever tried to set a svg as a list bullet?
Further has somebody ever tried to add a svg to a chunk?

So I tried to do this but I was not very successful, maybe somebody has an 
idea to do this well.

Here is the code which I has modified from the examples.
Thanks a lot.
Best Regards

Markus


---------------


package com.lowagie.examples.objects;

import java.awt.Graphics2D;

import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.awt.image.renderable.RenderableImage;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

import org.apache.batik.transcoder.TranscoderInput;
import org.apache.batik.transcoder.print.PrintTranscoder;

import com.lowagie.text.Chunk;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Font;
import com.lowagie.text.FontFactory;
import com.lowagie.text.Image;
import com.lowagie.text.List;
import com.lowagie.text.ListItem;
import com.lowagie.text.Paragraph;
import com.lowagie.text.html.HtmlWriter;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfTemplate;
import com.lowagie.text.pdf.PdfWriter;

/**
 * Demonstrates some List functionality.
 * 
 * @author blowagie
 */

public class Lists {

 /**
  * Demonstrates some List functionality.
  * 
  * @param args no arguments needed here
  */
 public static void main(String[] args) {

  System.out.println("the List object");

  // step 1: creation of a document-object
  Document document = new Document();
  try {
            // step 2:
            PdfWriter.getInstance(document, new 
FileOutputStream("c:\\lists.pdf"));
            HtmlWriter.getInstance(document, new 
FileOutputStream("c:\\lists.html"));
            
            // step 3: we open the document
            document.open();
            
            // step 4:
            List list = new List(true, 20);
            list.add(new ListItem("First line"));
            list.add(new ListItem("The second line is longer to see what 
happens once the end of the line is reached. Will it start on a new line?"));
            list.add(new ListItem("Third line"));
            document.add(list);
            
            document.add(new Paragraph("some books I really like:"));
            ListItem listItem;
            list = new List(true, 15);
            listItem = new ListItem("When Harlie was one", 
FontFactory.getFont(FontFactory.TIMES_ROMAN, 12));
            listItem.add(new Chunk(" by David Gerrold", 
FontFactory.getFont(FontFactory.TIMES_ROMAN, 11, Font.ITALIC)));
            list.add(listItem);
            listItem = new ListItem("The World according to Garp", 
FontFactory.getFont(FontFactory.TIMES_ROMAN, 12));
            
            
            Image img2; // = Image.getInstance("c:\\punkt_gruen_plus.png");
           img2 = svgToImg("c:\\punkt_gruen_plus.svg");
            
            
            
            Chunk ck = new Chunk(img2, 0, 5/2, false);
   listItem.setListSymbol(ck );
            listItem.add(new Chunk(" by John Irving", 
FontFactory.getFont(FontFactory.TIMES_ROMAN, 11, Font.ITALIC)));
            list.add(listItem);
            listItem = new ListItem("Decamerone", 
FontFactory.getFont(FontFactory.TIMES_ROMAN, 12));
            listItem.add(new Chunk(" by Giovanni Boccaccio", 
FontFactory.getFont(FontFactory.TIMES_ROMAN, 11, Font.ITALIC)));
            list.add(listItem);
            document.add(list);
            
            Paragraph paragraph = new Paragraph("some movies I really like:");
            list = new List(false, 10);
            list.add("Wild At Heart");
            list.add("Casablanca");
            list.add("When Harry met Sally");
            list.add("True Romance");
            list.add("Le mari de la coiffeuse");
            paragraph.add(list);
            document.add(paragraph);
            
            document.add(new Paragraph("Some authors I really like:"));
            list = new List(false, 20);
            list.setListSymbol(new Chunk("\u2022", 
FontFactory.getFont(FontFactory.HELVETICA, 20, Font.BOLD)));
            listItem = new ListItem("Isaac Asimov");
            list.add(listItem);
            List sublist;
            sublist = new List(false, true, 10);
            sublist.setListSymbol(new Chunk("", 
FontFactory.getFont(FontFactory.HELVETICA, 8)));
            sublist.add("The Foundation Trilogy");
            sublist.add("The Complete Robot");
            sublist.add("Caves of Steel");
            sublist.add("The Naked Sun");
            list.add(sublist);
            listItem = new ListItem("John Irving");
            list.add(listItem);
            sublist = new List(false, true, 10);
            sublist.setFirst('a');
            sublist.setListSymbol(new Chunk("", 
FontFactory.getFont(FontFactory.HELVETICA, 8)));
            sublist.add("The World according to Garp");
            sublist.add("Hotel New Hampshire");
            sublist.add("A prayer for Owen Meany");
            sublist.add("Widow for a year");
            list.add(sublist);
            listItem = new ListItem("Kurt Vonnegut");
            list.add(listItem);
            sublist = new List(false, true, 10);
            sublist.setListSymbol(new Chunk("", 
FontFactory.getFont(FontFactory.HELVETICA, 8)));
            sublist.add("Slaughterhouse 5");
            sublist.add("Welcome to the Monkey House");
            sublist.add("The great pianola");
            sublist.add("Galapagos");
            list.add(sublist);
            document.add(list);
  } catch (DocumentException de) {
   System.err.println(de.getMessage());
  } catch (IOException ioe) {
   System.err.println(ioe.getMessage());
  }

  // step 5: we close the document
  document.close();
 }

 private static Image svgToImg(String string) {

        int width = 5;
        int height = 5;
        PdfContentByte cb = null;
           
        PdfTemplate template = cb.createTemplate(width,height);         
        Graphics2D g2 = template.createGraphics(width,height);          
               
        PrintTranscoder prm = new PrintTranscoder();
        TranscoderInput ti = new TranscoderInput("file:///c:/neu.svg");
        
        prm.transcode(ti, null);
         AffineTransform arg1;
  RenderableImage arg0;
  Image image = new Image();
        
        

        g2.dispose(); 
        
  return image;
 }
}
------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to