Printing right-justification problem

I have tried to use several methods to accurately determine the rendered width of a string in order to position it at (right_edge - width) --that is, right-justified.  The problem is, all of the methods I have tried seem to under-report the length, resulting in the last few characters of the string being cut off at the right margin.  Here are the methods I have tried:
// g is an instance of Graphics2D cast from the Graphics object
// passed in via the Printable's print method
GlyphVector gv = g.getFont().createGlyphVector(g.getFontRenderContext(), MY_SENTENCE);
int widthONE = (int)Math.round(gv.getVisualBounds().getWidth());
int widthTWO = (int)Math.round(gv.getLogicalBounds().getWidth());
// try the standard methods:
int widthTHREE = (int)Math.round(g.getFontMetrics().getStringBounds(MY_SENTENCE,g).getWidth());
int widthFOUR = g.getFontMetrics().stringWidth(MY_SENTENCE);
I then render the string at the bottom right of the area using:
g.drawString( MY_SENTENCE, areaWidth-widthONE, areaHeight-1 );
...or widthTWO, etc.
No matter what Font I use, widthONE==widthTWO==widthTHREE==widthFOUR
areaWidth/areaHeight are correct, because a bounding rectangle (0,0,areaWidth,areaHeight) is rendered correctly and measures accurately with a ruler. But the string ends up cut off.
I am using Java 2 version 1.3.1_01 (Windows). I have tried several HP laser printers with identical results. Does anyone have any suggestions? Is this a bug in Java?
Thanks!

AHA! I upgraded to 1.4.2_03-b02 (Windows) and the problem went away... string bounds are accurate and right justification works nicely. And I was almost going to start on a workaround!

