OK here is the complete code with a file attached.

 

When I execute the following code (where pdf is a Document and img is an
ImgTemplate): 

 

 

        try {

            String parser =
XMLResourceDescriptor.getXMLParserClassName();

            SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);

            String uri = new File(getServletContext().getRealPath("/") +
"svg\\actreflect.svg").toURL().toString();

            SVGDocument page = (SVGDocument) f.createDocument(uri); 

        }

        catch (MalformedURLException e) {

            e.printStackTrace();

        }

        catch (IOException e) {

            e.printStackTrace();

        }

 

 

            Element svg = doc.getDocumentElement();

 

            Attr viewBoxAttr = doc.createAttribute("viewBox");

             viewBoxAttr.setNodeValue("-750 -850 1500 1700");

             svg.setAttributeNode(viewBoxAttr);

 

Attr widthAttr = doc.createAttributeNS("http://www.w3.org/2000/svg";,
"width");

            Attr heightAttr =
doc.createAttributeNS("http://www.w3.org/2000/svg";, "height");

            widthAttr.setNodeValue("2000");

            heightAttr.setNodeValue("2000");

            svg.setAttributeNodeNS(widthAttr);

            svg.setAttributeNodeNS(heightAttr);

 

 

            com.lowagie.text.Document pdf = new
com.lowagie.text.Document();

            PdfWriter wr = PdfWriter.getInstance(pdf, out);

            pdf.open()

 

            float width = PageSize.LEGAL.width();

            float height = PageSize.LEGAL.height();

            PdfContentByte cb = wr.getDirectContent();

            PdfTemplate template = cb.createTemplate(width, height);

            Graphics2D g2 = template.createGraphics(width, height);

           

            PageFormat pageFormat = new PageFormat();

            Paper paper= new Paper();

            paper.setSize(width, height);

            paper.setImageableArea(0, 0, width, height);

            pageFormat.setPaper(paper);

                   

            PrintTranscoder printTranscoder = new PrintTranscoder();

 
printTranscoder.addTranscodingHint(PrintTranscoder.KEY_HEIGHT, new
Float(1001));

 
printTranscoder.addTranscodingHint(PrintTranscoder.KEY_WIDTH, new
Float(1001));

            TranscoderInput transcoder = new TranscoderInput(page);

            printTranscoder.transcode(transcoder, null);

            printTranscoder.print(g2, pageFormat, 0);

            g2.dispose();

    

            ImgTemplate img = new ImgTemplate(template);

            img.setAlignment(Image.ALIGN_CENTER);

            

            pdf.newPage();

            pdf.setMargins(0, 0, 150, 150);

            PdfPTable table = new PdfPTable(1);

            table.setWidthPercentage(100f);

            PdfPCell cell = new PdfPCell(img, true);

            cell.setPadding(0f);

            table.addCell(cell);

            pdf.add(table);

 

I get the border of what I presume is the table and my image is present
but cut-off on the right side about 2/3 of the way from the left border.
I've tried fiddling with column width, page margins, the viewbox of my
image, padding, etc. but my image is always cut-off.  I want the image
to be centered within the cell and the cell to be centered within the
table.  What could this be?

 

Regards,

Eric Hamacher

 

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

THIS EMAIL IS INTENDED ONLY FOR THE REVIEW OF THE ADDRESSEE(S), AND MAY
CONTAIN CONFIDENTIAL AND LEGALLY PRIVILEGED INFORMATION. INTERCEPTION,
COPYING, DISSEMINATION, OR OTHER USE BY OTHER THAN THE ADDRESSEE(S) IS
PROHIBITED AND MAY BE PENALIZED UNDER APPLICABLE PRIVACY LAWS. IF YOU
RECEIVED THIS EMAIL IN ERROR, PLEASE DELETE IT AND NOTIFY ME BY RETURN
EMAIL TO [EMAIL PROTECTED] *******************************

 

Attachment: actreflect.svg
Description: actreflect.svg

-------------------------------------------------------------------------
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