Examples of RtfExternalGraphic


Examples of org.apache.fop.render.rtf.rtflib.rtfdoc.RtfExternalGraphic

        p.newLineBreak();
        p.newLineBreak();
        p.newLineBreak();
        p.newText ("EMF image with 150 % height");
        p.newLineBreak();
        RtfExternalGraphic imageA = p.newImage ();
        imageA.setURL (file + "emf");
        imageA.setHeight ("150%");
        p.newLineBreak();
        p.close();

        p = sect.newParagraph();
        p.newLineBreak();
        p.newText ("PNG image with 150 % width");
        p.newLineBreak();
        RtfExternalGraphic imageB = sect.newImage ();
        imageB.setURL (file + "png");
        imageB.setWidth ("150%");
        p.newLineBreak();
        p.close();

        p = sect.newParagraph();
        p.newLineBreak();
        p.newLineBreak();
        p.newText ("JPG image with width = 200px and height = 20 px");
        p.newLineBreak();
        RtfExternalGraphic imageC = sect.newImage ();
        imageC.setURL (file + "jpg");
        imageC.setWidth ("200");
        imageC.setHeight ("20");
        p.newLineBreak();
        p.close();

        p = sect.newParagraph();
        p.newLineBreak();
        p.newLineBreak();
        p.newText ("GIF image with width = 200px and scaling = 'uniform', that means the image "
                + "size will adjusted automatically");
        p.newLineBreak();
        RtfExternalGraphic imageD = sect.newImage ();
        imageD.setURL (file + "gif");
        imageD.setWidth ("200");
        imageD.setScaling ("uniform");
        p.newLineBreak();
        p.close();

        p = sect.newParagraph();
        p.newLineBreak();
        p.newLineBreak();
        p.newText ("GIF image");
        p.newLineBreak();
        RtfExternalGraphic imageE = sect.newImage ();
        imageE.setURL (file + "gif");
        p.newLineBreak();
        p.close();

    }
View Full Code Here

Examples of org.apache.fop.render.rtf.rtflib.rtfdoc.RtfExternalGraphic

     * Inserts an image.
     * @return inserted image
     * @throws IOException for I/O problems
     */
    public RtfExternalGraphic newImage() throws IOException {
        return new RtfExternalGraphic(this, writer);
    }
View Full Code Here

Examples of org.apache.fop.render.rtf.rtflib.rtfdoc.RtfExternalGraphic

            final IRtfTextrunContainer c
                = (IRtfTextrunContainer)builderContext.getContainer(
                    IRtfTextrunContainer.class, true, this);

            final RtfExternalGraphic newGraphic = c.getTextrun().newImage();
   
            //set URL
            newGraphic.setURL(url);
            newGraphic.setImageData(rawData);

            //set scaling
            if (eg.getScaling() == Constants.EN_UNIFORM) {
                newGraphic.setScaling ("uniform");
            }

            //get width
            int width = 0;
            if (eg.getWidth().getEnum() == Constants.EN_AUTO) {
                width = fopimage.getIntrinsicWidth();
            } else {
                width = eg.getWidth().getValue();
            }

            //get height
            int height = 0;
            if (eg.getWidth().getEnum() == Constants.EN_AUTO) {
                height = fopimage.getIntrinsicHeight();
            } else {
                height = eg.getHeight().getValue();
            }

            //get content-width
            int contentwidth = 0;
            if (eg.getContentWidth().getEnum()
                    == Constants.EN_AUTO) {
                contentwidth = fopimage.getIntrinsicWidth();
            } else if (eg.getContentWidth().getEnum()
                    == Constants.EN_SCALE_TO_FIT) {
                contentwidth = width;
            } else {
                //TODO: check, if the value is a percent value
                contentwidth = eg.getContentWidth().getValue();
            }

            //get content-width
            int contentheight = 0;
            if (eg.getContentHeight().getEnum()
                    == Constants.EN_AUTO) {

                contentheight = fopimage.getIntrinsicHeight();

            } else if (eg.getContentHeight().getEnum()
                    == Constants.EN_SCALE_TO_FIT) {

                contentheight = height;
            } else {
                //TODO: check, if the value is a percent value
                contentheight = eg.getContentHeight().getValue();
            }

            //set width in rtf
            //newGraphic.setWidth((long) (contentwidth / 1000f) + "pt");
            newGraphic.setWidth((long) (contentwidth / 50f) + "twips");

            //set height in rtf
            //newGraphic.setHeight((long) (contentheight / 1000f) + "pt");
            newGraphic.setHeight((long) (contentheight / 50f) + "twips");

            //TODO: make this configurable:
            //      int compression = m_context.m_options.getRtfExternalGraphicCompressionRate ();
            int compression = 0;
            if (compression != 0) {
                if (!newGraphic.setCompressionRate(compression)) {
                    log.warn("The compression rate " + compression
                        + " is invalid. The value has to be between 1 and 100 %.");
                }
            }
        } catch (Exception e) {
View Full Code Here

Examples of org.apache.fop.render.rtf.rtflib.rtfdoc.RtfExternalGraphic

           new RtfBookmark(this, writer, id);
       }
    }
   
    public RtfExternalGraphic newImage() throws IOException {
        return new RtfExternalGraphic(this, writer);
    }