Similar Messages

  • Format/justification problem in web reports

    Hi ,
    We are running the reports3.0 from forms5.0 using the run
    product. The application is web enabled using the developer 2000
    server.
    The text in the report is Justifed ( Left and right
    justification). If I run the reports with the destination type as
    screen it is displaying with left and right justification. If the
    Destination type is printer then the reports justification is not
    correct( It is coming with no justification ).
    The developer 2000 is 2.1 version and developer 2000 server is
    also 2.1 version.
    Any one of you has faced this problem.Please reply ASAP.
    Thanks
    Pidikiti Ramesh
    null

    There is no standard way to do it.
    You can manually use javascripting to create custom hover boxes.
    You will have to understand the way HTML generates (it has flat image and AREA maps which isolate the areas of flag image w/ coordinates). Then enhance the AREA maps to override the standard hover boxes.
    If you know javascript very well then you can use even available javascript frameworks to get highly customizable hover boxes. But it will involve considerable effort.
    Abhijeet

  • Downloaded iTunes 11.0.2.26,the print CD jewel case does not print right,all the songs listed are printed in about a 1/2in. space,how can I get it to print right

    Downloaded iTunes 11.0.2.26,the print CD jewel case does not print right,all the songs listed are printed in about a 1/2in. space,how can I get it to print right

    I recently upgraded to itunes 11.0.1.12 and that fixed the CD Jewel Case Insert song titles problem. Thanks itunes. It's working great!!.

  • My photos are not printing right with adobe manages color but works when i use printer manages color. never had any issues untill a week ago.

    my photos are not printing right with adobe manages color but works when i use printer manages color. never had any issues untill a week ago.

    We use CS6, yes we calibrate using x-rite. I have always had adobe manage colors when printing. This problem just occurred, all my settings are the same as they have been for years. The only thing we did lately is do an update to CS6. We thought it might be our printer but when we use the printer manages color it works fine, The problem with adobe manages color is it is not blending the light highlights like on top of the cheeks with the colors around the cheeks  and its putting a faint red between the two it just does not have a smooth transition. I printed a photo that I had printed 4 months ago with no issue, and this time it had the issue that I am dealing with now. Somehow the photo shop manages color is not getting the right info to my printer.  
    I set paper type
    set quality
    no color adjustment
    set my profile
    Teri

  • Photos included in table don't print right

    I'm having trouble getting the photos (jpg's of about 700KB each) that I have embedded in a table to print right. I have them all set to "Image Fill" and "Scale to Fit". They look beautiful when I preview the print job, and the text prints just fine, but the photos come out with strange exaggerated shadows and highlights and terrible resolution. Total file size is 17MB and I'm working in Pages 1.0.2. Any ideas or suggestions on why this is happening and how I might correct the problem?
    Thanks!!!
    IMac G5   Mac OS X (10.4.7)  

    Hello Lisa,
    welcome to the Pages Discussions. Exists this problem only with tables or are there other problems when you try to print these photos (in shapes, free positioned and with shadows? Do you print the document at home or at a store? Do you print it with Pages or do you export it first to a PDF and print it than? Please describe the way what you are doing more detailed.
    By the way, as I know with version 1.x of Pages the PDF export has not the best quality settings like in version 2.x. There is the way to use the ColorSync tool for best PDF exporting. Especially with shadows and Pages 1.x you should go this way for PDF export. If you are using the PDF export for your documents, have a look at this post: http://discussions.apple.com/thread.jspa?messageID=2800679&#2800679.

  • Photos not printing right

    When I try to print photos using MS Vista OS they come out looking like negatives.  It isn't the printer itself as it prints photos fine when using MS XP OS.    What am I missing with Vista?  

    We use CS6, yes we calibrate using x-rite. I have always had adobe manage colors when printing. This problem just occurred, all my settings are the same as they have been for years. The only thing we did lately is do an update to CS6. We thought it might be our printer but when we use the printer manages color it works fine, The problem with adobe manages color is it is not blending the light highlights like on top of the cheeks with the colors around the cheeks  and its putting a faint red between the two it just does not have a smooth transition. I printed a photo that I had printed 4 months ago with no issue, and this time it had the issue that I am dealing with now. Somehow the photo shop manages color is not getting the right info to my printer.  
    I set paper type
    set quality
    no color adjustment
    set my profile
    Teri

  • Unable To Print Right Justified from Customize Local Layout (Alt+F12)

    Hi,
    Problem I am having is giving me nightmares. I am able to print hebrew text abap list in sap 4.5b. But when i change the Character Set of language from "Customize Local Layout"  (Alt+F12) to Hebrew (Right Justified) the preview shows up correcctly.  But when I print from an actual printer, it still shows output as (Left Justified). Can someone please help!!!!!!

    Hi
    Apologies for replying late. The printer is unicode enabled however, since we are on a non-unicode version of SAP (4.5b) it wouldnt really matter. We are printing Hebrew language. Its always coming out as left justified. We want it to print right justified.
    Awaiting some solution....

  • Controlling subtemplate text format (left-center-right justification, font)

    Hello,
    I have several sub templates that we are calling to display different text information and these sub templates are used in multiple format templates (that is the entire idea, right? <g>)
    My problem is in some of my reports I need the text to be center aligned and in some of them I need the text to be left justified, etc...
    I also would like to display the text in different sized fonts as well.
    How can I control my formatting from the driving format template instead of having it inherit the left/center/right justification that is present in my sub templates???
    Thanks in advance for your feedback,
    Scott

    Yes, that is exactly what I think I need to do (override the formatting with commands in the main template).
    I don't know if the possibilities will get that large in my case because for each main format template the formatting will remain constant.
    So I may call a subtemplate from several main format templates but in each main template I will just need to set the alignment and font-size (we use a consistent font type). Perhaps once in awhile I may need to bold something, but that should be about it.
    Please, how is this done exactly? Can you point me toward the XSL command(s) to accomplish this? Or is there something in the plug in I am missing that can accomplish this?
    We have over a dozen reports waiting for this one last tweak now and I am working with the below fo block and in this example it is coming across from the subtemplate LEFT justified (because that is how it is stored in the subtemplate) and we need it to be CENTER justified.
    <fo:table-row>
    <fo:table-cell padding-end="0.0pt" padding-bottom="0.0pt" padding-start="0.0pt" padding-top="0.0pt" vertical-align="top" height="10.8pt" number-columns-spanned="2">
    <fo:block xdofo:xliff-note="ST: azzbillto" padding-bottom="0.0pt" text-align="center" orphans="2" widows="2" padding-top="0.0pt" end-indent="0.0pt" linefeed-treatment="preserve" start-indent="0.0pt" height="0pt">
    <xsl:call-template name="azzcompanyname">
    <xsl:with-param name="azzorg" select="string(.//POH_BILL_TO_LOCATION)"/>
    <xsl:with-param name="_XDOFOPOS" select="$_XDOFOPOS"/>
    <xsl:with-param name="_XDOFOPOS2" select="$_XDOFOPOS2"/>
    <xsl:with-param name="_XDOFOOSTOTAL" select="$_XDOFOOSTOTAL"/>
    <xsl:with-param name="_XDOFOTOTAL" select="$_XDOFOTOTAL"/>
    <xsl:with-param name="_SECTION_NAME" select="$_SECTION_NAME"/>
    </xsl:call-template>
    </fo:block>
    </fo:table-cell>
    </fo:table-row>
    Any ideas??
    Thanks,
    Scott

  • PDF printer has a problem with Safari in "Reader" mode in Windows7

    As shown in the image above. When I try to use the PDF printer to print out a web page in Safari "Reader" mode, the lines near the bottom of each page get squeezed like this. There is no problem with XPS printer. I guess this problem is because of some incorrect settings in Safari or the PDF printer?
    My system is Windows 7 Pro. I am using Acrobat X Pro. The page I am trying to print is http://en.wikipedia.org/wiki/Electronic_band_structure. This problem only happens when the webpage is adjusted into "Reader" mode in Safari.

    Many thanks for your reply!
    I am sorry, I did not make my question clear. I would like to save some web pages only in "Reader" mode, because in this mode all the advertisements are filtered out and the pages look much nicer than the origional layout.
    I first let Safari to active "Reader" by clicking "Reader" button.
    Then I click "Print" button and select Adobe PDF as the printer.
    The problem is the PDF file has something wrong (shown above), and I would like to know how to avoid this problem.

  • Downloaded acrobat reader 11 onto my Mac Book Pro, it can open the file but will not print. Get a message that says PDF cannot be printed, however, I forwarded it to someone else and they could print it, no problem. I called HP and spent an 1hour with the

    downloaded acrobat reader 11 onto my Mac Book Pro, it can open the file but will not print. Get a message that says PDF cannot be printed, however, I forwarded it to someone else and they could print it, no problem. I called HP and spent an 1hour with them and then called Apple support and worked with them for 3 hours. No one can figure it out. Is there something wrong with this version? the pdf was created in 2004. Do I have to pay to get Acrobat?

    Let me give you a slightly different perspective than everyone else here.  You are using an unsecured wireless network, which means that all your network traffic is easily available for viewing by anyone else using that network.  That's bad.  Very bad, for you, unless you absolutely trust everyone who lives within range of this network.  So stop doing it.
    As to the Mac not connecting, wireless networking is simply too complex for any reasonable answer without more information.  There are many possible error points, and as often as not it's the Mac that can connect and the Windows PC that cannot.  Since you can't give us any information about the configuration of the neighbor's network, and can't make any changes to it, we can't do much to help you troubleshoot it.

  • I am having trouble printing a PDF document. Whenever I click print nothing happens but when I am printing documents from Word, Excel etc they print without a problem. I've tried printing as image but that did not work. I uninstalled Adobe Reader XI and d

    I am having trouble printing a PDF document. Whenever I click print nothing happens but when I am printing documents from Word, Excel etc they print without a problem. I've tried printing as image but that did not work. I uninstalled Adobe Reader XI and downloaded Adobe Reader X instead and that still doesn't work. I have Windows 7.

    Hello,
    Please follow the link to troubleshoot the printing issues with Adobe Reader:- Troubleshoot PDF printing | Acrobat, Reader.
    Regards,
    Nakul

  • Right Justification in File Content Conversion

    I have a requirement where the data should be right justified in File content conversion of a Receiver Adapter .
    For example  it should be coming as   "      5864"  instead of "5864     ". Please help in completing this requirement.

    Hi Srinath
    AFAIK, there is no setting in FCC to achieve this. You can do this instead in the Message Mapping step by doing a right justify on that target fields.
    You can search for plenty of solutions on the internet to perform a right justify and include it in a UDF.
    Below is an example of a UDF of execution type single values with single input. It right justifies the String based on a total length of 15. You can change the field length according to your requirement.
    return String.format("%15s", input);
    Rgds
    Eng Swee

  • When I tried to print I had problems.

    I got a new Macbook pro yesterday.  Brilliant!
    I used Time machine to transfer everything.  I'm getting used to most things but
    when I try to print I had problems.
    I downloaded new driver but still no go.
    Help  please!!!
    Kathy

    If you haven't done so already, try resetting the printing system.
    OS X Mavericks: Reset the printing system  also Yosemite

  • They fixed the right click problem, but now there is a bigger problem

    after updating, I can use my right click perfectly on Windows XP. however, my windows XP starts to restart very often-which means the "blue-sceen" comes out very often. I believe many poeple has this problem because I had already read couple of complains...Well...I hope apple can fix it soon.

    I could not right click on my macbook's Precision aluminum unibody enclosure under windows xp, and after updating the trobubleshooter, it works. However, my windows starts to restart again and again (the blue screen) and it says it is because the applemtp.sys has some problems. I read couple of others people's experiences on the Internet, and they all so it started to happen after they fix the right click problem.

  • Print Color Management Problem ?

    I have a print color management problem I cannot solve. It reminds me of the print color management problem I had over a year ago when the compatibility conflict between LR and MAC Leopard produced horrible prints. I have Snow Leopard now and been out of the country for some months and yesterday when I tried to make some prints the same problem reemerged. So I downloaded current drivers (and ICCsfor Premium Luster) from Epson and LR 2.6 and spent a good part of the day with Martin Evening's book. I followed (I think) his instructions to make the basic print step by step but the prints still were terrible. My problem is with the color management pop up in the print settings dialog -- it says "color matching" not color management and I cannot check either "no color management " if I want LR to control the process (Kelby)  or check "color sync" if I want my Epson R800 take over. I have no idea where the "color management" pop up went. I'm clueless as usual and probably omitting a step because of frustration or brain numbness. Any help would be appreciated. WJS

    The settings in Lightroom are simple. and contain in the Print Job panel in the Print module. You either select manage in printer (and then select the profile in the printer drivers) or select the profile here and then turn of all colour management in the printer drivers. The second option will usually produce the best results. What you don't want is to have the profile selected in both LR and the printer drivers, so if the driver doesn't have an option to turn of colour management then you may be forced down the first route. However it would be an unusual decision for a printer manufacturer to make drivers that can't turn off colour management, so you may wish to ask how to do it to your printer manufacturer or check the printers handbook.

Maybe you are looking for