Hi,

I need assistance on how to embed svg (original size) image in to iText
document. Am using below code.

          float width = PageSize.A4.width();
        float height = PageSize.A4.height();
        
        Document document = new Document();
          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          PdfWriter wr = PdfWriter.getInstance(document, baos);
                
        PdfContentByte cb = wr.getDirectContent();
        PdfTemplate template = cb.createTemplate(width, height);
        Graphics2D g2 = template.createGraphics(width, height);
        
        PrintTranscoder printTranscoder = new PrintTranscoder();
        TranscoderInput transcoderInput = new
TranscoderInput("file:///C:/Documents and
Settings/a434865/Desktop/svgOutput.svg");
        
        printTranscoder.transcode(transcoderInput, null);
        
        PageFormat pageFormat = new PageFormat();
        Paper paper= new Paper();
        
        paper.setSize(width, height);
        paper.setImageableArea(0, 0, width, height);
        
        pageFormat.setPaper(paper);
        printTranscoder.print(g2, pageFormat, 0);
        g2.dispose(); 

        ImgTemplate img = new ImgTemplate(template);
        img.setAlignment(Image.DEFAULT);

Above code gets me cropped image (if original is big) or enlarged image
(if original is small), but not of original dimension.

Badly need your assistance. Please reply at your earliest.

Rag Setty

Important:  This e-mail, including any attachment(s) hereto, is intended
only for the individual or entity to whom it is addressed.  It may
contain proprietary, confidential or privileged information or attorney
work product belonging to Fidelity Business Services India Pvt. Ltd.
(FBS India) or its affiliates. If you are not the intended recipient of
this e-mail, or if you have otherwise received this e-mail in error,
please immediately notify the sender via return e-mail and permanently
delete the original mail, any print outs and any copies, including any
attachments. Any dissemination, distribution, alteration or copying of
this e-mail is strictly prohibited. The originator of this e-mail does
not guarantee the security of this message and will not be responsible
for any damages arising from any dissemination, distribution, alteration
or copying of this message and/or any attachments to this message by a
third party or as a result of any virus being passed on.  Any comments
or statements made in this are not necessarily those of FBS India or any
other Fidelity entity.  All e-mails sent from or to FBS India may be
subject to our monitoring and recording procedures.  FBS India is an
Appointed Representative of Fidelity Investments International, which is
authorized and regulated by the United Kingdom Financial Services
Authority. Fidelity Investments International only gives information on
its products and services and does not give investment advice to private
clients based on individual circumstances.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to