View Full Code Here

Examples of org.apache.fop.render.rtf.rtflib.rtfdoc.RtfExternalGraphic

        p.newLineBreak();
        p.newLineBreak();
        p.newLineBreak();
        p.newText ("EMF image with 150 % height");
        p.newLineBreak();
        RtfExternalGraphic imageA = p.newImage ();
        imageA.setURL (file + "emf");
        imageA.setHeight ("150%");
        p.newLineBreak();
        p.close();

        p = sect.newParagraph();
        p.newLineBreak();
        p.newText ("PNG image with 150 % width");
        p.newLineBreak();
        RtfExternalGraphic imageB = sect.newImage ();
        imageB.setURL (file + "png");
        imageB.setWidth ("150%");
        p.newLineBreak();
        p.close();

        p = sect.newParagraph();
        p.newLineBreak();
        p.newLineBreak();
        p.newText ("JPG image with width = 200px and height = 20 px");
        p.newLineBreak();
        RtfExternalGraphic imageC = sect.newImage ();
        imageC.setURL (file + "jpg");
        imageC.setWidth ("200");
        imageC.setHeight ("20");
        p.newLineBreak();
        p.close();

        p = sect.newParagraph();
        p.newLineBreak();
        p.newLineBreak();
        p.newText ("GIF image with width = 200px and scaling = 'uniform', that means the image "
                + "size will adjusted automatically");
        p.newLineBreak();
        RtfExternalGraphic imageD = sect.newImage ();
        imageD.setURL (file + "gif");
        imageD.setWidth ("200");
        imageD.setScaling ("uniform");
        p.newLineBreak();
        p.close();

        p = sect.newParagraph();
        p.newLineBreak();
        p.newLineBreak();
        p.newText ("GIF image");
        p.newLineBreak();
        RtfExternalGraphic imageE = sect.newImage ();
        imageE.setURL (file + "gif");
        p.newLineBreak();
        p.close();

    }
View Full Code Here

