0

Display Tif Image

asked 2008-08-28 09:03:46 +0800

DEEP gravatar image DEEP
34

How can i show a tiff File in Image object/Control

delete flag offensive retag edit

2 Replies

Sort by ยป oldest newest

answered 2008-08-28 09:24:31 +0800

sousa1981 gravatar image sousa1981
573 4

updated 2008-08-28 09:54:54 +0800

For example to show pdf (is same to show file like an image jpg, gif, tiff, etc):


if (file.equalsIgnoreCase("PDF")) {
	showPDF(file);
} else {
	Filedownload fd = new Filedownload();
	fd.save(file, content_type, file_name);
}

where my showPDF is an function
        public void showPDF(byte[] pdf) {
		try {
			Window showpdfWnd = (Window) Executions.createComponents("showpdf.zul", null, null);
			showpdfWnd.setParent(getWnd());

			Iframe iframePdf = (Iframe) showpdfWnd.getFellow("iframePdf");
			AMedia media = new AMedia("APP NAME", "pdf", "application/pdf", pdf);
			iframePdf.setContent(media);

			showpdfWnd.doModal()
		} catch (Exception e) {
			//
		}
	}

// showpdf.zul
<?xml version="1.0" encoding="utf-8"?>

<window id="showpdfWnd" width="95%" height="550px" border="normal"
	title="APP NAME" xmlns:h="http://www.w3.org/1999/xhtml"
	xmlns:zk="http://www.zkoss.org/2005/zul"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.zkoss.org/2005/zul http://www.zkoss.org/2005/zul/zul.xsd"
	closable="true">
	
	<zk:iframe id="iframePdf" width="100%" height="100%" />

</window>


link publish delete flag offensive edit

answered 2017-02-23 20:59:28 +0800

JhovannySuarez gravatar image JhovannySuarez
1 1

Hello. Is late, but I was faced to the same problem and after searching a lot, I saw that there isn't good examples about this problem and I had to read until to find a solution that I wante sharing for the next developer that get the same problem

In the ZUL Page

<image content="@load(vm.bufferImg)"/>

The "image" ZK component supports "BufferedImage" objects, so you should pass your ".tiff" file to an "BufferedImage" object. this snippet of code works for that.

    bufferImg = tiffToImage(myTifFile);

public BufferedImage tiffToImage(File file) throws IOException{
    FileSeekableStream stream = null;
    try {
        stream = new FileSeekableStream(file);
        ParameterBlock params = new ParameterBlock();
        params.add(stream);

        RenderedOp image1 = JAI.create("tiff", params);
        return image1.getAsBufferedImage();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } finally{
        if(stream != null)
            stream.close();
    }
    return null;
}
link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2008-08-28 09:03:46 +0800

Seen: 343 times

Last updated: Feb 24 '17

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More