How to a copy a tif image to system clipboard and paster in MS Word

import java.awt.image.RenderedImage;
import java.io.IOException;
import javax.media.jai.RenderedImageAdapter;
import util.TIFFFileHelper;
public class ClipboardSupport implements ClipboardOwner{
     public ClipboardSupport() {
          super();
     public static void main(String[] args) throws IOException {
          ClipboardSupport co = new ClipboardSupport();
          RenderedImage img=co.getTestImage();
          co.copyToClipBoard(img);
     private RenderedImage getTestImage() throws IOException{
          TIFFFileHelper th = new TIFFFileHelper("C:/workspace/AV/src/images/onepageSample.tif");
          th.getPageCountParseFirstPage();
          RenderedImage img = th.getFirstPage();
          return img;
     public void copyToClipBoard(RenderedImage img2){
          Image img=this.getCovertedImage(img2);
          this.copyToClipBoard(img);
     public void copyToClipBoard(Image img){
          Toolkit tkt = Toolkit.getDefaultToolkit();
          Clipboard clipboard = tkt.getSystemClipboard();
          Transferable t = new ImageSelection(img);
          clipboard.setContents(t,this);
     public void lostOwnership(Clipboard clipboard, Transferable contents) {
          System.out.println("ClipboardSupport.lostOwnership() called");
     private Image getCovertedImage(RenderedImage img) {
          RenderedImageAdapter aid = new RenderedImageAdapter(img);
          Image im = aid.getAsBufferedImage();
          return im;
package util.clipboard;
import java.awt.Image;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.IOException;
public class ImageSelection implements Transferable {
     private Image img=null;
     DataFlavor dataFlavor = DataFlavor.imageFlavor;
     public ImageSelection(Image img) {
          super();
          this.img=img;
     public DataFlavor[] getTransferDataFlavors() {          
          DataFlavor[] data = new DataFlavor[1];
          data[0]=dataFlavor;
          return data;
     public boolean isDataFlavorSupported(DataFlavor flavor) {          
          if(dataFlavor.equals(flavor)){
               return true;
          }else{
               return false;
     public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
          return img;
}

done.

Similar Messages

  • How can I copy an audio effect from a clip and paste it to another clip in the same timiline...With FCPro 7 it was all so fast........

    how can I copy an audio effect from a clip and paste it to another clip in the same timiline...With FCPro 7 it was all so fast........

    Tom Wolsky wrote:
    The advantage goes to FCP7 if you allow that it can copy and paste filters, audio and video, transformations, and other attributes separately.
    You can do that in FCPX too, as all the things you cited are listed separately in the inspector.
    Here's a little gotcha. Let's say you've color corrected a few clips and you've applied an effect to one and want to paste it the other clips. You switch off color correction and copy the clip. You select the other clips and paste effects. What do you think happens? The effect is applied, but the color correction is applied as well, only it's switched off as it was in the first clip, so all the color correction on the other clips is lost. Fun, eh?
    I'll try to replicate your gotcha - but no, that doesn't sound like fun at all!

  • How do i copy the picture i made on photoshop and paste it on to word

    how do i copy the picture i made on photoshop and paste it on to word

    OK, Now I have word up and running. No edit menu. Poor memory...
    On the home tab at far left side is paste. Just below the paste button is a downward arrow which will give you other options for pasting. By default it will paste as a photoshop object. Which means you can not scale it but double clicking on will let you edit in photoshop. Clicking that downward arrow will let you do a paste special and the following dialog box will pop up.

  • How do I cut out an image from one photo and paste it in another photo?

    Help!  I did use the scissors and eraser tool to cutout unwanted background, and now I have an image I want to save and copy to another photo.  The problem is that Elements 11 won't let me open up another photo at the same time, or let me copy the selected image to clipboard to paste on a different photo.  Adobe's  info. on how to do this seems to be sketchy.

    Try this:
    Open photo B, the one that you want to add an object to. Minimize this.
    Open Photo A, and using one of the selection tools, e.g. selection brush, lasso tool, make a selection of the object that is to be transferred to B. You will see "marching ants" when the selection is complete.
    Go to Edit menu>copy to place the selection on the clipboard
    Go back to photoB
    Go to Edit>paste
    With the move tool, position the object and resize with the corner handles of the bounding box.

  • How can I copy a table from a web file and paste it into a word document on a pc?

    I am having diffculty getting a pdf file from a web document pasted into my word document.  I do no get the option to copy or save as a table.  I can copy and paste the text but I lose the table and the format and just get the text.  Anybody know what I can do to solve this?

    Try holding down the alt key as you mark the text to be copied. You can then copy columns to table text.

  • HowDoI copy a phone number from a contact and paste it into a text

    Z10 HowDoI copy a phone number from a contact and paste it into a text message?
    Help Please. It should be so simple but in the maze of approaches to contacts from the phone or home screen which ever way you get there; how do I select a phone number, copy it and paste it into a text message to another contact so that I can send it on?
    The logic of the interface is totally baffling to me most of the time. Can't there just be one contacts interface so that when you enter it from anywhere it presents the same options to edit etc. Cannot the three blobs be called up to allow a proper edit menu - copy/cut/paste/delete.
    Can the favourites be held permanently in screen at the top with the rest of the contacts scrolling below them?
    Can it be set up so that contact pictures do not show to save screen space?
    Any help on any of these - much appreciated.
    Solved!
    Go to Solution.

    Hey jbee,
    Welcome to the BlackBerry® Support Community Forums.
    How Do I copy a phone number from a contact and paste it into a text message?
    The only option would be to to select the edit option on the contact and hold your finger on the number and select the copy option on the left side panel.
    Can the favorites be held permanently in screen at the top with the rest of the contacts scrolling below them?
    This feature is currently not available. 
    Can it be set up so that contact pictures do not show to save screen space?
    This feature is currently not available.
    Let me know if you have any other questions.
    Thanks.
    -HB
    Come follow your BlackBerry Technical Team on twitter! @BlackBerryHelp
    Be sure to click Kudos! for those who have helped you.Click Solution? for posts that have solved your issue(s)!

  • The float in windows option is grey and not accessable ? How can I copy from one image to another ? Elements 11

    The float all in windows option is grey and not accessible ? How can I copy from one image to another ? Elements 11

    You really are not getting this.
    "I guess I am still completely shocked that as a parent we can't download something for everyone to use."
    Why do you continue to think this although we keep telling you that this is not the case.
    You do NOT have to purchase anything twice.  You can share the music with as many ipods as you like in your household.
    The ipods are designed to sync with your computer regularly.  You should have been syncing these other ipods with your computer all along, thus transferring the purchases to your computer where that music can be synced to as many ipods as you like.
    Take on of the ipods with the music in it.  Open itunes on your computer.  Plug in the ipod.  Do not sync.  Click File>Transfer Purchases  This will transfer the purchases from the ipod to the computer.  Make sure that you have authorized your account on the computer:  here are directions for that. http://support.apple.com/kb/HT1420
    Unplug the ipod.
    Plug in the other ipod with purchased music.  Do not sync.  Click File>Transfer Purchases  This will transfer purchases from the ipod to the computer.
    You can now plug in any of the ipods, select what you want to sync and sync.
    Have a look at the manual for the ipod.  http://manuals.info.apple.com/en_US/iPod_touch_iOS4_User_Guide.pdf

  • How can I copy a web image and paste into iMessages?

    I have recently purchased a new iPhone that uses the iOS7.  Previously, I was able to copy images from the web and paste into iMessages.  When I try this now, all that is pasted is the link.  Is there a way around this?

    When I tap and hold the image, I don't see an option to "Save" it.  I get the following options:
    Open, Open in New Page, Add to Reading Lisa, and Copy.  When I choose "copy and then go to paste it, it just pastes the web link as you mentioned.  Am I missing something?
    (Thanks for your response, by the way)!

  • How can I copy and paste text into Word in Acrobat 9 Pro

    How can I copy and paste text into Word from Acrobat 9 Pro?

    You might find it easier to export the file to Word under File > Export > Word in Acrobat 9.

  • How can I copy part of a larger PDF file and create a smaller one?

    How can I copy part of a larger PDF file and create a smaller one?

    Hi,
    Copy the content of PDF file in Adobe Reader and paset it to MS Word then create PDF file from the Word file.
    This may not work for all PDF files as some PDF files are not created correctly or some content cannot be copied.
    Acrobat XI Pro has features to extract/delete/crop pages in PDF files and you can download it from www.adobe.com(Trial version- 30 days free). Or you can upgrade your subscription to Acrobat Plus and see more information at https://www.acrobat.com/acrobatplus/en/home.html
    Hisami

  • How do i copy text added to a protected pdf and save in word.

    how do I copy text added to a protected pdf and save in word?

    More details would be helpful. What security restrictions are there, exactly? Do you know the password? Do you want to copy all of the text in a document, or just some?

  • How to save a new jpg image from the clipboard

    It seems like it should be simple but I can't find anywhere this has been documented.
    I have an image on the clipboard and simply want to save it as a new image.
    I've been using Image Events and I can get a file saved but it's always empty.
    Can someone please post some sample code to do this?

    I'm sure there's a more elegant way to script this, but here is a script I just wrote real quick that should at least give you a start to an alternate way of dealing with clipboard data without having to launch Preview...
    <pre style="width:630px;height:auto;overflow-x:auto;overflow-y:hidden;"
    title="Copy this code and paste it into your Script Editor application.">--see if clipboard is a file
    set filePath to ""
    try
    set clipPath to the clipboard as «class furl»
    set filePath to clipPath as alias
    end try
    if filePath is not "" then
    set newFile to getFileName("copied")
    do shell script "cp " & quoted form of POSIX path of filePath & ¬
    space & quoted form of POSIX path of newFile
    return --end
    end if
    --see if clipboard is image data
    set jpegDATA to ""
    try
    set jpegDATA to the clipboard as JPEG picture
    end try
    if jpegDATA is not "" then
    set newFile to getFileName("new")
    set theFile to open for access newFile with write permission
    write jpegDATA to theFile
    close access theFile
    return --end
    end if
    beep 1
    display dialog ¬
    "No file or image data found on the clipboard." with icon ¬
    note buttons {"Whatever"} default button 1
    on getFileName(type)
    choose file name with prompt ¬
    "Select a name and location for the " & type & ¬
    " jpeg:" default location (path to desktop) default name ¬
    type & ".jpg"
    end getFileName</pre>
    Hope this helps...

  • Paste Image to System Clipboard

    Hello all...I can't paste an Image to the system clipboard and was wondering if you could help me. Noticed there was some help on this topic with JDK 1.4.1, however I'm using JDK 1.3.1.
    I following code was copied from Sun at http://developer.java.sun.com/developer/Books/GJ21AWT/ch20.pdf
    but I cant get it to work.
    <code>
    //implement the class like this
    ImageSelection is = new ImageSelection(Constants.DRAWINGSLATE.currentImage.pBitmap[dList.ptr].getImage());
    toolkit.getSystemClipboard().setContents(is, null);
    class ImageSelection implements ClipboardOwner, Transferable
    public static DataFlavor ImageFlavor;
    public static DataFlavor ImageArrayFlavor;
    private DataFlavor[] flavors = {ImageFlavor, ImageArrayFlavor};
    private java.awt.Image image;
    private int width, height;
    static
    try
    ImageFlavor = new DataFlavor(Class.forName("java.awt.Image"),"AWT Image");
    ImageArrayFlavor = new DataFlavor("image/gif", "GIF Image");
    catch(Exception e)
    public ImageSelection(Image image)
    this.image = image;
    public ImageSelection(Image image, int width, int height)
    this.image = image;
    this.width = width;
    this.height = height;
    public synchronized DataFlavor[] getTransferDataFlavors()
    return flavors;
    public boolean isDataFlavorSupported(DataFlavor flavor)
    return flavor.equals(ImageFlavor) || flavor.equals(ImageArrayFlavor);
    public synchronized Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException
    if (flavor.equals(ImageFlavor))
    return image;
    if (flavor.equals(ImageArrayFlavor))
    return imageToArray();
    else
    throw new UnsupportedFlavorException(flavor);
    public void lostOwnership(Clipboard c, Transferable t)
    private int[] imageToArray()
    int[] pixels = new int[width*height];
    PixelGrabber pg = new PixelGrabber(image, 0, 0, width, height, pixels, 0 , width);
    try
    pg.grabPixels();
    catch(InterruptedException e)
    e.printStackTrace();
    return pixels;
    </code>
    I get this exception
    Couldn't write data flavor java.awt.datatransfer.DataFlavor[representationclass=java.awt.Image;mimetype=application/x-java-serialized-object] to clipboard:
    java.io.IOException: Transferable's flavor data is of unexpected class com.apple.mrj.internal.awt.graphics.VImage
    Thanks for any help.

    I was trying to use ur code with slight modification
    import java.awt.*;
    import java.awt.datatransfer.*;
    import java.io.*;
    import java.util.*;
    public class Test {
    public static void main (String[] parameters) {
              new Test ().test ();
    private void test () {
    Toolkit.getDefaultToolkit().getSystemClipboard ().setContents (          new mageTransferable ("test.jpg"),
         new ClipboardOwner () {
         public void lostOwnership (                                             Clipboard clipboard,
                             Transferable contents) {}
    private class ImageTransferable implements Transferable {
    private String fileName;
    public ImageTransferable (String fileName) {
    System.out.println(" Checking for the File now");
    if (! new File(fileName).exists ()) {
    throw new IllegalArgumentException ("Can't find image");
    System.out.println(" got the file");
    this.fileName = fileName;
    System.out.println(" returning from constructor");
    public Object getTransferData (DataFlavor flavor) throws UnsupportedFlavorException {
    System.out.println("trying to get the data to be transfered");
    if (! isDataFlavorSupported (flavor)) {
    throw new UnsupportedFlavorException (flavor);
    System.out.println("This is a supported flavor");
    return (Image)Toolkit.getDefaultToolkit().createImage (fileName);
    //               System.out.println(
    public boolean isDataFlavorSupported (DataFlavor flavor) {
    System.out.println("trying to check whether the flavour is supported one");
    DataFlavor[] df= this.getTransferDataFlavors();
    System.out.println(" data flavors " + df);
    boolean result = in(flavor, df);
    return result;
    public DataFlavor[] getTransferDataFlavors () {
    //     "image/x-java-image; class=java.awt.Image"
    DataFlavor df=null;
    System.out.println("trying to get the data flavours");
    df =new DataFlavor("application/x-java-serialized-object; class=java.awt.Image","Image");
    //new DataFlavor("image/x-java-image;class=java.awt.Image","Image");
    System.out.println(" Just going to return & DF found was"+ df);
    DataFlavor[] df2 = new DataFlavor[]{df,DataFlavor.plainTextFlavor,DataFlavor.stringFlavor,DataFlavor.javaFileListFlavor };
    System.out.println(df2.length);
    System.out.println(df2[0]);
    return df2;
    private boolean in (DataFlavor flavor, DataFlavor[] flavors) {
    System.out.println("Im in in");
    int f = 0;
    while ((f < flavors.length) && ! flavor.equals (flavors[f])) {
         f ++;
         System.out.println("Im in in's loop");
    return f < flavors.length;
    But this throws the following exception:
    Exception in thread "main" java.lang.ClassCastException: sun.awt.windows.WImage
    at sun.awt.windows.WDataTransferer.translateTransferable(WDataTransferer
    .java:346)
    at sun.awt.DataTransferer.translateTransferable(DataTransferer.java:245)
    at sun.awt.windows.WClipboard.setContents(WClipboard.java:69)
    at Test.test(Test.java:13)
    at Test.main(Test.java:8)
    Is the dataflavour purely dependent on OS. What can be done to overcome this problem

  • How to make a selection of a layer delete content and paste another content with Photoshop scripting..?

    how to make a selection of a layer delete content and paste another content with Photoshop scripting..?

    There is a more specific Forum …
    Photoshop Scripting

  • Installed 4 today, cannot copy and paste to MS Word

    I get an error message when I try to copy from another site and paste to ms word, then it closes word, I tried it several times with the same result. I never had this problem before installing 4 today.

    Hi Ldxrunner2015
    I would like to know what word processor program are you using?
    Is your W520 managed by company (Domain) or personal?
    When the response is contact the administrator, does it prompt you for password or other credentials?
    Have a nice day! 
    Peter
    W520 (4284-A99)
    Does someone’s post help you? Give them kudos as a reward, as they will do better to improve | Mark it as solved if the solution works for you, so it could be reference for others in the future
    =====================================
    Sound Enthusiast and Enhancement (Post comments, share mixes, etc.)
    Dolby Home Theater v4 ; IdeaPad Slate Tablet

Maybe you are looking for

  • How do I use count for this query?

    How do I display all the addresses in a table that have more than one (or >1) account number? I wasn't sure how or if I should use count along with group by and having to get the expected results.

  • Issue with Auto PO creation

    Hello Gurus, Kindly help me with this issue. I have user who is using ME59 for the auto PO creation.When he runs this transaction with the "TEST RUN" flaged,in the result screen he is able to see a mesasage as "PO creation successfull" along with the

  • Webdynpro - Object could not be found in cache, key is null

    Folks I am getting this marvelous exception for which I am not able to find any not in SAP Service Portal as well. Any insights shared will be highly appreciated. [EXCEPTION] com.sap.tc.webdynpro.services.sal.util.cache.ResourceNotFoundException: Obj

  • Blend does not support display resolution​s higher than 1080p

    I have noticed that blackberry blend does not resize its display to compensate for higher resolutions. In other words, if you open up blend on a windows laptop with a QHD display. The text is going to look really small. Please fix.

  • Converting any date string to GMT standard

    Hi All, I want to convert any date string to GMT standard. The date string may be like this. "Sat Sep 15 14:23:40 IST 2001" I have tried to change my defaultTimeZone . But I don't know why it's not working. Is there something to do with Locals? Can a