Examples of org.apache.fop.render.rtf.rtflib.rtfdoc.RtfExternalGraphic

            final IRtfTextrunContainer c
                = (IRtfTextrunContainer)builderContext.getContainer(
                    IRtfTextrunContainer.class, true, this);

            final RtfExternalGraphic newGraphic = c.getTextrun().newImage();
   
            //set URL
            newGraphic.setURL(url);
            newGraphic.setImageData(rawData);

            //set scaling
            if (eg.getScaling() == Constants.EN_UNIFORM) {
                newGraphic.setScaling ("uniform");
            }

            //get width
            int width = 0;
            if (eg.getWidth().getEnum() == Constants.EN_AUTO) {
                width = fopimage.getIntrinsicWidth();
            } else {
                width = eg.getWidth().getValue();
            }

            //get height
            int height = 0;
            if (eg.getWidth().getEnum() == Constants.EN_AUTO) {
                height = fopimage.getIntrinsicHeight();
            } else {
                height = eg.getHeight().getValue();
            }

            //get content-width
            int contentwidth = 0;
            if (eg.getContentWidth().getEnum()
                    == Constants.EN_AUTO) {
                contentwidth = fopimage.getIntrinsicWidth();
            } else if (eg.getContentWidth().getEnum()
                    == Constants.EN_SCALE_TO_FIT) {
                contentwidth = width;
            } else {
                //TODO: check, if the value is a percent value
                contentwidth = eg.getContentWidth().getValue();
            }

            //get content-width
            int contentheight = 0;
            if (eg.getContentHeight().getEnum()
                    == Constants.EN_AUTO) {

                contentheight = fopimage.getIntrinsicHeight();

            } else if (eg.getContentHeight().getEnum()
                    == Constants.EN_SCALE_TO_FIT) {

                contentheight = height;
            } else {
                //TODO: check, if the value is a percent value
                contentheight = eg.getContentHeight().getValue();
            }

            //set width in rtf
            //newGraphic.setWidth((long) (contentwidth / 1000f) + "pt");
            newGraphic.setWidth((long) (contentwidth / 50f) + "twips");

            //set height in rtf
            //newGraphic.setHeight((long) (contentheight / 1000f) + "pt");
            newGraphic.setHeight((long) (contentheight / 50f) + "twips");

            //TODO: make this configurable:
            //      int compression = m_context.m_options.getRtfExternalGraphicCompressionRate ();
            int compression = 0;
            if (compression != 0) {
                if (!newGraphic.setCompressionRate(compression)) {
                    log.warn("The compression rate " + compression
                        + " is invalid. The value has to be between 1 and 100 %.");
                }
            }
        } catch (Exception e) {
View Full Code Here

Examples of org.apache.fop.render.rtf.rtflib.rtfdoc.RtfExternalGraphic

            final IRtfTextrunContainer c
                = (IRtfTextrunContainer)builderContext.getContainer(
                    IRtfTextrunContainer.class, true, this);

            final RtfExternalGraphic newGraphic = c.getTextrun().newImage();

            //set URL
            String url = eg.getURL();
            newGraphic.setURL(url);

            //set image data
            ImageFactory fact = ImageFactory.getInstance();
            FopImage fopimage = fact.getImage(url, eg.getUserAgent());
            fopimage.load(FopImage.ORIGINAL_DATA);

            newGraphic.setImageData(fopimage.getRessourceBytes());

            //set scaling
            if (eg.getScaling() == Constants.EN_UNIFORM) {
                newGraphic.setScaling ("uniform");
            }

            //get width
            int width = 0;
            if (eg.getWidth().getEnum() == Constants.EN_AUTO) {
                width = fopimage.getIntrinsicWidth();
            } else {
                width = eg.getWidth().getValue();
            }

            //get height
            int height = 0;
            if (eg.getWidth().getEnum() == Constants.EN_AUTO) {
                height = fopimage.getIntrinsicHeight();
            } else {
                height = eg.getHeight().getValue();
            }

            //get content-width
            int contentwidth = 0;
            if (eg.getContentWidth().getEnum()
                    == Constants.EN_AUTO) {
                contentwidth = fopimage.getIntrinsicWidth();
            } else if (eg.getContentWidth().getEnum()
                    == Constants.EN_SCALE_TO_FIT) {
                contentwidth = width;
            } else {
                //TODO: check, if the value is a percent value
                contentwidth = eg.getContentWidth().getValue();
            }

            //get content-width
            int contentheight = 0;
            if (eg.getContentHeight().getEnum()
                    == Constants.EN_AUTO) {

                contentheight = fopimage.getIntrinsicHeight();

            } else if (eg.getContentHeight().getEnum()
                    == Constants.EN_SCALE_TO_FIT) {

                contentheight = height;
            } else {
                //TODO: check, if the value is a percent value
                contentheight = eg.getContentHeight().getValue();
            }

            //set width in rtf
            newGraphic.setWidth((long) (contentwidth / 1000f) + "pt");

            //set height in rtf
            newGraphic.setHeight((long) (contentheight / 1000f) + "pt");

            //TODO: make this configurable:
            //      int compression = m_context.m_options.getRtfExternalGraphicCompressionRate ();
            int compression = 0;
            if (compression != 0) {
                if (!newGraphic.setCompressionRate(compression)) {
                    log.warn("The compression rate " + compression
                        + " is invalid. The value has to be between 1 and 100 %.");
                }
            }
        } catch (Exception e) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.