xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vyang <vy...@apt-cafm.com>
Subject PDFTranscoder Text Opacity & Transcoding Hints
Date Fri, 03 Apr 2009 20:12:06 GMT

Hello,

I"m not sure if this should be posted in fop forums but I'm trying to
convert an svg document from jsvgcanvas to pdf.  I'm using the PDFTranscoder
and I'm having two problems.  The first one is that I use addTranscodingHint
and add KEY_WIDTH, KEY_HEIGHT, AND KEY_AOI to the PDFTranscoder I get this
exception:

Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Requested
array size exceeds VM limit

Without it the hints it seems to work fine.  My second problem is that if my
text elements have a set opacity of probably less than 1 then those text
becomes all fuzzy.  It seems like those are not considered as text elements
because in the pdf I can't used the text select tool to select those texts
that have an opacity less than 1.  I'm using bakik 1.6 and fop .95.  My code
is as follows:

public void convertToPDFTest() throws FileNotFoundException{
        JFileChooser jfc = new JFileChooser();
        jfc.setFileFilter(GUIUtilities.getPDFFileFilter());
        
        File file = new File("c:/my documents/" +
getDrawing().getDrawingName() + ".pdf");
        jfc.setSelectedFile(file);
        int choice = jfc.showSaveDialog(this);
        
        if (choice != JFileChooser.APPROVE_OPTION)
            return;
        
        String absPath = jfc.getSelectedFile().getAbsolutePath();
        int index = jfc.getSelectedFile().getName().lastIndexOf(".");
        String nameSub = jfc.getSelectedFile().getName().substring(0,
index);
        
        if (nameSub.contains("."))
            nameSub = nameSub.replace(".", "");
        
        nameSub = nameSub + ".pdf";
        
        int nameIndex = absPath.indexOf(jfc.getSelectedFile().getName());
        String absPathSub =
jfc.getSelectedFile().getAbsolutePath().substring(0, nameIndex);
        absPath = absPathSub + nameSub;
        
        //VPY - make a clone of SVGDocuemnt
        SVGDocument tempSVGDocument =
(SVGDocument)drawing.getSVGDocument().cloneNode(true);
        
//        SVGDocument tempSVGDocument = drawing.getSVGDocument();
        
        createAoiRect();
        
        Transcoder pdfTranscoder = new PDFTranscoder();
//       
pdfTranscoder.addTranscodingHint(XMLAbstractTranscoder.KEY_XML_PARSER_VALIDATING,
Boolean.FALSE);
//        pdfTranscoder.addTranscodingHint(PDFTranscoder.KEY_STROKE_TEXT,
Boolean.FALSE);
//        final TranscoderInput transcoderInput = new
TranscoderInput(tempSVGDocument);
        
//        OutputStream out = new FileOutputStream(absPath);
//        out = new BufferedOutputStream(out);
//        final TranscoderOutput transcoderOutput = new
TranscoderOutput(out);
        
        for (int p = 0; p < printNum; p++) {
            Rectangle tempAoiRect = new Rectangle();
            tempAoiRect = (Rectangle)aoiRect.get(p);
            
            float tempWidth = (float)tempAoiRect.getWidth();
            float tempHeight = (float)tempAoiRect.getHeight();
            
//            pdfTranscoder.addTranscodingHint(PDFTranscoder.KEY_WIDTH,
tempWidth);
//            pdfTranscoder.addTranscodingHint(PDFTranscoder.KEY_HEIGHT,
tempHeight);
//            pdfTranscoder.addTranscodingHint(PDFTranscoder.KEY_AOI,
tempAoiRect);
            
            final TranscoderInput transcoderInput = new
TranscoderInput(tempSVGDocument);
            OutputStream out = new FileOutputStream(absPath);
            out = new BufferedOutputStream(out);
            final TranscoderOutput transcoderOutput = new
TranscoderOutput(out);
            
            final Transcoder finalPrintTranscoder = pdfTranscoder;
            final OutputStream finalOut = out;
            
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    try {
                        finalPrintTranscoder.transcode(transcoderInput,
transcoderOutput);
                    } catch (TranscoderException ex) {
                        ex.printStackTrace();
                    } finally {
                        try {
                           
System.out.println("drawingpanel.converttopdftest pdf done");
                            finalOut.close();
                        } catch (IOException ex) {
                            ex.printStackTrace();
                        }
                    }
                }
            });
            
            //clear sprite and resets variables
            if (p == printNum - 1) {
                clearPageSprite();
                pageLayoutDialog.setIsOKClicked(false);
            }
        }
    }

Any help is much appreciated.  Thanks.

vyang
-- 
View this message in context: http://www.nabble.com/PDFTranscoder-Text-Opacity---Transcoding-Hints-tp22874236p22874236.html
Sent from the Batik - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Mime
View raw message