Problem in converting text to image.

Hi I am trying to convert a text to image. The code for the same is pasted below. The problem is how do I change the background color. No matter what color I give with Graphics2D object, the background is always black. I want a white background.
public class TextToImg1
public static void main(String args[])
try
int width = 400;
int height = 400;
BufferedImage bimage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics2D g2D = bimage.createGraphics();
g2D.drawString("This is the sample page to convert text to image.",100,100);
g2D.setBackground(Color.WHITE);
g2D.setColor(Color.WHITE);
File f = new File ("anImage.jpg");
ImageIO.write (bimage, "jpeg", f);
catch(Exception exception)
System.err.println(exception.getMessage());
}

Probably because you didn't draw the background. Use the fillRect(...) method to paint the background using the color your want.

Similar Messages

  • Printing a PDF document to virtual PDF printer converts text to image in output PDF-file

    When I "print" any regular PDF document to a PDF virtual printer, it always converts a source regular (textual) PDF document into an image only document. It applies even to pure plain text documents (say, HTML source code etc.)
    (I often need to create a PDF document from the existing PDF. Yes, I know, it might seems quite pointless, but actually it makes sense.)
    Thus I have 2 questions:
    1) Is such sonvertion normal or I do anything wrong myself?
    2) It is by design, is there any woraround to prevent conveting text to image?
    Many thanks in advance!

    Have you checked to see if the "Print As Image" option is inadvertently checked? In the Print dialog, click the Advanced button then look for the checkbox.

  • Problem with alligning text and images

    Dear reader
    I am having a problem with alligning some content in the left
    column of my webpage. It will allign correctly in internet explorer
    but I would like it to also allign correctly in Opera and Firefox
    as many people use thise browsers also. Here is links to
    screenshots to show you what I mean. The problem is highlited in
    orange.
    http://www.iggpog22.com/mystuff/gap.png
    - There is a gap between my starburst logo and the header image
    'Links'
    http://www.iggpog22.com/mystuff/nogap.png
    - There is no gap between my starburst logo and the header image
    'Links' in dreamweaver though which is how I would like it to
    display.
    If anyone could offer some advice I would be very grateful. I
    usually try to work stuff out for myself but this problem has me
    stumped. I can also provide the html is you need that. Thanks again
    for any response.
    .Sam
    Edit
    This is a link to a .rtf file of the code for the webpage
    http://www.iggpog22.com/mystuff/ig2code.rtf
    you can also visit my webpage at www.iggpog22.com (gotta
    include the www. otherwise it shows the wrong site)
    I hope this is enough to be more helpful

    Posting images aren't that much use I'm afraid. The answer is
    in the
    code and to solve the issue its more than likely thats what
    someone
    would need to see to help you.
    Can you upload the page somewhere and give a link to it?
    02cspearson wrote:
    > Dear reader
    > I am having a problem with alligning some content in the
    left column of my
    > webpage. It will allign correctly in internet explorer
    but I would like it to
    > also allign correctly in Opera and Firefox as many
    people use thise browsers
    > also. Here is links to screenshots to show you what I
    mean. The problem is
    > highlited in orange.
    >
    http://www.iggpog22.com/mystuff/gap.png
    - There is a gap between my starburst
    > logo and the header image 'Links'
    >
    http://www.iggpog22.com/mystuff/nogap.png
    - There is no gap between my
    > starburst logo and the header image 'Links' in
    dreamweaver though which is how
    > I would like it to display.
    >
    > If anyone could offer some advice I would be very
    grateful. I usually try to
    > work stuff out for myself but this problem has me
    stumped. I can also provide
    > the html is you need that. Thanks aain for any response.
    > .Sam
    >

  • Problem in converting some images

    Hi all,
    I have a problem when converting a word document in pdf (using acrobat 9). If i use the standard settinings, everything works fine. If I use personalised options to mantain bookmarks and links in the final pdf, some images (png) after the conversion appear with some black stripes on top of them.
    Does someone encountered the same problem?
    Thank You!

    Sorry for the delay in my response. I was on vacation.
    I tried following code (giving the type as related). But still it didn't work out :(
    I am sure i am doing some silly mistake. I guess mistake is in how i use cid:imageDo i need to use four unique cid tag if i attach four images? If yes can someone help me how? Thanks
    MimeMultipart multiPart = new MimeMultipart("related");
    MimeBodyPart msgBody = new MimeBodyPart();
    String htmlText = content+"<H1></H1><img src=\"cid:image\">";
    msgBody.setContent(htmlText, "text/html");
    multiPart.addBodyPart(msgBody);
    File folder = new File("./result");
    File[] listOfFiles = folder.listFiles();
    for (int i = 0; i < listOfFiles.length; i++)
    MimeBodyPart attachmentPart = new MimeBodyPart();
    FileDataSource fds = new FileDataSource(listOfFiles.getAbsolutePath());
    attachmentPart.setDataHandler(new DataHandler(fds));
    attachmentPart.setFileName(listOfFiles[i].getName());
    attachmentPart.setHeader("Content-Type", "image/png" );
    //attachmentPart.setDisposition("inline");
    attachmentPart.setHeader("Content-ID","image"+i);
    mp.addBodyPart(attachmentPart);
    System.out.println("Attached the file " + listOfFiles[i].getAbsolutePath());
    mess.setContent(multiPart);

  • Will Adobe ExportPDF convert a pdf with text and images to docx ?

    I have tried to convert an adobe pdf, which includes text and images, to a docx file.  The Adobe ExportPDF has not been able to do it - comes back with many errors.

    Mostly it can do it, though you can't expect a precise match on the layout. What errors do you get?

  • I am trying to convert an Illustrator cs6 file to a PDF and every time I do it, I lose all text and images. Can someone provide some assistance? Thank you!

    I am trying to convert an Illustrator cs6 file to a PDF and every time I do it, I lose all text and images. Can someone provide some assistance? Thank you!

    It's always a good idea to supply platform and AI version info.
    How are you "converting" the file? Are you choosing "Save As" and selecting PDF from the file format options? This will bring up additional save options. I would suggest "Illustrator Default" setting unless you have specific needs.

  • Convert text from an image to speech

    Hello...I have successfully read characters from an image using OCR but I am unable to built a vi which can convert those characters of an image  into sound
    I have attached the image
    Attachments:
    1348653532_441577804_1-Pictures-of--number-plate-for-salefancy-number.jpg ‏34 KB

    Hi Dilpreet
    If you are on a Windows machine there is a .NET assembly that will convert text to speech. It is System.Speech
    Have a look at the example below
    Mike
    Attachments:
    Speech.vi ‏11 KB

  • Possible to scan a document into Acrobat XPro,then replace part of that PDF with text or image file?

    Hi everyone,
    Is it possible first to  scan a paper document into Acrobat X Pro, and then to replace a "pane" or box within that PDF with a text or image file?
    Would it require  SDK and Javascript?
    Thanks,
    Rick Weinhaus

    CtDave and others:
    Here's the problem in more detail.
    I am a physician and I already have the ability to incorporate paper-based
    documents into an electronic health record (EHR) by scanning them and
    saving them as PDFs.  The documents are paper patient encounter forms with
    a different box or 'pane' for each category of data.   Each box has a fixed
    location on the paper form.
    There are three situations, however, where I want to have the option to
    overwrite certain boxes of the PDF with data generated by methods other
    than scanning.
    1) Insert text macros with variable fields using the electronic health
    record's software.
    2) Insert a drawing available as a pre-existing JPG or generated by using a
    tablet.
    3) Insert text generated using Dragon Naturally Speaking.
    For efficient office workflow, in all three cases the text or image to be
    inserted into the box or 'pane' in the PDF needs to be generated while I am
    still seeing the patient -- that is -- before the paper form has been
    scanned and converted to a PDF.
    The sticky note tool is one option, but I would want to be able to modify
    the default size of the sticky note so that it corresponded exactly to the
    size of the box it was 'overwriting.'  I can't figure out how to do this?
    Could it be done using scripting?
    Furthermore, I would want the sticky notes to automatically display when
    the PDF was opened, so that a hover would close rather than open them.  This
    sticky note method would have the advantage of allowing the user to toggle
    back and forth between inserted data and any original handwritten text.
    Any thoughts?
    Rick

  • Problem in converting to PDF

    Hi,
    i am facing a strange problem while converting the book file to pdf...
    Error message:
    %%[ ProductName: Distiller ]%%
    %%[Page: 1]%%
    %%[Page: 2]%%
    %%[ Error: ioerror; OffendingCommand: readstring ]%%
    Stack:
    (====;;;;;;::::9998877755554444222222222-\)&# ...)
    -file-
    -mark-
    -save-
    %%[ Flushing: rest of job (to end-of-file) will be ignored ]%%
    %%[ Warning: PostScript error. No PDF file produced. ] %%
    I think its with the encapsulated post script files I use in the book.
    please help me to resolve this issue...
    Thanks...

    PostScript language level 2 dates back to 1990. PostScript language level 3 was announced in 1996 with first devices shipping in 1997. Adobe Acrobat Distiller is effectively an Adobe PostScript 3 device as of Acrobat 4.0. At Adobe, we know of no problems associated with processing of properly generated PostScript language level 3 files by Distiller.
    In terms of what may appear in an EPS file, the major areas of difference would be in use of smooth-shaded gradients in language level 3 as opposed to adjacent similar polygons or images to represent gradients in language level 2.
    Ironically, changing the settings of the Adobe PDF PostScript printer driver instance for PostScript language level (the Distiller itself has no such setting) does
    not affect the placed EPS (or EPS derived from placed PDF) in your FrameMaker document. The PostScript text in the EPS is simply passed through the driver unchanged, regardless of the driver's PostScript language level setting, to the Distiller. The setting you changed affected only the PostScript generated from non-EPS components of your FrameMaker document.
    I cannot rationally explain the symptoms you experienced and why the driver setting change you made resolved the symptoms without looking at your files and knowing exactly how they were generated. It is possible that the problem has nothing to do whatsoever with your EPS files! :-)
    - Dov

  • Printing text and images together on a single page (printjob)

    Hello all,
    how am I able to print both text and images on the same page (defined by one printjob), using the javax.print API?
    It seems that one printjob (one page) can have only one flavor, that is text, or GIF, or JPEG, etc. Since the majority of print jobs out there usually require text and graphics on the same sheet this seems a bit strange.
    I have resorted on creating a PDF file through the iText library, and then printing by converting to GIF (quality is significantly reduced though, not an option), or by using the Acrobat Reader command line from java (looks dangerous for batch printing). My printer does not support printing directly using the PDF flavour.
    So, I solved the problem by converting to PDF, but printing is still cumbersome. Any other ideas?
    Thank you for your time,
    Ari.

    TIP: For insurance against the iPhoto database corruption that many users have experienced I recommend making a backup copy of the Library6.iPhoto database file and keep it current. If problems crop up where iPhoto suddenly can't see any photos or thinks there are no photos in the library, replacing the working Library6.iPhoto file with the backup will often get the library back. By keeping it current I mean backup after each import and/or any serious editing or work on books, slideshows, calendars, cards, etc. That insures that if a problem pops up and you do need to replace the database file, you'll retain all those efforts. It doesn't take long to make the backup and it's good insurance.
    I've created an Automator workflow application (requires Tiger), iPhoto dB File Backup, that will copy the selected Library6.iPhoto file from your iPhoto Library folder to the Pictures folder, replacing any previous version of it. It's compatible with iPhoto 08 libraries and Leopard. iPhoto does not have to be closed to run the application, just idle. You can download it at Toad's Cellar. Be sure to read the Read Me pdf file.

  • Mail converts jpg/gif images to tiff

    I have a friend who has an ibook running panther. When she tries to forward an email message that contains jpg or gif attachments, Mail converts them to tiff, which causes problems for her windows bound friends, and also increases the message size by a factor of 10. Animated gif attachments converted to tif are useless.
    Is there any way for her to stop Mail from converting these attachments to tif? Thanks.

    Is there any way for her to stop Mail from converting these attachments to tif?
    Not with Jaguar or Panther Mail.
    This is caused by the sender using HTML for message composition and a jpg or gif being embedded in the message body which are not true attachments.
    Jaguar and Panther Mail render HTML received but do not support composing in HTML which includes when forwarding a message received that was composed in HTML. Jaguar/Panther Mail supports RTF and Plain Text only so when forwarding a message received that was composed in HTML with embedded images, the Mail.app converts the embedded images to attachments and uses RTF.
    Although Tiger Mail does not support complex HTML composition within the body of a message, RTF in Tiger Mail is HTML. Tiger Mail also supports forwarding a received message that was composed in HTML. With Safari under Tiger, you can select Mail Contents of This Page which will copy the selected web page and paste the contents in a new mail message and the contents of the copied web page will be sent in it's entirety.

  • Dynamic text box, HTML Text with Image

    Hello Everyone,
    I am using Flash version 8. I have used the text tool and
    created a dynamic text box and have attached the UIScrollBar
    component to it. This text box is configured to allow the use of
    html text to be inputted to it. I have code that reads a file which
    contains a list of text files that I then read and place them into
    the text box. The user can use the scroll bar to scroll through all
    the text.
    I have created an image that is a picture of the tab portion
    of a file folder. On the tab I have place some text. This was all
    done in Photoshop. This tab image is used to separate the different
    stories in the text box. The image is save as a jpeg file
    Everything you have just read works with out any problems.
    Now for the problem!
    This image is only 20 pixels tall and the text is not very
    readable. As we all know the HTML tags are very limited in Flash 8.
    Ideally I would like to put the text and image in to the text
    box as I would normally do. Then place text on top of the image and
    have it all scroll properly with in the text box.
    I have taken the tab image and converted it in to a graph
    symbol and then put the text on top of the image. This looks good;
    however I don’t know how (or if it is even possible) to place
    the graphic symbol in to the text box at the correct place within
    the text.
    Does anyone have ideas on what may work? Remember that the
    image I am working with is only 20 pixels tall which is why the
    text quality on the image is so poor.
    Thank you all for any help you may provide,
    Steve

    Yes Tim I am using the <img> tag and I know that I
    can’t place text over the image. I have set the height and
    width to be the exact size of the image. However When you go to the
    webpage it will open the movie to the maximum size based on the
    resolution of your display; however I do maintain the aspect ratio
    of the movie. For testing I did set a fix size to the size of the
    movie. Sometimes the fix size (1000x750) looks better and sometimes
    a larger size (example 1280x1024). I believe that the main problem
    is the fact the size of the image is 670 pixels wide by 25 pixels
    high and of the 25 pixels the text is only 18 pixels tall. In
    Photoshop this makes it about a 1.75 point font. As you can see the
    real problem is that I don’t have enough pixels to make up
    the text. This is why I am looking for an alterative way to create
    the text.
    I tried importing the image into flash as a graphic symbol
    and then using the text tool to create the text. The results looked
    real sharp, the text was nice and crisp (just what I wanted). The
    problem is that I could not find a way to place the graphic symbol
    into the dynamic text area like id did using the <img> tag.
    This symbol needs to scroll as you scroll the text in the text
    area.
    This is why I am asking for help. I am looking for some ideas
    that may work.
    Thank you,
    Steve

  • Blue Background of large text or images until page fully loads

    This problem occurs in Internet Explorer when viewing iWeb created sites. The blue or yellow highlights go away when the full page is loaded. This does not occur in Safari. I just want to make sure the other 90% gets to see my site as intended.

    This is probably caused by the fact that your images are large and the text may also be converted to an image. Turn on "Show text imaging indicator" in iWeb preferences to see if this is the case.
    Files take a lot longer to download in IE as it is so inefficient.
    To improve this situation you can optimize your images before loading into iWeb......
    http://roddymckay.com/PlanetRoddyPhotoSatellite/OptimizeImageFile.html
    ... and optimize all your website files...
    http://www.iwebformusicians.com/SearchEngines/Optimize.html

  • "Convert Text to Table" Size limit issue?

    Alphabetize a List
    I’ve been using this well known work around for years.
    Select your list and in the Menu bar click Format>Table>Convert Text to Table
    Select one of the column’s cells (1st click selects entire table, 2nd click selects individual cell)
    Open “Table Inspector” (Click Table icon at top of Pages document)
    Make sure “table” button is selected, not “format” button
    Choose Sort Ascending from the Edit Rows & Columns pop-up menu
    Finally, click Format>Table>Convert Table to Text.
    A few days ago I added items & my list was 999 items long, ~22 pages.
    Tonight, I added 4 more items. Still the same # pages but now 1,003 items long.
    Unable to Convert Text to Table! Tried for 45 minutes. I think there is a list length limit, perhaps 999 items?
    I tried closing the document w/o any changes. Re-opening Pages & re-adding my new items to the end of the list as always & once again when I highlight list & Format>Table>Convert Text to Table .....nothing happens! I could highlight part of the list up to 999 items & leave the 4 new items unhighlighted & it works. I pasted the list into a new doc and copied a few items from the middle of the list & added them to the end of my new 999 list to make it 1003 items long (but different items) & did NOT work. I even attempted to add a single new item making the list an even 1000 items long & nope, not working. Even restarted iMac, no luck.
    I can get it to work with 999 or fewer items easily as always but no way when I add even a single new item.
    Anyone else have this problem?  It s/b easy to test out. If you have a list of say, 100 items, just copy & repeatedly paste into a new document multiple times to get over 1,000 & see if you can select all & then convert it from text to table.
    Thanks!
    Pages 08 v 3.03
    OS 10.6.8

    G,
    Yes, Pages has a table size limit, as you have discovered. Numbers has a much greater capacity for table length, so if you do your sort in Numbers you won't have any practical limitation.
    A better approach than switching to Numbers for the sort would be to download, install and activate Devon Wordservice. Then you could sort your list without converting it to a table.
    Jerry

  • How do I use the Services menu to convert text to an iTunes track?

    I'm trying to convert text to an iTunes track using the Services option on the Firefox drop down menu, but having trouble with it. I have set my preferences to turn on that option, but all that happens is I get a spinning wheel at the top of my screen, and it doesn't record. I can't see anything in the iTunes settings that I need to change, but wondering if that could be the problem? Any help would be appreciated.

    Then you may be much better off posting your question in the ExportPDF forum,
    http://forums.adobe.com/community/exportpdf

Maybe you are looking for