Printing graphics object in Landscape or portrait mode

Hello,
I have a graphics 2d object (a Tree Diagram) which is inside a JScrollPane,and the JSCrollPane is on a JPanel. it's length and width is more than one page. I am using a printable object to print the object. The task I need to do is,
(1). compress the width and length of the diagram, so that if can fit into one page, else split the diagram into pages, so that each part of it can be printed on different pages(page size A4) and then later those pages can be merged accordingly.
I am not able to find, how to split the graphic object(the tree diagram into pages), shoul d I try doing it using x and y co ordinate of the graphic object.

* PrintUtilities.java
* Created on January 17, 2007, 7:25 PM
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
package action.vector.bam;
* @author serjith
import java.awt.*;
import javax.swing.*;
import java.awt.print.*;
import javax.print.attribute.HashPrintRequestAttributeSet;
import javax.print.attribute.PrintRequestAttributeSet;
/** A simple utility class that lets you very simply print
* an arbitrary component. Just pass the component to the
* PrintUtilities.printComponent. The component you want to
* print doesn't need a print method and doesn't have to
* implement any interface or do anything special at all.
* <P>
* If you are going to be printing many times, it is marginally more
* efficient to first do the following:
* <PRE>
* PrintUtilities printHelper = new PrintUtilities(theComponent);
* </PRE>
* then later do printHelper.print(). But this is a very tiny
* difference, so in most cases just do the simpler
* PrintUtilities.printComponent(componentToBePrinted).
* 7/99 Marty Hall, http://www.apl.jhu.edu/~hall/java/
* May be freely used or adapted.
public class PrintUtilities implements Printable {
private Component componentToBePrinted;
public static void printComponent(Component c) {
new PrintUtilities(c).print();
public PrintUtilities(Component componentToBePrinted) {
this.componentToBePrinted = componentToBePrinted;
public void print() {
PrinterJob printJob = PrinterJob.getPrinterJob();
PrintRequestAttributeSet set = new HashPrintRequestAttributeSet();
PageFormat pgFormat = printJob.pageDialog(set);
printJob.setPrintable(this,pgFormat);
//printJob.setPrintable(this);
if (printJob.printDialog())
try {
printJob.print();
} catch(PrinterException pe) {
System.out.println("Error printing: " + pe);
public int print(Graphics g, PageFormat pageFormat, int pageIndex) {
if (pageIndex > 0) { // requires change since it is bigger than a single page
return(NO_SUCH_PAGE);
} else {
Graphics2D g2d = (Graphics2D)g;
g2d.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
disableDoubleBuffering(componentToBePrinted);
int W = componentToBePrinted.getWidth();
int H = componentToBePrinted.getHeight();
//Component newComp = componentToBePrinted.getGraphics().clipRect();
System.out.println("WorkSpace Height "+H+" Width "+W);
pageFormat.getHeight();
pageFormat.getWidth();
pageFormat.setOrientation(PageFormat.LANDSCAPE);
//componentToBePrinted.paint(g2d);
componentToBePrinted.printAll(g2d);//.paintAll(g2d);
enableDoubleBuffering(componentToBePrinted);
return(PAGE_EXISTS);
/** The speed and quality of printing suffers dramatically if
* any of the containers have double buffering turned on.
* So this turns if off globally.
* @see enableDoubleBuffering
public static void disableDoubleBuffering(Component c) {
RepaintManager currentManager = RepaintManager.currentManager(c);
currentManager.setDoubleBufferingEnabled(false);
/** Re-enables double buffering globally. */
public static void enableDoubleBuffering(Component c) {
RepaintManager currentManager = RepaintManager.currentManager(c);
currentManager.setDoubleBufferingEnabled(true);
=============================================================
Please find this code, which I am trying to use, here I am passing the JPanel
try{                   
PrintUtilities.printComponent(actWorkSpace);
}catch(Exception ex){
ex.printStackTrace();
the actWorkSpace is a JPanel with graphics as mentioned above, which is being passes to PrintUtilities.printComponent();
the output is only just a single page with just a portion of the graphics on the JPanel, pls help...... it is urgent....

Similar Messages

  • Print SSRS Server Report in landscape or portrait mode directly(without report viewer control)

    Hello,
    .Net 4.0\VS2010\C#\ssrs 2008 on Sql Server 2008R2
    Having a problem printing a Server report while controlling the orientation and the size of the emf rendered to the physical page.
    I have the report cutting off in both landscape and portrait modes. I'm passing the following deviceinfo to the render function:
    string DeviceInfo =
    @"<DeviceInfo>
    <OutputFormat>EMF</OutputFormat>
    <PageWidth>8.5in</PageWidth>
    <PageHeight>11in</PageHeight>
    <MarginTop>0.25in</MarginTop>
    <MarginLeft>0.25in</MarginLeft>
    <MarginRight>0.25in</MarginRight>
    <MarginBottom>0.25in</MarginBottom>
    </DeviceInfo>";
    return DeviceInfo;
    string mimeType;            string fileExtension;            Stream pageStream = serverReport.Render("IMAGE",  deviceInfo, firstPageParameters, out mimeType, out fileExtension);
    No other settings seem to have an affect on controlling the output to printer or pdf.  i.e. The deviceinfo params fed to server report's render function are all you get.  I think my original code comes from an MSDN or CodeProject example. I'm not
    inventing anything new here.
    Links below indicate similar problems but they are looking at the issue from just landscape mode. Seems like I ought to be able to squash or expand the image to whatever size I specify, separate from the 'page' size.  Please let me know what i need
    to know to make these reports print without bleeding onto 2 pages or slicing off the right side of the document image.
    http://stackoverflow.com/questions/25652415/cant-print-ssrs-rdlc-report-in-landscape-mode-directly-to-printer-using-suggest
    https://social.technet.microsoft.com/Forums/sqlserver/en-US/06a9b432-c8a5-4952-a07c-867742a26c47/print-rdlc-without-report-viewer-either-in-portrait-or-landscape?forum=sqlreportingservices
    print ssrs rdlc report in landscape mode directly
    Thanks!

     Hi
    FraterJoanni,
    Thanks for posting in MSDN forum.
    I am not expert in SSRS. You should get better response in SQL Server > SQL
    Server Reporting Services, Power View forum.
    After take a look at the similar threads links as you posted above.
    The conclusion is we needn’t tell the program o this report is landscape not portrait. If the width is larger than the height, the report will be printed in landscape; otherwise, it will be printed in portrait.
    >>Links below indicate similar problems but they are looking at the issue from just landscape mode.
    But in C# forum, we only from the point of code, code looks OK to me.
    A similar blog talking about this
    Controlling Page Size in a Reporting Services Report
    And  I have got the default page size in the US is Letter, 8.5in x 11in.  In other parts of the world A4 (8.3in x 11.7in) is the standard. 
    65: //build the device settings (A4 8.3 × 11.7)
    66: string deviceInfo = string.Format("<DeviceInfo><PageHeight>{0}</PageHeight><PageWidth>{1}</PageWidth></DeviceInfo>", "11.7in", "8.3in");
    67:
    68: //get report bytes
    69: result = rs.Render(format, deviceInfo, out extension, out encoding, out mimeType, out warnings, out streamIDs);
    70:
    Best regards,
    Kristin
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Landscape and portrait mode

    My iPad is slow between rotating from landscape o portrait mode at the home screen. In apps though it is very fast. Anybody know why? It hasn't always been like this

    Hi,
    Try restarting your iPad.
    Press and hold the Sleep/Wake button until the red slider appears. Slide your finger across the slider to turn off iPad. To turn iPad back on, press and hold the Sleep/Wake until the Apple logo appears.
    See if that made a difference.
    If not, you may have an app that needs "force quitting" ...
    Try this... Press and hold the Sleep/Wake button on top of iPad for a few seconds until a red slider appears, then press and hold the Home button until the application quits.
    Try again. If it's still slow, connect your iPad to your computer, launch iTunes. Check available storage at the bottom of the iTunes window. Might be a good idea to have at least 10% free space available.
    Carolyn

  • Landscape and portrait mode in Epub

    Hey!
    When I export from Indesign to .epub with a fixed layout - is there a way to use it in landscape and portrait mode on an Ipad or Iphone? Mine stays in landscape.

    @Steve – don't think so…
    @Kaz Till – do you mean the following:
    1. Without setting "auto":
    2. After setting "auto":
    Don't think, that this is to the advantage of the reader…
    Uwe

  • Printing only first page landscape not portrait

    Acrobat Standard for Windows v.8
    When using Acrobat to print any PDF document, the first page is printed in landscape instead of portrait, the rest of the pages print as expected. This is reproduceable behavior on a single machine. Printing the PDF using other applications like InDesign or eCopy Desktop print as expected. Only Acrobat is exhibiting this behavior.
    Acrobat has been reapired, uninstalled and reinstalled, printer drivers reinstalled with no success. The work around I have figured out (as a temporary solution so the user can print documents properly) is to select to print the PDF in landscape orientation in the print driver when printing from Acrobat, which prints the whole document in portrait orientation, essentially what was supposed to happen in the first place. This orientation change only seems to affect the first page and doesn't have any affect on duplex orientation.
    Does anyone have a solution to this one? Or some direction? Thanks in advance.

    Try one of these:
    1/ In Adobe, deselect "Choose Paper based on PDF size" - you can leave the "Auto Rotate and Center" on.
    2/ In Adobe, go into Advanced and choose "Print as Image".
    3/ If this is a Canon H1 Fiery RIP, go into Printer Properties, Printing Preferences, Layout, Rotate 180degrees and choose "Large Paper Only."

  • Stuck in landscape then portrait mode...

    After attempting to watch a video, the iPad stayed stuck in landscape mode. None of the following helped: turning on & off, attempting to sync, shaking it around, using different apps. I finally did a Reset All Settings and it put the device back in portrait mode but now stuck there. Since all else has failed, I am about to do a Restore.

    Bossy Boss wrote:
    After attempting to watch a video, the iPad stayed stuck in landscape mode. None of the following helped: turning on & off, attempting to sync, shaking it around, using different apps. I finally did a Reset All Settings and it put the device back in portrait mode but now stuck there. Since all else has failed, I am about to do a Restore.
    Make sure the Screen Rotation Lock button on the side isn't locked.

  • Making a photographic book in landscape and portrait mode in iBooks author

    Hello, I am making a photographic book with the iBooks author and I have a problem that I cannot resolve. The book is only with photos, without text and I am putting every photo on a whole page. I made around 15 pages in landscape orientation and now I want to make the same thing with the same photos in portrait, but I don't know how to arrange the photos to match when the ipad is flipped. The whole idea is that I want people to see different crops of the photos when they flip the iPad. I hope that you understood me and will eventually come up with solution...  Really thanks!

    Hi user_1,
    If you are looking to reshape the graph based on whether the user has selected portrait or landscape mode, you could use a property node for your graph that executes in the same case as the print orientation, in which you reshape the graph using plotareasize or another property. I've attached an example of this.
    Hope this helps!
    -Sam F, DAQ Marketing Manager
    Learn about measuring temperature
    Learn how to take voltage measurements
    Learn how to measure current
    Attachments:
    ReShapeGraphExample.vi ‏19 KB

  • Different layout ipad landscape and portrait mode

    I want my ipad landscap layout to be different from my ipad portrait layout, How can I do that?
    Thanks,
    Johan

    When creating a tablet website in Muse, the only thing that will happen when you rotate your iPad is it will scale up or scale down, you can't change the layout since Muse doesn't do re-flow or responsive websites based on browser page width.
    See this thread for a workaround.
    is Muse responsive?

  • Firefox will not print in portrait mode; landscape stuck even in preview mode

    Firefox will not allow printing of a web page in portrait mode. Even print preview selecting portrait shows only landscape printing preview. Tried uninstalling printer, installing Firefox 4, no luck. Printing in portrait mode works fine using IE8 but I'd rather stay with Firefox.
    Any help would be greatly appreciated.
    Thanks in advance,
    George

    Pages version?
    Does the printer driver match the MacOS system?

  • Mail and Messages freeze in landscape/portrait mode

    When in Messages and Mail, my iPhone 5 freezes in landscape or portrait mode.  I can continue to type, edit, etc. but can only get it to rotate after pressing 'Home' button or closing and re-opening app.  I am running 8.0.2.  I notice it most when taking a break for Mail or Messages and turning phone off and when I turn back on.  I'm guessing it is a bug and not a hardware problem because I can always get it to clear by just pressing home or closing app.

    Hello there, HoosierZach1979.
    Great job in coming up with a good workaround for your issue with Mail and Messages. For issues regarding iOS not functioning as expected, the following Knowledge Base article provides a great and practical list of steps for troubleshooting:
    iOS: Not responding or does not turn on
    If a single application is not responding or stops responding when it opens, you can force it to close.
    If the device is unresponsive or if certain controls aren't working as expected,  restart your device.
    If the device remains unresponsive or does not turn on (or power on),  reset your device.
    If there is no video or if the screen remains black, verify that the device has enough charge to turn on:
    If you are using an iPad, ensure that it's connected to the USB Power Adapter supplied with the device.
    Let it charge for at least twenty minutes, then see if it starts normally.
    If there is no image on the screen, press the Sleep/Wake button to attempt to wake the device.
    If the screen displays a red battery icon, continue charging the device until the battery is fully charged. Learn more about charging iPhone and iPod touch, or iPad.
    If the above steps do not resolve the issue, or the if the screen remains black or shows a persistent Apple logo, try restoring with iTunes:
    Connect the device to your computer and open iTunes.
    If the device appears in iTunes, select and click Restore on the Summary pane. Learn more about restoring iOS software.
    If the device doesn't appear in iTunes, try to force the device into recovery mode, and then restore it.
    If the above steps do not resolve the issue, contact Apple.
    Thanks for reaching out to Apple Support Communities.
    Cheers,
    Pedro.

  • IPhone DPS landscape & portrait mode

    Would it be possible to create a DPS iPhone App that takes advantage of both the landscape and portrait mode?

    If you are a pro or enterprise customer and are creating a multi-issue app, yes. We support dual orientation folios on iPhone.
    Your mention of "iPhone app" makes me think you are trying to create a single edition DPS app. Note that we do not support Single Edition at all on iPhone.
    Neil

  • Samsung 244T on Mac OS X - does it rotate to portrait mode?

    I'm thinking of buying a Samsung 24" LCD panel - one of it's more interesting features (for me, at least) is the ability to rotate the panel from landscape to portrait mode - does anyone know if this feature works for sure in MacOS X?
    Dual 2GHz G5   Mac OS X (10.4.7)  

    It doesn't depend on the OS. It depends on the driver for the graphics card. Some Macs do allow rotation and some don't. If you see a rotation option in Display Preferences with your current video card and monitor, then your configuration supports it.

  • Portrait Mode Lock / Orientation Sensor

    If anyone from Apple is reading this, I have a suggestion for improving the iPhone user interface.
    My wife and I are relatively new to our iPhones.  I frequently use the orientation sensor for photos, safari, email and other apps so that I can switch the display from landscape to portrait mode by tilting the phone to the appropriate orientation.  My wife saw me doing this and noted that her iPhone, identical to mine (4s) doesn't do that, and indeed, on examining it, it didn't.  I carefully went through the Settings dialog and the Settings|General dialog and any promising looking page below these and found nothing.  I assumed that the orientation sensor was broken, and we called up Verizon, from whom we bought our phones.
    The (very helpful!) tech person at our local Verizon store had to look this one up, and it took him some time, but he finally located a software switch, accessible by double-tapping the home button - a "Portrait Mode Lock".
    This is an OK location for such a control, along with a general volume control, but this switch should also be available from the Settings menu, along with brightness and other hardware-specific switches.  This is, after all a "hardware setting" and the Settings page is the logical place to look for it.  I would strongly suggest that whether or not this switch is left on the Phone Favorites line, it should be available from somewhere in the Settings page heirarchy.

    No one from Apple is reading this forum, its just a user forum like you and I.
    You can send them a feedback here:
    http://www.apple.com/feedback/

  • Change landscape-and-portrait-folio to landscape-only

    Is it possible after mistakenly having produced a folio with landscape-and-portrait-mode setting it back to landscape-only?
    In the new content viewer, if a folio is set for both landscpae and folio, but only one layout exists, it shows a grey empty page in the second alignment (before it didn't change the alignment and the picture wasn't changed when turning the iPad).
    Now, when you create a new folio, you are asked if this is landscape-and-portrait or portrait-only respectively landscpae-only. We mistakenly have chosen both-alignments and are now having the problem of the empty grey mode in portrait.
    Can this be changed after upload the layouts? Is this also happening within the app itself?

    Hi Bhaskar,
    thanks for your help. My intention is to create a single-orientation layout, but I created a both-orientations-layouts. Before v20 (or 19?) when just uploading one of the orientation into that folio, content viewer and the branded app just showed one orientation and fixed the layout within the iPad. Now, if you choose both-orientations and just upload a single one, you are getting a grey screen in the missing orientation.
    I wasn't aware of this fact (maybe because german customers weren't invited to sprint v20 presentation) but I'm afraid that you are right an  have to created the folio completely from the ground (which is a lot of more work with import function not running )
    Maybe this solves my push notification error with one of my folios I have
    Richard

  • How to view presentation in portrait mode?

    I just bought Keynote for iOS, to present some of my app mockups, but was sadly surprised to learn that I can't rotate a presentation from landscape to portrait mode.
    My canvas is 640x960.
    Anyone know if Apple is aware of this, or if there is a workaround?
    It makes no sense to me why this is not possible. With Apple making iPhones and iPad, it makes no sense that their presentation iOS app doesn't support rotation, and presentation in portrait format...So I have to create my mockups sideways?
    I had hoped to be able to sit and view my Mockup on the iPhone, while I continue to work on it and make changes.

    I have just stitched together a work around to do this for me.
    I was using Keynote to build a file containing some screen shots from a magazine I had a digital version of which I was reading on my iPad and wanted to keep for reference, these were in portrait mode. 
    As we know iPad keynote only let me build Landscape.
    I save keynote files to iCloud and opened same file on my iMac, and using 'Inspector' changed slide size to 768x1204 and realigned screen shots to fit. I saved file again to iCloud and opened it again on my iPad. The new file had the portrait sized slides but still only displayed in Landscape on Keynote, so lots of wasted space and small pages.
    I made a copy of this (Edit, Select, +) and used this to make a 'Portrait Template'.
    So now I can create Keynote file on iPad with portrait sized slides. To see these in full screen just Open In Another App (Edit, curly arrow icon) and open in either GoodReader or PDF Expert. You can send either PDF or native Keynote, both work.

Maybe you are looking for

  • Print GR slip for GR against an Outbound Delivery

    Dear Experts, I have a requirement as below. Need to print GR slip for GR against an Outbound Delivery in VL02N (for Return Orders) What setting needs to be done? I donot see the GR slip check box in VL02N which normally exists in MIGO However, i nee

  • Powerpoint audio

    I have spent a hudge amount of time creating powerpoint slides with voice narration attached directy to shapes(not the slides themselves) with and without animation. After importing into captivate, non of the audio narration plays even the shapes are

  • My txt message app constantly locks up requiring me to reboot the phone. Is there a solution for this ?

    my txt message app constantly locks up requiring me to reboot the phone. Is there a solution for this ?

  • Purchase Order Dunning

    Hi All, I have two questions regarding reminder letters sent to vendors for pending items (as specified in purchasing value key): 1. What is the best way to automate the sending of these dunning letters to vendors? 2. Is there a way to view the dunni

  • Invalid Characters in URL

    I'm trying to pass query variables in a URL. Within the code, the link is (CFM page)?Category=#rsCatSum.category1# The actual URL comes out as (CFM page)?Category=Skin%20Creams%20&%20Lotions%20. The category should show "Skin Creams & Lotions". Howev