Ruby: PDF::Writer can't read JPG or PNG files?

require 'pdf/writer'
pdf = PDF::Writer.new
pdf.image('/home/max/pics/kiwi.png')
Results in:
RuntimeError: Unsupported Image Type
from /home/max/.gem/ruby/1.9.1/gems/pdf-writer-1.1.8/lib/pdf/writer/graphics.rb:668:in `image'
Why?
edit - can't get rid of that mysterious newline in the code snippet ... weird? oh well, you get the idea
Last edited by synthead (2012-08-21 22:48:47)

Hello,
I don't know about this error, but PDF::Writer is unsupported and it is recommended to use  Prawn[1].
Couldn't the problem be that you are using Ruby 1.9.1 and PDF::Writer written for 1.8(just a guess).
Sebastian
[1] http://prawn.majesticseacreature.com/

Similar Messages

  • I can't read a Object from file, Please help me

    i want to write a Object into File. this is code of Object
    class objStoreCus implements Comparable, Serializable
    String customerID = new String();
    String customerName = new String();
    String customerEmail = new String();
    objStoreCus(String cusID, String cusName, String cusEmail)
    customerID = cusID;
    customerName = cusName;
    customerEmail = cusEmail;
    objStoreCus(){}
    public int compareTo(Object o)
    objStoreCus oS = new objStoreCus();
    oS = (objStoreCus)o;
    return(customerEmail.compareTo(oS.customerEmail));
    private void writeObject(ObjectOutputStream s) throws IOException {
    s.defaultWriteObject();
    private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException {
    try
    s.defaultReadObject();
    }catch(IOException ie){throw new IOException();}
    catch(ClassNotFoundException cnt){throw new ClassNotFoundException();}
    And I was wrote above Object into File by this code :+
    FileOutputStream fos;
    ObjectOutputStream oos;
    FileInputStream fis;
    ObjectInputStream ois;
    public void writeObjToFile(objStoreCus obj)
    try
    fos = new FileOutputStream("Exrcise3.ex3", true);
    }catch(FileNotFoundException fnfe){}
    try
    oos = new ObjectOutputStream(fos);
    //ghi doi tuong vao file
    oos.writeObject(obj);
    //dong stream
    oos.close();
    fos.close();
    }catch(IOException ie){}
    But i can't read above Object from file. allway have a Exception occur "StreamCorruptedException".
    this is code read Object form file :
    *parameter is ArrayList will be store Object from file.
    public void readObjFromFile(ArrayList al)
    try
    fis = new FileInputStream("Exrcise3.ex3");
    }catch(FileNotFoundException fnfe){}
    try
    ois = new ObjectInputStream(fis);
    while(true)
    try
    objStoreCus osc = new objStoreCus();
    osc = (objStoreCus)ois.readObject();
    System.out.println(osc.customerEmail);
    }catch(Exception e)
    e.printStackTrace();
    //System.out.println();
    break;
    ois.close();
    fis.close();
    }catch(IOException ie){}
    }

    Problem lies in
    os = new FileOutputStream("Exrcise3.ex3", true);
    You are trying to append to that file, You should always use new file to serialize objects.
    os = new FileOutputStream("Exrcise3.ex3");
    Try with above line.

  • Windows Easy Transfer (WET) Issues with External Hard Drive - "Can't read from the source file or disk"

    I work for Office Depot, in the tech department. Basically, one of our associates was supposed to do a data backup, and re-install Windows 7, then transfer the files back. He used Windows Easy Transfer and compacted everything into a 163 GB file. 
    Now comes the hard part. When we try to put it back on his computer ((drag-and-drop to the desktop) which has been wiped back to factory settings using the recovery partition), it stops at 79.5 GB remaining (you know how it doesn't give you a % of completion,
    it just shows how many GB are remaining) and then says "Can't read from the source file or disk" and gives you an option to try again, or cancel. It gets hung up on the same point each time.
    Normally, this wouldn't be a huge issue, but the contents on the drive are his wife's architect blueprints and interior design stuff, along with wedding photos, etc, which are the only copies they have. On top of those, they have court documents and other
    important files that we are unable to access now.
    I wasn't involved with this transfer, so I'm trying to clean up the mess as best I can. I remembered that the customer's wife was Russian, and had some files typed with a Russian keyboard, so on and so forth. I wonder if that's the issue? If not, I really
    have no idea how to manually extract things from a ".mig" file, or how to diagnose what area is potentially corrupted.
    In light of this situation, we tried using "Recuva" to recover the files post-wipe, but everything was corrupted or unable to be opened, and it also extracted and recovered all of the "useless" photos, such as the skype logos, up and
    down arrows for browsers, etc (it was 160,000+ photos).
    Trying to avoid a potential lawsuit, unhappy customer, and costing the company lots of money to see if professionals can get into this external hard drive.
    Other relevant information:
    We used a Toshiba 500 GB (465 GB) external hard drive.
    Customer's computer is an HP Pavilion P6000 Series (Model No. p6520y) running Windows 7 Home Premium 64-bit Service Pack 1.
    Any other information that is needed can be provided, thanks in advance, and hopefully we can find a solution to this issue quickly!
    -John

    I think there's a lack of understanding somewhere.
    "If you even can't start the process, please unplug it from your new PC. Then head back to your new computer and plug
    the external drive back in to your new computer. "
    Unplug from new, head back to new, plug it back in? That doesn't make much sense! Haha.
    I knew what you meant though, somewhat. When I search through the drives after clicking yes (Has windows easy transfer
    already saved your files blah blah blah) I click on the transfer file and it says "Windows Easy Transfer could not open the file".
    Rather than drag-and-drop the file to the desktop, I now tried to double-click on the file itself while it was plugged
    into the computer. It opened, and it started transferring until it was about 70% completed, and then an error popped up saying "WET can't open the easy transfer file, make sure your USB device is plugged in or check your internet connection". 
    I checked, and the USB hard drive's light wasn't on. Now, I unplug it and plug it back in, and the light comes back on,
    so I click Retry, and it resets the bar back to nothing and says "Transfer time: 1 minute".
    Rather than continue trying, I clicked "Cancel" instead of Retry, and it says "Your transfer did not complete successfully."
    It says to click "view report" for more information, but there's no "view report button".
    At the moment, I am scanning the External Drive for bad sectors using the check disk tool in properties. It's frozen
    at "0 USN bytes processed".

  • How can I read the printer snapshot file printers.xml

    How can I read the printer snapshot file printers.xml

    XML files are typically viewed using a web browser.
    Open the XML file and the default program should open it automatically.  If you are prompted to select a program, use the option that lets you choose a program and brows through the directories for your browser (for example, use Internet Explorer, Firefox, etc.).
    If need be, you should be able to right-click the file and select open with to choose the program to open it with.
    There are other XML viewers out ther, but web browsers are typically the default as XML is a web language.
    ↙-----------How do I give Kudos?| How do I mark a post as Solved? ----------------↓

  • Bought a new camera and Photoshop advises me that it can not read my type of file.. Its canon 7d mark 2 and the extension is CR2.

    Bought a new camera and Photoshop advises me that it can not read my type of file.. Its canon 7d mark 2 and the extension is CR2.

    Hi EddieGerdak,
    The update is available now.
    Release details:
    Lightroom 5.7: http://blogs.adobe.com/lightroomjournal/2014/11/lightroom-5-7-now-available.html
    Camera Raw 5.7: http://blogs.adobe.com/lightroomjournal/2014/11/camera-raw-8-7-and-dng-converter-8-7-now-a vailable.html
    Regards,
    Pete

  • Can't open or save png files

    Hi, I'm very new to fireworks and since I installed it 4
    weeks ago I can't save or open png files. An error message appears
    stating An internal error occurred. I've read through other posts
    and because fonts kept coming up It needed doing anyway, I ran a
    clean install of my os, still no luck. All other file types are
    fine.
    Mac G5 - 10.4.9 running studio 8
    Any help with this would be much appreciated.
    Thanks.

    My OS is 10.4.11. on 2 GHz Intel iMac.
    I reread my orignial post and noticed a typo. I can save png's with PS "save for the web," but can't open those just-saved png files.
    I did lots of things before I noticed that the png wasn't working. Don't know which may have caused a problem. Likely things? Well, I added a plugin for Ico. format. I deleted it because I thought it might have caused the conflict.
    Assuming that was the problem, what can I do to restore the png file format?
    I don't have disk warrior. I did run the maintenance utility yesterday. It runs crons, clears caches, deletes cookies, that kind of stuff.
    I've never had a problem with it disabling plugins or causing any problems. Haven't run disk utility for a few weeks. Would that help?
    I didn't download the replace png plugin from Adobe, but the original wasn't working anyway. I looked for a backup on the exernal drive, didn't find one, and downloaded another.
    Next, I did a Photoshop reinstall thinking that might fix the problem, but it didn't.  Which plugin folder should the png plugin be place in. I've never been sure why there are two format folders;  the folder in plugins, and the folder in Photoshop only.

  • AE CC crash when drag jpg and png files to comp

    Hi I have noticed photoshop exports of jpg and png files cause AE CC to crash when drag these files  to comp Same jpg and png exported from CS6 do not cause crash.

    What exact version of Photoshop CC are you using? 14.0, 14.1, 14.2?
    How are you saving the PNG and JPEG files from Photoshop? File > Save As? Save for Web?
    In After Effects preferences > Media & Disk Cache, is the Create Layer Markers from Footage XMP Metadata option enabled? Does the problem go away if you turn this off?
    A similar problem recently occurred with files generated from Illustrator CC (17.1):
    http://adobe.ly/1jlIykQ
    However, we have no reason to believe the same problem would apply to files generated from Photoshop. I am not able to reproduce your problem with PNG and JPEG files saved from Photoshop CC (14.2), either from Save As or Save for Web. So either the conditions of your problem are more specific, or it is not related to the XMP Metadata problem.

  • Opening JPG or PNG files without using PS

    I want to open simple JPG's without using PS CC.   Previously, I could open JPG's or png files with Apple's Preview; I would like to return to the simple and quick tool of using Preview.
    I have looked and can not seem to find a way to open my JPG or PNG files without using Photoshop.   Can you point me the way to accomplish this?
    Thanks,   Bob

    Joe,
    First, allow me to thank you for your reply.
    Allow me to also explain that I am handicapped and have suffered the effects of five strokes in recent years and then ask for some more help from you.
    When open any JPG image (or png, I think), it automatically opens in Photoshop CC (I also own PS 6).  This is not the desired effect, as I would like to just see the images using Preview, which is the way it used to work (before I acquired the CC application, I believe).
    I quickly tried to open an image using Preview (a PNG screen shot as you suggested), though I at a loss to use 'get info' command as you suggested, nor am I able to see the 'open with' from the drop-down in Preview.  So I have to ask you for more instructions if you can assist me further?
    I live in the Seattle area, if you can call me (I am always at home) at *removed for privacy*.  If you could call me that would be great.  With my impaired communications, I usually can understand verbal information better.
    Thanks again for getting back to me.
    Bob LaBouy

  • How can i read Thai language in file .txt?

    AttN; Whom may concern.
    How can i read file txt in other language (Asian language such as Japanese, Thai, or Korea)?
    Please let me know urgent... I have to use it urgently...
    Best Regards,
    Sae
    Solved!
    Go to Solution.

    Hello Sae,
    Welcome to the Sony Community.
    What is the model number of the Reader Digital Book?
    The Reader supports the text file (.txt) formats as well as the following two formats:
    - EPUB file (.epub) EPUB (OPS version 2.0) supported
    - PDF file (.pdf) Support is based on the PDF 1.6 specification.
    The default language setting on your Reader Digital Book does not affect the language the book is in. To read books in a foreign language, you will have to purchase them specifically in that language.
    Thank you for your post.

  • Oops. Can I read my byte stream files with missing headers?

    My fault, I know, but I wrote out an 1D array of numbers to a file using the simple Write File vi, not realising that a header would have been a good idea at the time. Now I can't read them back in because LabVIEW doesn't know what they are, and trying to put the original array element (Dbl Precision Number) on the Byte Stream Type of Read File doesn't work.
    So, is there any way that I can insert an appropriate header back into the beginning of the file so that I can then read them in successfully?
    (No, unfortunately I can't regenerate the data. Believe me, I would if I could!)
    Thanks,
    Riggy

    I suppose you used the Write File function from the File I/O pallette since there is no Write File VI?
    If that is the case your file should be exactly 8*N bytes long, if the array had N elements of type DBL.
    You can simply read back you data with the 'Read characters from File' VI (from the File I/O pallette) and then typecast the read string to a 1D array of DBL. (typecast is the first icon in the 'Advanced--Data Manipulation' pallette.
    -Franz

  • Compiling "write to jpg\bmp\png file" in Labview2011

    Hello everyone,
    I'm trying to compile a source code written in Labview 8.5 into Labview 2011.
    In the old source code I used the "write BMP/JPG/PNG file" VIs.
    I noticed that these VIs have changed in Labview 2011.
    Either way (using the old or new VIs) I get an error (#1003 - Vi is not executable) when I try to run my compiled .exe file.
    Did anyone encounter this problem?
    Do you have any idea how to bypass this problem?
    Thanks in advance.

    Mentos wrote:
    I have LABVIEW 2011 Runtime engine installed.
    I even reinstalled it, but the problem still remains.
    Could it be you only installed the minimum run time engine (~32MB)? You definitely need the std (~210MB).
    LabVIEW Champion . Do more with less code and in less time .

  • How can i read data in pagemaker file (PMD) using Visual Studio C# NET ?

    I have bunch of data in .PMD file (Page Maker Document). Which contains mathematical equations and chemistry formulas, I am a .NET developer, and I am writing code for one of the educational learning system. For that I need to read and store mathematical equations/ chemistry formulas from .PMD file into database then display on the browser page.
    Is it possible to read data from .PMD file using C#.NET, do I need to use any external libraries. How can I import .PMD to MATHML (Mathematical Markup language)?
    Any existing examples for C#.NET?
    Please help me regarding this.

    I can't claim to know much about visual C# Net, but I do know a bit about pagemaker. It really can't handle equations. there are a few work arounds involving things like baseline shifts and multiple text boxes, but generally equations were created in different programs and placed in pagemaker in picture or eps files. Either way the chances of extracting usable data out of pagemaker is very slim.
    Jay

  • How can i read my 1080 50p files from my panasonic camera

    Hi all newbie here can someone give me the name of software that can read my panosonic HDC-HS700 1080-50p files from my camera i can read the HA 1920 files okay but just cant read the 1080 file, people tell me that the imac doesnt support the 1080-50p files but surely there must be some software that can read from my camera.
                 Regards to all Pete.

    Hi  EZ  Jim, 
    After reading and following the info you sent through, i realised that the question i asked was totally wrong.
    my question is that my mac cant read or even see the 1080/50p on the hard drive of my cam, because apparently the Panasonic HDC-HS700 is not compatible with Apple can you beleive that, so now i have got to go out and by the software from Panasonic install on a crappy windows machine and then onto a portable hard drive and then back into my Mac.what a load of c--p.
    So thanks EZ for your help it was in any event usefull info that you gave me,
    My very Best regards Pete.
    EZ Jim wrote:
    You're welcome.
    We will watch for your status update.
    (Hope you and Fido have a nice walk! )
    Message was edited by: EZ Jim
    Mac OSX 10.8.3

  • How can I read my iPhone backup files?

    I would like to have a readable version of my text message backup files. I have found the file but I can't read it in its current database format. Please help!

    Why not read them on your phone? Or if the screen's too small for that to be comfortable, email them to yourself and read them on the Mac.

  • How can I read in a TDMS file into Sound and Vibration Assistant

    I have recorded a signal from 2 channels from a PXI 4496 DAQ card. I recorded this signal with the TDMS file format from a VI in Labview. I would like to import these signals into the Sound and Vibration Assistant for freq. analysis. In sound and vibration assistant there is an import logged tdms from signal express but I can not seem to import my original signal?  How can I import this data? 

    Hello All,
    I am trying to read TDMS file using LABVIEW. The TDMS file is created by me for reading data from one wire devices.
    I have created simple vi. attached below which read data from TDMS file. I am able to read other tdms files, I have with this program but not which one created by me. I am not able to attach file with .tdms exentiont. So I have attached it with .xlsx extention. Can anyone please guide me where is the problem in TDMS file? Am I missing anything while creating it?
    Thanks
    Attachments:
    EditTDMS (1).vi ‏14 KB
    data.xlsx ‏17 KB

Maybe you are looking for