Printing a graph from a FormView (SOS)

I'm having problems with printing a CWgraph which is positioned on FormView. (C++)
I tried using the attatched code but it only prints when the graph is positioned on a dialog.
What's the diffrence?
Attachments:
cwprinting.zip ‏80 KB

Ahhh, just a simple C mistake. You have an error in one of your lines with the operator orders. You have the line:
double cInchesTall = cInchesWide * rcGraph.Height() * 60 / rcGraph.Width() * 60;
in your program. This line calculates how tall (in inches) the printout should be based on a fixed width of 6 inches. In our examples the * 60 is not there and that is what is causing your problem. I'm not sure why you have * 60 on your rc width and height, but that is causing the problem. You DON't have parentheses. Therefore your graph height is coming out 3600 times larger than it should. ) That's going to be one HUGE graph. You printer is running out of memory and therefore, you don't get the printout. Change that l
ine to:
double cInchesTall = cInchesWide * (rcGraph.Height() * 60) / (rcGraph.Width() * 60);
or
double cInchesTall = cInchesWide * rcGraph.Height() / rcGraph.Width();
Either one should fix your problem. At least it did for me with your code.
Best Regards,
Chris Matthews
National Instruments

Similar Messages

  • Printing a Graph from viewer

    Hi,
    I have a worksheet along with a Graph in Discoverer Viewer.If I see Printable Page only data is shown.How can I print the data along with the Graph.Any help ?
    P.Velvadivu.

    Graphs are displayed on the same page as the table/crosstab on the printable page.
    Regards
    Discoverer Technical Team

  • Printing problem with PDF graphs from preview

    Whenever I print PDF files from preview or from safari, some graphs print incorrectly, although they are displayed correctly on the screen.  This only happens with black and white figures and either a negative image with the black and white are reversed is printed or the background of the graphic just prints as a black box.  Colour elements are unaffected.  This doesn't happen when printing the same files using Adobe Reader or Adobe Professional.  Any suggestions for tweaking this, or am I going to have to start using the Adobe plugins instead?

    Please try it on Adobe Reader version 10.1.0 ,  Please note that this forum is for Adobe Reader on android and not for PDF Viewer.
    -vaibhav

  • Print Charts/Graphs on Smart Forms

    Hi Seniors,
    Here is a requirement on Smart Forms:
    I need to print Charts on Smart Forms. I have been through many answers on SDN but unfortunately, there are not many appropriate solutions. I executed some standard reports and got Charts and graphs as output but am not able to use it to display the same on Smart Forms. I have even  tried using classes for charts / graphs, business graphics(may be there would have been some sequential procedure for that).
    In the Smart Form, I have tried Form Attributes>Output Options>Output Format--> XSF output
    with output mode: 'Spool' and Output Device: 'XSFOUTDEV' from help.sap(I couldn't get what output device that was and was unable to execute).
    I have tried executing transaction GRAL(demo reports for SAP graphics) too.
    I found a report that would produce graph in Excel, I executed it, saved the graph from excel in '.bmp' format in SE78 and then printed it on Smart Form. But all I want is to have it done dynamically.
    I saw answers that we can save the graph chart/graph onto the desktop, upload it and then display it on the Smart Forms. But, when i tried it, I saw that it could be saved only in '.dat' format. I have to save it dynamically in a supported format like '.bmp' and print it on the Smart Forms(the graph would change depending upon the input values). Please help me resolve this.
    Thanks in Advance,
    Chaitanya.

    Dear Bouman,
    Thank you for the reply. I can write a report if would helps me to upload images dynamically. I saw your program but, here we cant give the name of the chart that comes as output. I tried to save the chart but it comes in '.dat' format but not in '.bmp' format. We may be having some classes or function modules that we need to call in a particular sequence. What other options do we have. Please help me resolve this.
    Regards,
    Chaitanya.C.N

  • Is it possible to print a JPanel from the application?

    Hello,
    Just a quick question: Is it possible to print a JPanel from your application? I have plotted a graph and I would like user to be able to print this with a click of a button (or similar)
    Thanks very much for your help, its appreciated as always.
    Harold Clements

    It is absolutely possible
    Check out my StandardPrint class. Basically all you need to do is
    (this is pseudocode. I don't remember the exact names of methods for all this stuff. Look it up if there's a problem)
    PrinterJob pd = PrinterJob.createNewJob();
    StandardPrint sp = new StandardPrint(yourComponent);
    pd.setPageable(sp);
    //if you want this
    //pd.pageDialog();
    pd.doPrint();You are welcome to have use and modify this class but please don't change the package or take credit for it as your own code.
    StandardPrint.java
    ===============
    package tjacobs.print;
    import java.awt.*;
    import java.awt.image.BufferedImage;
    import java.awt.print.*;
    import javax.print.PrintException;
    public class StandardPrint implements Printable, Pageable {
        Component c;
        SpecialPrint sp;
        PageFormat mFormat;
         boolean mScale = false;
         boolean mMaintainRatio = true;
        public StandardPrint(Component c) {
            this.c = c;
            if (c instanceof SpecialPrint) {
                sp = (SpecialPrint)c;
        public StandardPrint(SpecialPrint sp) {
            this.sp = sp;
         public boolean isPrintScaled () {
              return mScale;
         public void setPrintScaled(boolean b) {
              mScale = b;
         public boolean getMaintainsAspect() {
              return mMaintainRatio;
         public void setMaintainsAspect(boolean b) {
              mMaintainRatio = b;
        public void start() throws PrinterException {
            PrinterJob job = PrinterJob.getPrinterJob();
            if (mFormat == null) {
                mFormat = job.defaultPage();
            job.setPageable(this);
            if (job.printDialog()) {
                job.print();
        public void setPageFormat (PageFormat pf) {
            mFormat = pf;
        public void printStandardComponent (Pageable p) throws PrinterException {
            PrinterJob job = PrinterJob.getPrinterJob();
            job.setPageable(p);
            job.print();
        private Dimension getJobSize() {
            if (sp != null) {
                return sp.getPrintSize();
            else {
                return c.getSize();
        public static Image preview (int width, int height, Printable sp, PageFormat pf, int pageNo) {
            BufferedImage im = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
            return preview (im, sp, pf, pageNo);
        public static Image preview (Image im, Printable sp, PageFormat pf, int pageNo) {
            Graphics2D g = (Graphics2D) im.getGraphics();
            int width = im.getWidth(null);
            int height = im.getHeight(null);
            g.setColor(Color.WHITE);
            g.fillRect(0, 0, width, height);
            double hratio = height / pf.getHeight();
            double wratio = width / pf.getWidth();
            //g.scale(hratio, wratio);
            try {
                   sp.print(g, pf, pageNo);
              catch(PrinterException pe) {
                   pe.printStackTrace();
            g.dispose();
            return im;
        public int print(Graphics gr, PageFormat format, int pageNo) {
            mFormat = format;
            if (pageNo > getNumberOfPages()) {
                return Printable.NO_SUCH_PAGE;
            Graphics2D g = (Graphics2D) gr;
              g.drawRect(0, 0, (int)format.getWidth(), (int)format.getHeight());
            g.translate((int)format.getImageableX(), (int)format.getImageableY());
            Dimension size = getJobSize();
              if (!isPrintScaled()) {
                 int horizontal = getNumHorizontalPages();
                 int vertical = getNumVerticalPages();
                 int horizontalOffset = (int) ((pageNo % horizontal) * format.getImageableWidth());
                 int verticalOffset = (int) ((pageNo / vertical) * format.getImageableHeight());
                 double ratio = getScreenRatio();
                 g.scale(1 / ratio, 1 / ratio);
                 g.translate(-horizontalOffset, -verticalOffset);
                 if (sp != null) {
                     sp.printerPaint(g);
                 else {
                     c.paint(g);
                 g.translate(horizontal, vertical);
                 g.scale(ratio, ratio);
              else {
                 double ratio = getScreenRatio();
                 g.scale(1 / ratio, 1 / ratio);
                   double xScale = 1.0;
                   double yScale = 1.0;
                   double wid;
                   double ht;
                   if (sp != null) {
                        wid = sp.getPrintSize().width;
                        ht = sp.getPrintSize().height;
                   else {
                        wid = c.getWidth();
                        ht = c.getHeight();
                   xScale = format.getImageableWidth() / wid;
                   yScale = format.getImageableHeight() / ht;
                   if (getMaintainsAspect()) {
                        xScale = yScale = Math.min(xScale, yScale);
                   g.scale(xScale, yScale);
                   if (sp != null) {
                        sp.printerPaint(g);
                   else {
                        c.paint(g);
                   g.scale(1 / xScale, 1 / yScale);
                   g.scale(ratio, ratio);
             g.translate((int)-format.getImageableX(), (int)-format.getImageableY());     
            return Printable.PAGE_EXISTS;
        public int getNumHorizontalPages() {
            Dimension size = getJobSize();
            int imWidth = (int)mFormat.getImageableWidth();
            int pWidth = 1 + (int)(size.width / getScreenRatio() / imWidth) - (imWidth == size.width ? 1 : 0);
            return pWidth;
        private double getScreenRatio () {
            double res = Toolkit.getDefaultToolkit().getScreenResolution();
            double ratio = res / 72.0;
            return ratio;
        public int getNumVerticalPages() {
            Dimension size = getJobSize();
            int imHeight = (int)mFormat.getImageableHeight();
            int pHeight = (int) (1 + (size.height / getScreenRatio() / imHeight)) - (imHeight == size.height ? 1 : 0);
            return pHeight;
        public int getNumberOfPages() {
              if (isPrintScaled()) return 1;
            return getNumHorizontalPages() * getNumVerticalPages();
        public Printable getPrintable(int i) {
            return this;
        public PageFormat getPageFormat(int page) {
            if (mFormat == null) {
                PrinterJob job = PrinterJob.getPrinterJob();
                mFormat = job.defaultPage();
            return mFormat;
    }

  • How can I chose a printer to print my graph?

    hi,
    how can I chose a printer to print my graph? At the moment I can print only with the standard printer, but I want to chose different printers, because I have three printers. How can I solve this in Labview? Is there a property in the property node or a VI?

    If you have the Report Generation Toolkit you can use the Qurey Available Printers.vi to get a list of printers configured for your PC, write a vi to select from this list, and pass that printer to the Print Report.vi.
    If you don't have the toolkit, you can use the property node (located under the Application Control palette), Printing:Available Printers property to obtain a list of printer names programmatically, then write a vi to select from the list, and pass that printer to the Printingefault Printer property to set the default printer in LabVIEW programmatically.

  • Print stretched graph image

    I'm looking for a way to print a cwgraph stretched on a complete page ( larger then screen size)
    Is there one?

    To update the example code so that it behaves differently from only using half of the page like you're seeing, look at this section of the code in OnPrintBestFit:
    if (bResizeGraph) {
    // create a rectangle to resize the graph to (on the screen)
    CRect rcNew;
    rcNew.left = 0;
    rcNew.top = 0;
    rcNew.right = (long)(cInchesWide * logicalPixelsPerInchX_Screen);
    rcNew.bottom = (long)(cInchesTall * logicalPixelsPerInchY_Screen);
    // resize the graph so it will render larger (with more detail)
    // the FALSE tells it to not redraw
    m_Graph.MoveWindow(rcNew, FALSE);
    // Calculate a rectangle (in printer coordinates) to print the
    // graph in.
    rc.left = 0;
    rc.top = 0
    rc.right = (long)(cInchesWide * logicalPixelsPerInchX_Printer);
    rc.bottom = (long)(cInchesTall * logicalPixelsPerInchY_Printer);
    Adjust the calculation for the rcNew.bottom and rc.bottom according to what you want.
    - Elton

  • Print Dynamic Graph

    I have created a graph with a large number of samples on the X-axis, so the FULL graph can only be viewed using a horizontal scroller. But while printing the graph I am unable to get a print of the entire graph (only the viewable area is printed). Similarly for saving, I am not able to save the entire Length of the graph. Since my data is variable, I cannot have a fixed limit on the X-axis, so a horizontal scroller is a must to view. Any help in this regards would be highly appreciated.
    thnx,
    -prak

    Before drawing the graph onto the panel, draw the graph in its entirety onto an offscreen buffer. Then, copy the viewable portion of the graph onto the panel. Print from the offscreen buffer.

  • Is it possible to call the Print Quote functionality from Custom ADF page

    Hi,
    We are researching if it is possible to call the Print Quote functionality from the Custom ADF application.
    Goal is to pop up the PDF report upon clicking the Print Quote button on the custom page. Is it possible ?
    Atleast advice on the direction to go forward is appreciated.
    Thanks
    Sai

    Hi ,
    Please check following thread on forum -
    Re: ADF: Calling OAF Page from ADF page
    Check this may also be useful-
    https://blogs.oracle.com/shay/entry/to_adf_or_oaf_or
    I have not tried yet but Steven Chan (Sr. Director OATG) suggest following methodolgy for this-
    https://blogs.oracle.com/stevenChan/entry/appsdatasource_jaas_ebs
    Thanks,
    Ashish

  • Print a report from Application Express direct to a CUPS Printer

    Hi all, I'm new to this technology, is it possible to print a report from Application Express directly to a CUPS Printer? Can someone tell me in laymans terms how to do it? I find the terminology and documentation less than helpful.

    Jeremy,
    BI Publisher handles submitting reports directly to a CUPS printer. However, the APEX integration doesn't currently integrate with that portion of BI Publisher.
    Here's an options:
    Use the Java API of BI Publisher to build a custom Java program that would do this for you. Delivering to CUPS is part of the Java API.
    Bryan

  • Print Message Report from Mobile

    Hello...
    We need modify standard mobile infrastructure java code...
    We need print some report from Mobile Front-end.
    Is possible to print all MESSAGE data that we can see from front-end of mobile infrastructure 2.5 ???
    thank you very much
    Stefano

    I haven't really done much enhancements on MAM 2.5, but Im sure sami will let you know where to add the code, or you can review the MAM enhancement guide on the CD.
    In regards to printing the PIOS API is pretty simple. If you are using a laptop to print to a normal printer then you can just use the Win32 Drivers..(installed via driver addon from web sap console.)If you are using the handheld you will need to find the appropriate drivers.
    Here is some code I used in one of my applications:
                   <i>Connector conn = Connector.getInstance();
                   DriverInfo[] driverInfo = conn.listDrivers(ConnectionType.PRINTER);
                   PrinterParameters params = new PrinterParameters(driverInfo[0]);
                   params.setPrinterMode(PrinterParameters.GRAPHIC_MODE);
                   GraphicPrinter gp = (GraphicPrinter) conn.open(params);
                   File myImage = new File("c:
    smalllogo.bmp");
                   if (myImage.exists()) {
                        float x = 0;
                        float y = 50;
                        try {
                             String[] sFonts =
                                  gp.getFontConfigurationManager().listFontNames();
                             PrinterFont pf = gp.getFont(sFonts[0]);
                             gp.drawText(
                                  pf,
                                  25,
                                  25,
                                  "TO For Delivery # = "
                                       + dbAccess.getItemFieldValue(arrayItems[0], "VBELN"),
                                  GraphicPrinter.NO_ROTATION);
                             for (i = 0; i < arrayItems.length; i++) {
                                  gp.drawText(
                                       pf,
                                       25,
                                       y,
                                       "Delivery Item # = "
                                            + dbAccess.getItemFieldValue(
                                                 arrayItems<i>,
                                                 "POSNR"),
                                       GraphicPrinter.NO_ROTATION);
                                  y = y + 10;
                                  gp.drawText(
                                       pf,
                                       25,
                                       y,
                                       "Material # = "
                                            + dbAccess.getItemFieldValue(
                                                 arrayItems<i>,
                                                 "MATNR"),
                                       GraphicPrinter.NO_ROTATION);
                                  y = y + 10;
                                  gp.drawText(
                                       pf,
                                       25,
                                       y,
                                       "Quantity to Pick = "
                                            + dbAccess.getItemFieldValue(
                                                 arrayItems<i>,
                                                 "LFIMG"),
                                       GraphicPrinter.NO_ROTATION);
                                  y = y + 25;
                   gp.doPrint(1);
                   gp.close();
              } catch (Throwable tFile) {
                   tFile.printStackTrace();
              }<i>
    This should give you an idea, you should also read through the MDK documentation for the printer API (PIOS). Its quite easy to pick up and as long as you have the driver and connector installed it prints right away.(You could also use the Peripheral emulator in
    NWDS to test the code first)
    Hope this helps,
    Wael..
    Dont forget the rewards
    Message was edited by: wael aoudi

  • I cant seem to print in color from iphoto

    when ever i try to print from iphoto it only prints in color....what do i do?

    i cant seem to print in color from iphoto
    tdav18 wrote:
    when ever i try to print from iphoto it only prints in color....what do i do?
    Please restate your question - your title and   question are different - I have no idea what you want to do
    LN

  • Is there any way to print a photo from my iphone on plain paper on my photosmart plus printer?

    Whenever I try to use Airprint to print a photo from my iPhone to my Photosmart Plus printer, it tries to print it on photo paper from the photo paper tray.
    I want it to print on the plain paper in the regular tray.
    I read online where this is possible with the iPrint app - but when I went to the App Store, there is no iPrint App.  I found a sticky post here saying that it has been removed from the App Store in anticipation of a new ePrint Home & Business version that won't be available everywhere until September.
    So, in the meantime, is there anyway to change the location of where the photos from the iPhone print?
    Thanks in advance for any assistance.

    HI
    Most likely their is not, as printing pictures is standard set to photopaper as you most likely need good quality. Pictures on normal paper are not considered good quaity and thus not set as standard.
    Say "Thanks" by clicking the Kudos Star in the post that helped you.
    Although I work for HP my posts and replies are my own
    Please mark the post that solves your problem as "Accepted Solution"

  • I just updated my Ipad 2 last night with iOS 7.04 now I can't print shipping labels from Paypal. I downloaded a different browser, Dolphin, per Paypal's suggestion. Still can not print. It says it has lost connection with the server.help!.

    Hello! I updated my Ipad now I can not print USPS labels from Paypal. I used my boss' Ipad not updated and worked fine. I am dependent on my Ipad to print these labels for me. I can print anything else I want, like email or packing slips. Any thoughts? I would go back to the previous version if anyone knows how to do that.

    Hello Sapo11,
    To get your issue more exposure I would suggest posting it in the commercial forums since this is a commercial product. You can do this at Commercial Forums.
    Thanks for your time.
    Click the “Kudos Thumbs Up" at the bottom of this post to say “Thanks” for helping!
    Please click “Accept as Solution ” if you feel my post solved your issue, it will help others find the solution.
    W a t e r b o y 71
    I work on behalf of HP

  • When trying to print to PDF from a sales program we use it keeps throwing errors

    When several people try to print to PDF from MAS90, it will save it and create a file as it normally does. However, it does not open in Acrobat 9 Pro as it normally does, and displays the famous error "Acrobat could not open 'xxxx.pdf' because it is either not a supported..."  Yet when you manually open the file from the file system, it opens just fine.
    So to rehash what I just said, when I print to pdf, it asks me where to save, the notification said the printing completed, adobe opens and displays error. If you click on the file, then the file opens just fine.
    However several other people do not have this error while trying to print to file from mas90. Does anyone out there have any idea what could possibly be causing this error to be displayed?

    Hi ftd12300,
    Are you saving the PDFs you're creating to a network drive or are they being saved locally? 
    Do you have this problem when creating PDFs from other applications such as Notepad?
    -David

Maybe you are looking for

  • How to connect Lumia 820 with Sony DSX A50BT

    Hi, In my car am my mobile(Nokia Lumia 820) not able to connect with Sony DSX - A50 BT. Is there any additional setting s require . Please share the procedure. Thanks & Regards, Anuj Mittal

  • How to know value of a feild in IDOC for further proccessing

    Hi Guys , I am receiving different sets of IDOC's  in XI with same structure but different Instances.There is feild called company ID in every IDOC._I need to count the number of Idoc's received from a particular companyID and group them_. I came to

  • Error while entering number range

    Dear All While entering number ranges for Assets using t-code AS08 i am getting the following error: Company code........ 2000 does not exist Message no. NR011 The company code 2000 is assigned to Chart of depreciation also. Please advice. Thanks & R

  • When I try to open links from Incredimail, nothing happens.

    I just got a new computer with Windows 7. I transferred my Incredimail 2 account over installed Firefox 14.0.1. When I try to click on links in my email, nothing happens. Could there be a compatibility issue with with the newest version of Firefox an

  • ITunes library.itl file is locked?? please help

    I downloaded iTunes and tried to open it and it says that the library.itl file is locked on a locked disc or I do not have write permission for this file.....very confused can someone please help me.....Thanx