Printing .GIF images with PHP

Hello,
As part of a PHP IF statement, I would like to print an image
instead of text. How do I do this?
Thanks in advance,
John

I've done some dabbling in PHP's GD library (the image
manipulation extension of PHP).
What I have done in the past is create a separate php file
just for the image output. I then pass in the parameters needed to
create the image in the image request. So as an example, I'd send
the image request like so:
http://domain.com/preview_image.php?text_string=Type%20Text%20Here&text_color=black&bg_col or=white&font=ADORABLE
preview_image.php is the php file that contains the script to
generate the image based off of the text_string, text_color, and
bg_color variables contained in the query parameters.
Or if you don't need a dynamic image, just echo the image tag
inside the if statement:
echo "<img src='pathtoimage.jpg'>;

Similar Messages

  • Problem uploading images with php script.

    As a webdebdesigner i developped a cms system to upload images with php to a mysql database. Firefox version 5.0.1 for MAC and earlier have no problems with uploading through the script. But after that version it is impossible to upload images bigger then 250kb. The page where the customer chooses his image for upload stalls and the form is not sent to the actual upload script, which should validate and process the image.
    This problem only occurs in Firefox, all other browsers work just fine!
    On top of that: Giving feedback to firefox not possible for MAC.

    Try posting at the Web Development / Standards Evangelism forum at MozillaZine. The helpers over there are more knowledgeable about web site development issues with Firefox. <br />
    http://forums.mozillazine.org/viewforum.php?f=25 <br />
    You'll need to register and login to be able to post in that forum.

  • Print a image with the standard pdf-print function

    hello,
    we have a Web-Template with a query a chart an the company-image.
    When we want to print the Web-Template with the pdf button, then we get only the query and the chart in the PDF.
    What can I do, that I get also the image in de PDF-Print-Layout?
    I tried it with a .png and a .gif image.
    Thank you very much!
    Best reagards,
    andreas

    hi,
    at the time I have no solution for this problem.

  • How to Print GIF image in XML RTF Report

    Hi All,
    I have one requirement like to print the GIF image in Oracle Report.
    The report is an XML Report.
    The image file stored in database, the table is fnd_attached_docs_form_vl.
    select distinct file_name from fnd_attached_docs_form_vl
    Front end Navigation ----->
    view -----> Attachments
    Now i need to get the image from there and print it report.
    Can you pls help me.
    Regards
    Venu

    Hi,
    I didn't tried that scenario as my report is not a Non-XML Report.
    And my report is XML Report.
    Regards
    Venu

  • Action to: Print current document to PDF Printer "As Image" with Specified DPI

    I FREQUENTLY do the following task on documents.  I would LOVE to have an action that did it for me.  Can someone help me create one or point me to someone who can?
    Version: Adobe Acrobat X Pro.  Windows 7 64-bit
    With current PDF file open:
    2) Print
    3) Select PDF Printer
    4) (Under advanced printer settings) choose "Print as Image", "150" DPI.
    5) OK
    6) Save file AS the original with _printed appended to the filename.
    Image1: Printer dialogue box
    Image 2: After selecting the PDF Printer and pressing "Advanced"

    The forum added some nice links and i found my answer here http://forums.adobe.com/message/1179199#1179199 - changed the registry key permissions and it's working like a charm. Thank you.

  • Load, crop and saving jpg and gif images with JFileChooser

    Hello!
    I wonder is there someone out there who can help me with a applic that load, (crop) and saving images using JFileChooser with a simple GUI as possible. I'm new to programming and i hope someone can show me.
    Tor

    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;
    import java.io.*;
    import javax.imageio.ImageIO;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.filechooser.*;
    import javax.swing.filechooser.FileFilter;
    public class ChopShop extends JPanel {
        JFileChooser fileChooser;
        BufferedImage image;
        Rectangle clip = new Rectangle(50,50,150,150);
        boolean showClip = true;
        public ChopShop() {
            fileChooser = new JFileChooser(".");
            fileChooser.setFileFilter(new ImageFilter());
        public void setClip(int x, int y) {
            clip.setLocation(x, y);
            repaint();
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            if(image != null) {
                int x = (getWidth() - image.getWidth())/2;
                int y = (getHeight() - image.getHeight())/2;
                g2.drawImage(image, x, y, this);
            if(showClip) {
                g2.setPaint(Color.red);
                g2.draw(clip);
        public Dimension getPreferredSize() {
            int width = 400;
            int height = 400;
            int margin = 20;
            if(image != null) {
                width = image.getWidth() + 2*margin;
                height = image.getHeight() + 2*margin;
            return new Dimension(width, height);
        private void showOpenDialog() {
            if(fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
                File file = fileChooser.getSelectedFile();
                try {
                    image = ImageIO.read(file);
                } catch(IOException e) {
                    System.out.println("Read error for " + file.getPath() +
                                       ": " + e.getMessage());
                    image = null;
                revalidate();
                repaint();
        private void showSaveDialog() {
            if(image == null || !showClip)
                return;
            if(fileChooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
                File file = fileChooser.getSelectedFile();
                String ext = ((ImageFilter)fileChooser.getFileFilter()).getExtension(file);
                // Make sure we have an ImageWriter for this extension.
                if(!canWriteTo(ext)) {
                    System.out.println("Cannot write image to " + ext + " file.");
                    String[] formatNames = ImageIO.getWriterFormatNames();
                    System.out.println("Supported extensions are:");
                    for(int j = 0; j < formatNames.length; j++)
                        System.out.println(formatNames[j]);
                    return;
                // If file exists, warn user, confirm overwrite.
                if(file.exists()) {
                    String message = "<html>" + file.getPath() + " already exists" +
                                     "<br>Do you want to replace it?";
                    int n = JOptionPane.showConfirmDialog(this, message, "Confirm",
                                                          JOptionPane.YES_NO_OPTION);
                    if(n != JOptionPane.YES_OPTION)
                        return;
                // Get the clipped image, if available. This is a subImage
                // of image -> they share the same data. Handle with care.
                BufferedImage clipped = getClippedImage();
                if(clipped == null)
                    return;
                // Copy the clipped image for safety.
                BufferedImage cropped = copy(clipped);
                boolean success = false;
                // Write cropped to the user-selected file.
                try {
                    success = ImageIO.write(cropped, ext, file);
                } catch(IOException e) {
                    System.out.println("Write error for " + file.getPath() +
                                       ": " + e.getMessage());
                System.out.println("writing image to " + file.getPath() +
                                   " was" + (success ? "" : " not") + " successful");
        private boolean canWriteTo(String ext) {
            // Support for writing gif format is new in j2se 1.6
            String[] formatNames = ImageIO.getWriterFormatNames();
            //System.out.printf("writer formats = %s%n",
            //                   java.util.Arrays.toString(formatNames));
            for(int j = 0; j < formatNames.length; j++) {
                if(formatNames[j].equalsIgnoreCase(ext))
                    return true;
            return false;
        private BufferedImage getClippedImage() {
            int w = getWidth();
            int h = getHeight();
            int iw = image.getWidth();
            int ih = image.getHeight();
            // Find origin of centered image.
            int ix = (w - iw)/2;
            int iy = (h - ih)/2;
            // Find clip location relative to image origin.
            int x = clip.x - ix;
            int y = clip.y - iy;
            // clip must be within image bounds to continue.
            if(x < 0 || x + clip.width  > iw || y < 0 || y + clip.height > ih) {
                System.out.println("clip is outside image boundries");
                return null;
            BufferedImage subImage = null;
            try {
                subImage = image.getSubimage(x, y, clip.width, clip.height);
            } catch(RasterFormatException e) {
                System.out.println("RFE: " + e.getMessage());
            // Caution: subImage is not independent from image. Changes
            // to one will affect the other. Copying is recommended.
            return subImage;
        private BufferedImage copy(BufferedImage src) {
            int w = src.getWidth();
            int h = src.getHeight();
            BufferedImage dest = new BufferedImage(w, h, src.getType());
            Graphics2D g2 = dest.createGraphics();
            g2.drawImage(src, 0, 0, this);
            g2.dispose();
            return dest;
        private JPanel getControls() {
            JPanel panel = new JPanel(new GridBagLayout());
            GridBagConstraints gbc = new GridBagConstraints();
            gbc.weightx = 1.0;
            gbc.fill = GridBagConstraints.HORIZONTAL;
            gbc.gridwidth = GridBagConstraints.REMAINDER;
            panel.add(getCropPanel(), gbc);
            panel.add(getImagePanel(), gbc);
            return panel;
        private JPanel getCropPanel() {
            JToggleButton toggle = new JToggleButton("clip", showClip);
            toggle.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    showClip = ((AbstractButton)e.getSource()).isSelected();
                    repaint();
            SpinnerNumberModel widthModel = new SpinnerNumberModel(150, 10, 400, 1);
            final JSpinner widthSpinner = new JSpinner(widthModel);
            SpinnerNumberModel heightModel = new SpinnerNumberModel(150, 10, 400, 1);
            final JSpinner heightSpinner = new JSpinner(heightModel);
            ChangeListener cl = new ChangeListener() {
                public void stateChanged(ChangeEvent e) {
                    JSpinner spinner = (JSpinner)e.getSource();
                    int value = ((Number)spinner.getValue()).intValue();
                    if(spinner == widthSpinner)
                        clip.width = value;
                    if(spinner == heightSpinner)
                        clip.height = value;
                    repaint();
            widthSpinner.addChangeListener(cl);
            heightSpinner.addChangeListener(cl);
            JPanel panel = new JPanel(new GridBagLayout());
            GridBagConstraints gbc = new GridBagConstraints();
            gbc.insets = new Insets(2,2,2,2);
            gbc.weightx = 1.0;
            panel.add(toggle, gbc);
            addComponents(new JLabel("width"),  widthSpinner,  panel, gbc);
            addComponents(new JLabel("height"), heightSpinner, panel, gbc);
            return panel;
        private void addComponents(Component c1, Component c2, Container c,
                                   GridBagConstraints gbc) {
            gbc.anchor = GridBagConstraints.EAST;
            c.add(c1, gbc);
            gbc.anchor = GridBagConstraints.WEST;
            c.add(c2, gbc);
        private JPanel getImagePanel() {
            final JButton open = new JButton("open");
            final JButton save = new JButton("save");
            ActionListener al = new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    JButton button = (JButton)e.getSource();
                    if(button == open)
                        showOpenDialog();
                    if(button == save)
                        showSaveDialog();
            open.addActionListener(al);
            save.addActionListener(al);
            JPanel panel = new JPanel();
            panel.add(open);
            panel.add(save);
            return panel;
        public static void main(String[] args) {
            ChopShop chopShop = new ChopShop();
            ClipMover mover = new ClipMover(chopShop);
            chopShop.addMouseListener(mover);
            chopShop.addMouseMotionListener(mover);
            JFrame f = new JFrame("click inside rectangle to drag");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(new JScrollPane(chopShop));
            f.getContentPane().add(chopShop.getControls(), "Last");
            f.pack();
            f.setLocation(200,100);
            f.setVisible(true);
    class ImageFilter extends FileFilter {
        static String GIF = "gif";
        static String JPG = "jpg";
        static String PNG = "png";
        // bmp okay in j2se 1.5+
        public boolean accept(File file) {
            if(file.isDirectory())
                return true;
            String ext = getExtension(file).toLowerCase();
            if(ext.equals(GIF) || ext.equals(JPG) || ext.equals(PNG))
                return true;
            return false;
        public String getDescription() {
            return "gif, jpg, png images";
        public String getExtension(File file) {
            String s = file.getPath();
            int dot = s.lastIndexOf(".");
            return (dot != -1) ? s.substring(dot+1) : "";
    class ClipMover extends MouseInputAdapter {
        ChopShop component;
        Point offset = new Point();
        boolean dragging = false;
        public ClipMover(ChopShop cs) {
            component = cs;
        public void mousePressed(MouseEvent e) {
            Point p = e.getPoint();
            if(component.clip.contains(p)) {
                offset.x = p.x - component.clip.x;
                offset.y = p.y - component.clip.y;
                dragging = true;
        public void mouseReleased(MouseEvent e) {
            dragging = false;
        public void mouseDragged(MouseEvent e) {
            if(dragging) {
                int x = e.getX() - offset.x;
                int y = e.getY() - offset.y;
                component.setClip(x, y);
    }

  • Opening gif images with AEGP_NewFootage

    Hey guys,
    For some reason it does not work. JPEGs work properly. Any idea?
    Thanks,
    Eran

    Same thing for me in vista 64 bit and Windows 7 RC. Random.
    Just letting you know your not the only one.
    Ok, not trying to hi-jack. If I use paint shop pro or the windows 7 RC paint program to open a image then close it, then I open bridge and double click a image, Paint shop Pro or wndows 7 paint will open with the image showing. I have to close the program, open bridge, right click on the image and select CS4 to open the file. After that Bridge will have CS4 open files. So the random opening might be related? Who knows!
    Ricky-T wrote:
    Hi,
    This problem has happened to me quite a bit only with CS4, so i thought i'd finally ask. Practically all of my images are set to open with Photoshop. My probelm is that many times, i double click an image on my computer to open it in photoshop, and then photoshop comes up and doesnt open it or even attempt to. The image usually does open if photoshop is currently not open, and is lanuched by double clicking the image though. The problem seems very random and does it to JPEG's, PNG's, GIF's and BMP's and TIFF's as far as i am awear. PSD's seem fine. Note that this problem has not been resolved by resetting preferences as i have recently doen that and it is still here. Any suggestions on how to make it work?

  • Random background-image with PHP

    I would like to have random images as background-images on a
    page. So I
    made a rotate.php ("SELECT picsid, picsurl FROM pics WHERE
    picsite =
    'home' ORDER BY MD5(RAND()) limit 1") with
    <img src="<?php echo $row_rsimages['picsurl']; ?>"
    alt="" />
    Then I put the following rule into the css-file:
    #pics {
    width: 400px;
    height: 200px;
    background-color: #fff;
    background-image: url(banner.php);
    background-repeat: no-repeat;
    background-position: top left;
    Finally I inserted a div called #pics on the index.php and
    previewed the
    page, and - you are right ;) - the images are not displayed.
    Where have I failed?
    Martin Lang

    Martin Lang wrote:
    > I would like to have random images as background-images
    on a page. So I
    > made a rotate.php
    > background-image: url(banner.php);
    > Where have I failed?
    In several places.
    1. Presumably banner.php is the page that you earlier refer
    to as
    rotate.php. The name should be the same.
    2. It looks as though you're trying to use an <img> tag
    to display a
    background image. That won't work.
    3. If you want banner.php to display an image, you need to
    send the
    correct MIME header and stream the image as a download.
    // code to select the image
    $filepath = '/home/mysite/htdocs/images/'; // path to image
    folder
    $image = $filepath.$row_rsimages['picsurl'];
    if (file_exists($image) && is_readable($image)) {
    $size = filesize($image);
    header('Content-type: image/jpeg');
    header('Content-length: '.$size);
    $file = @fopen($image, 'rb');
    if ($file) {
    fpassthru($file);
    It's actually a lot simpler to do everything in the same
    page.
    Put the recordset at the top of the page to select the random
    image.
    Then put the style block in the head of the document:
    <style type="text/css">
    #pics {
    width: 400px;
    height: 200px;
    background-color: #fff;
    background-image: url(<?php echo $row_rsimages['picsurl'];
    ?>);
    background-repeat: no-repeat;
    background-position: top left;
    </style>
    David Powers, Adobe Community Expert
    Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
    Author, "PHP Solutions" (friends of ED)
    http://foundationphp.com/

  • Can't Print Large Images With PrintJob()

    Hey all,
    I'm having an issue where when I try to print a larger image
    via printjob one of two things happens. One either the job fails or
    two the output of the image is literally diagonally cut off. I am
    simply passing the stage to the print job. I've tried both with and
    without using printAsBitmap. Anyone encounter anything like
    that?

    nope. but you'll need to scale your stage to fit the
    page.

  • ¿Print multiple images with specific settings all at once?

    Hi,
    I have never been able to fully get the Automator to work...
    Here's my scenario.
    I use Fedex Online to make labels and use their adhesive labels, but I usually need to print about 17 at a time... So instead of printing 1 by 1... I save the PNG files... Then I setup a template in pages, with 17 pages and replace each image 1 by 1, then print....
    Which is a lot of work, then I have to double check to make sure I didn't duplicate 1 form, etc...
    SO what can I do to A. Get them to print all at once and B. Make sure they are setup to print to the FEDEX labels margins (Right/Left: .5", top .375", bottom 5.5")?
    I already made a custom page setting in page setup...
    hopefully someone can offer some insight
    Thanks

    Another thing I tried was to save images into a pdf, but I don't know where the PDF is saved to...
    What is the order that I am supposed to do things in?
    What I have now is:
    1. Get specified Finder items (I have the items selected)
    2. Compress Images into PDF Document
    Now what? When I press play, it seems to work, but I don't know where the PDF is saved...

  • Printing Mirror Image with 9.x

    I have an issue which others have also reported: ANY pdf printed from Adobe Reader 9.x prints as a mirror image!!! This is NOT a printer driver problem.
    Information: I have 4 computers on a network and a network printer supporting them (HP Officejet L7680). I had Adobe Reader v8.x on all 4 machines - 3 Windows XP, 1 Vista64. All printing/viewing was normal.
    I decided to upgrade my Vista64 machine to Adobe 9.x (currently v9.2). That was a mistake. Now, every pdf printed from that machine prints as a mirror image of the pdf. I do not see any kind of printer option under Adobe or my printer to print as a mirror image.
    So, 3 Windows XP machines with Adobe 8.x print fine; 1 Vista64 machine with Adobe 8.x printed fine; 1 Vista64 machine upgraded to Adobe 9.x does NOT print correctly.
    This problem has cropped up with enough frequency that there is some sort of Adobe 9.x problem. A quick internet search will show the extent of this issue.
    Any solutions? (Otherwise, my thoughts are to delete 9.x and find 8.x.)
    Ken

    Update: 9.x is STILL broken. I have deleted 9.x and downgraded back to 8.x. Using 8.x all the printing is normal.
    Since this mirror image printing issue is NOT isolated to a single user, but rather, based on the number of complaints about mirror image printing found on the internet, a prevalant problem, how about ADDRESSING it?
    Ken

  • Need to print in image with good quality in multiple pages

    rinting of the image display area is to small to read on some large displays
    Need to restrict the image resizing in generating the print output to a minimum size (to allow it to be readable) and allow the printed output to flow into a multiple pages wide by multiple pages in length if necessary. Currently it is restricted to one page.
    below is the code
    public int print(Graphics g, PageFormat pageFormat, int pageIndex) throws PrinterException {
    if (pageIndex != 0)
    return NO_SUCH_PAGE;
    Graphics2D g2d = (Graphics2D) g;
    Rectangle2D.Double printBounds = new Rectangle2D.Double(
    pageFormat.getImageableX(),
    pageFormat.getImageableY(),
    pageFormat.getImageableWidth(),
    pageFormat.getImageableHeight()
    // Print the header and reduce the height for printing
    float headerHeight = printHeader(printBounds, g2d);
    printBounds.y += headerHeight;
    printBounds.height -= headerHeight;
    // Carve off the amount of space needed for the footer
    printBounds.height -= getFooterHeight(g2d);
    // Print the nodes and edges
    printDisplay( printBounds, g2d, 0 );
    if (footer != null) {
    printBounds.y += (printBounds.height + 15);
    printFooter(printBounds, g2d);
    return PAGE_EXISTS;
    =================================
    protected void printDisplay( Rectangle2D.Double printBounds, Graphics2D g2d, double margin ) {
    // Get a rectangle that represents the bounds of all of the DisplayEntities
    Rectangle r = null;
    for (Enumeration e=displayManager.getEntitySet().getEntityEnumerati on();e.hasMoreElements();) {
    DisplayEntity de = (DisplayEntity)e.nextElement();
    if (r == null)
    r = de.getBounds();
    else
    r = r.union(de.getBounds());
    // Get that as doubles, rather than ints, and expand by half the margin
    // height in all directions
    Rectangle2D.Double entityBounds = new Rectangle2D.Double(r.x,r.y,r.width,r.height);
    entityBounds.x -= margin/2;
    entityBounds.y -= margin/2;
    entityBounds.width += margin;
    entityBounds.height += margin;
    // See if height and/or width was specified
    Unit specifiedSize = configuration.getHeight();
    double printHeight = (specifiedSize != null) ?
    specifiedSize.getValueAsPixels((int)printBounds.he ight) :
    printBounds.height;
    specifiedSize = configuration.getWidth();
    double printWidth = (specifiedSize != null) ?
    specifiedSize.getValueAsPixels((int)printBounds.wi dth) :
    printBounds.width;
    // Figure out the ratio of print-bounds to the entities' bounds
    double scaleX = 1;
    double scaleY = 1;
    // See if we need to scale
    boolean canExpand = configuration.expandToFit();
    boolean canShrink = configuration.shrinkToFit();
    if (canExpand == false && canShrink == false) {
    scaleX = scaleY = configuration.getScale();
    else {
    if ((canShrink && canExpand) ||
    (canShrink &&
    (entityBounds.width > printWidth ||
    entityBounds.height > printHeight)) ||
    (canExpand &&
    (entityBounds.width < printWidth ||
    entityBounds.height < printHeight))) {
    scaleX = printWidth / entityBounds.width;
    scaleY = printHeight / entityBounds.height;
    if (configuration.maintainAspectRatio()) { // Scale the same
    if (scaleX > scaleY)
    scaleX = scaleY;
    else
    scaleY = scaleX;
    above methods am using for printing image. but in large display i cant able to read letters.
    Thanks in advance
    Srini

    Your renderer is wrong.... try this (untested):
       class myCellRenderer extends DefaultTableCellRenderer {
         public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) {
            if (value!=null) {
              ImageIcon icon = new ImageIcon(image);     // assuming image is defined elsewhere and is accessible
              setIcon(icon);
              setText(value.toString());
            } else {
              setIcon(null);
              setText("");
            return this;
       };o)
    V.V.

  • Print label image in GIF format returned by Web Service XML string.

    Hi All
    I have extremely interesting situations and have been struggling with this for a past week. I have been looking everywhere but nobody seems to have an answer. This is my last resort.
    Detail -
    I am consuming UPS web service from my ABAP program. Everything works fine until I have to print UPS label.  The label image is returned to my ABAP program via XML by the UPS reply transaction as a GIF image.
    When I download this image to my PC I can see it and print it, but for the love of god I cannot print this image from my ABAP program. The GIF image is passed to me as a binary data string it looks like bunch on numbers - (2133FFDGFGFGFHHu2026..) very long string about 89800 bites. I cannot use smart forms since smart form requires to have graphic stored in  SAP before smart form print, so this is not possible. I need help figuring out how print GIF image form ABAP or any other SAP method dynamically.  Any ideas are extremely appreciated. I am just puzzled that I cannot find any info on something like this. I cannot be the first one who needs to print GIF image in SAP.

    Hi all,
    I understand this thread was started long back. But wanted to share this solution since I see the same question in many forums without any particular conclusive answer. So the steps I am explaining here, if it helps in some way, I will be really happy. I won't say this is the perfect solution. But it definitely helps us to print the images. This solution is infact implemented successfully in my client place & works fine.
    And please note there may be  better solutions definitely available in ECC6 or other higher releases. This solution is mainly for lesser versions, for people don't have ADOBE forms or other special classes.
    Important thing here is binary string is converted to postscript here. So you need to make sure your printer supports postscripts. (Ofcourse, if anybody is interested, they can do their R&D on PCL conversion in the same way...and pls let me know). Once the binary data is converted to postscript, we are going to write it in the binary spool. so you will still see junk characters (or numberssss) in spool. But when you print it in postscript printer , it should work.
    First step, assuming you have your binary data ready from tiff or pdf based on your requirement.
    Basically below compress/decompress function modules convert the binary data from lt_bin (structure TBL1024) to target_tab (structure SOLIX). From Raw 1024 to Raw 255
    DATA: aux_tab LIKE soli OCCURS 10. - temp table
    Compress table
                  CALL FUNCTION 'TABLE_COMPRESS'
                    TABLES
                      in             = lt_bin
                      out            = aux_tab
                    EXCEPTIONS
                      compress_error = 1
                      OTHERS         = 2.
    Decompress table
                  CALL FUNCTION 'TABLE_DECOMPRESS'
                    TABLES
                      in                   = aux_tab
                      out                  = target_tab
                    EXCEPTIONS
                      compress_error       = 1
                      table_not_compressed = 2
                      OTHERS               = 3.
    In my case, since I have to get it from archived data using function module, ARCHIV_GET_TABLE which gives RAW 1024, above conversion was necessary.
    Second step: Application server temporary files for tif/postscript files.
    We need two file names here for tif file & for converted postscript file. Please keep in mind, if you are running it in background, user should have authorization to read/write/delete this file.
    Logical file name just to make sure the file name is maintainable. Hard code the file name if you don't want to use logical file name.
                  CALL FUNCTION 'FILE_GET_NAME'
                    EXPORTING
                      logical_filename = 'ABCD'
                      parameter_1      = l_title
                      parameter_2      = sy-datum
                      parameter_3      = sy-uzeit
                    IMPORTING
                      file_name        = lv_file_name_init
                    EXCEPTIONS
                      file_not_found   = 1
                      OTHERS           = 2.
                  IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
                  ENDIF.
    Now concatenate with the different extensions to get two different files.
                  CONCATENATE lv_file_name_init '.tif' INTO lv_file_name_tif.
                  CONCATENATE lv_file_name_init '.ps' INTO  lv_file_name_ps.
    Third step: Write the target_tab to tif file.
    Open dataset for writing the tif file.
                  OPEN DATASET lv_file_name_tif FOR OUTPUT IN BINARY MODE.
                  IF NOT sy-subrc IS INITIAL.
                    RAISE open_failed.
                  ELSE.
                    LOOP AT target_tab INTO w_target_tab.
                      CATCH SYSTEM-EXCEPTIONS dataset_write_error = 1
                                              OTHERS = 4.
                        TRANSFER w_target_tab TO lv_file_name_tif.
                      ENDCATCH.
                      IF NOT sy-subrc IS INITIAL.
                        RAISE write_failed.
                      ENDIF.
                    ENDLOOP.
                    CATCH SYSTEM-EXCEPTIONS dataset_cant_close = 1
                                            OTHERS = 4.
                      CLOSE DATASET lv_file_name_tif.
                    ENDCATCH.
                  ENDIF.
    Fourth Step: Convert the tiff file to postscript file.
    This is the critical step. Create an external command (SM49/SM69) for this conversion. In this example, Z_TIFF2PS is created. Infact, I did get help from our office basis gurus in this. so I don't have the exact code of this unix script. You can refer the below link or may get some help from unix gurus.
    http://linux.about.com/library/cmd/blcmdl1_tiff2ps.htm
    Since my external command needs .ps file name and .tif file name as input, concatenate it & pass it as additional parameter. Command will take care of the conversion & will generate the .ps file.
       CONCATENATE lv_file_name_ps lv_file_name_tif INTO lw_add SEPARATED BY space.
    Call the external command with the file paths.
                  CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
                    EXPORTING
                      commandname           = 'Command name'
                      additional_parameters = lw_add
                    TABLES
                      exec_protocol         = t_comtab.
    Fifth step: Read the converted ps file and convert it to RAW 255.
      DATA:lw_content TYPE xstring.
    Open dataset for reading the postscript (ps) file
                  OPEN DATASET lv_file_name_ps FOR INPUT IN BINARY MODE.
    Check whether the file is opened successfully
                  IF NOT sy-subrc IS INITIAL.
                    RAISE open_failed.
                  ELSE.
                    READ DATASET lv_file_name_ps INTO lw_content.
                  ENDIF.
    Close the dataset
                  CATCH SYSTEM-EXCEPTIONS dataset_cant_close = 1
                                          OTHERS = 4.
                    CLOSE DATASET lv_file_name_ps.
                  ENDCATCH.
    Make sure you delete the temporary files so that you can reuse the same names again & again for next conversions.
                  DELETE DATASET lv_file_name_tif.
                  DELETE DATASET lv_file_name_ps.
    Convert the postscript file to RAW 255
                  REFRESH target_tab.
                  CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
                    EXPORTING
                      buffer     = lw_content
                    TABLES
                      binary_tab = target_tab.
    Sixth step: Write the postscript data to binary spool by passing the correct print parameters.
                  IF NOT target_tab[] IS INITIAL.
                    PERFORM spo_job_open_cust USING l_device
                                                         l_title
                                                         l_handle
                                                         l_spoolid
                                                         lw_nast.
                    LOOP AT target_tab INTO w_target_tab.
                      PERFORM spo_job_write(saplstxw) USING l_handle
                                                            w_target_tab
                                                          l_linewidth.
                    ENDLOOP.
                    PERFORM spo_job_close(saplstxw) USING l_handle
                                                          l_pages.
                    IF sy-subrc EQ 0.
                      MESSAGE i014 WITH
                       'Spools for'(019) lw_final-vbeln
                   'created successfully.Check transaction SP01'(020).
                    ENDIF.
                  ENDIF.
    Please note the parameters when calling function module RSPO_SR_OPEN. Change the print parameters according to your requirement. This is very important.
    FORM spo_job_open_cust USING value(device) LIKE tsp03-padest
                            value(title) LIKE tsp01-rqtitle
                            handle  LIKE sy-tabix
                            spoolid LIKE tsp01-rqident
                            lw_nast TYPE nast.
      DATA: layout LIKE tsp01-rqpaper,
            doctype LIKE tsp01-rqdoctype.
      doctype = 'BIN'.
      layout = 'G_RAW'.
      CALL FUNCTION 'RSPO_SR_OPEN'
          EXPORTING
            dest                   = device "Printer name
        LDEST                  =
            layout                 = layout
        NAME                   =
            suffix1                = 'PDF'
        SUFFIX2                =
        COPIES                 =
         prio                   = '5'
           immediate_print        = 'X'
    immediate_print        = lw_nast-dimme
            auto_delete            = ' '
            titleline              = title
        RECEIVER               =
        DIVISION               =
        AUTHORITY              =
        POSNAME                =
        ACTTIME                =
        LIFETIME               = '8'
            append                 = ' '
            coverpage              = ' '
        CODEPAGE               =
            doctype                = doctype
        ARCHMODE               =
        ARCHPARAMS             =
        TELELAND               =
        TELENUM                =
        TELENUME               =
          IMPORTING
            handle                 = handle
            spoolid                = spoolid
          EXCEPTIONS
            device_missing         = 1
            name_twice             = 2
            no_such_device         = 3
            operation_failed       = 4.
      CASE sy-subrc.
        WHEN 0.
          PERFORM msg_v1(saplstxw) USING 'S'
                           'RSPO_SR_OPEN o.k., Spoolauftrag $'(128)
                           spoolid.
          sy-subrc = 0.
        WHEN 1.
          PERFORM msg_v1(saplstxw)  USING 'E'
                               'RSPO_SR_OPEN Fehler: Gerät fehlt'(129)
                               space.
          sy-subrc = 1.
        WHEN 2.
          PERFORM msg_v1(saplstxw)  USING 'E'
                             'RSPO_SR_OPEN Fehler: Ungültiges Gerät $'(130)
                             device.
          sy-subrc = 1.
        WHEN OTHERS.
          PERFORM msg_v1(saplstxw)  USING 'E'
                               'RSPO_SR_OPEN Fehler: $'(131)
                               sy-subrc.
          sy-subrc = 1.
      ENDCASE.
    ENDFORM.                    "spo_job_open_cust
    Thats it. We are done. If you open the spool, still you will see numbers/junk characters. if you print it in postscript printer, it will be printed correctly. If you try to print it PCL, you will get lot of pages wasted since it will print all junk characters. So please make sure you use postscript printer for this.
    Extra step for mails (if interested):
    Mails should work fine without any extra conversion/external command since it will be opened again using windows. So after the first step (compress & decompress)
    Create attachment notification for each attachment
                  objpack-transf_bin = 'X'.
                  objpack-head_start = 1.
                  objpack-head_num   = 1.
                  objpack-body_start = lv_num + 1.
                  DESCRIBE TABLE  lt_target_tab LINES objpack-body_num.
                  objpack-doc_size   =  objpack-body_num * 255.
                  objpack-body_num = lv_num + objpack-body_num.
                  lv_num = objpack-body_num.
                  objpack-doc_type   =  'TIF'.
                  CONCATENATE 'Attachment_' l_object_id INTO objpack-obj_descr.
                  reclist-receiver = l_email.
                  reclist-rec_type = 'U'.
                  reclist-express = 'X'.
                  APPEND reclist.
                  CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
                    EXPORTING
                      document_data              = docdata
                      put_in_outbox              = 'X'
                      commit_work                = 'X'
                    TABLES
                      packing_list               = objpack
                      contents_txt               = objtxt
                      contents_hex               = target_tab
                      receivers                  = reclist
                    EXCEPTIONS
                      too_many_receivers         = 1
                      document_not_sent          = 2
                      document_type_not_exist    = 3
                      operation_no_authorization = 4
                      parameter_error            = 5
                      x_error                    = 6
                      enqueue_error              = 7
                      OTHERS                     = 8.
                  IF sy-subrc <> 0.
                    RAISE email_not_sent.
                  ENDIF.
                  COMMIT WORK.
    Hope this helps. I am sure this (print/email both) can be improved further by removing some conversions/by using some other methods.Please check & let me know if you have any such suggestions or any other comments.
    Regards,
    Gokul
    Edited by: Gokul R Nair on Nov 16, 2011 2:59 AM</pre>
    Edited by: Gokul R Nair on Nov 16, 2011 3:01 AM
    Edited by: Gokul R Nair on Nov 16, 2011 3:15 AM

  • Printing PDF files with smb/cups not possible // SLPReg status -20!

    Hello *,
    i am running SAMBA 3.6.1-1 and CUPS 1.5.0-1 on a dedicated system. Printer: Canon Pixma IP4500 (USB).
    The problem is that all Windows 7 clients are not able to print PDF files (since few months) on that printer while printing these files with Linux software is no problem. The PDF files are neither encrypted nor forbidden to print.
    I tried to print with Adobe Acrobat Reader X (latest) and Foxit Reader. Both are preparing the pages to be printed and close their printing dialog after processing. Windows printing queue does not show any jobs (which it even does not when printing simple images with MS Paint, which is not a problem).
    Windows systems are using the Canon Inkjet 4500 and Canon iP 4500 driver (manually installed). Printing images works with both drivers.
    I searched for "SLPReg […] failed with status -20!" but found no helpful information.
    /var/log/cups/error_log
    D [24/Dec/2011:23:05:35 +0100] Report: clients=0
    D [24/Dec/2011:23:05:35 +0100] Report: jobs=499
    D [24/Dec/2011:23:05:35 +0100] Report: jobs-active=0
    D [24/Dec/2011:23:05:35 +0100] Report: printers=2
    D [24/Dec/2011:23:05:35 +0100] Report: printers-implicit=0
    D [24/Dec/2011:23:05:35 +0100] Report: stringpool-string-count=199735
    D [24/Dec/2011:23:05:35 +0100] Report: stringpool-alloc-bytes=14344
    D [24/Dec/2011:23:05:35 +0100] Report: stringpool-total-bytes=3718136
    D [24/Dec/2011:23:05:36 +0100] cupsdNetIFUpdate: "lo" = localhost:631
    D [24/Dec/2011:23:05:36 +0100] cupsdNetIFUpdate: "eth0" = 192.168.2.9:631
    D [24/Dec/2011:23:05:36 +0100] cupsdNetIFUpdate: "lo" = localhost:631
    D [24/Dec/2011:23:05:36 +0100] cupsdNetIFUpdate: "eth0" = [v1.fe80::1e6f:65ff:fe51:1b3+eth0]:631
    D [24/Dec/2011:23:05:36 +0100] send_slp_browse(0x7f7d52023050 = "IP4500")
    E [24/Dec/2011:23:05:36 +0100] SLPReg of "IP4500" failed with status -20!
    D [24/Dec/2011:23:05:48 +0100] send_slp_browse(0x7f7d52017c90 = "IP4500_Duplex")
    E [24/Dec/2011:23:05:48 +0100] SLPReg of "IP4500_Duplex" failed with status -20!
    D [24/Dec/2011:23:06:07 +0100] send_slp_browse(0x7f7d52023050 = "IP4500")
    E [24/Dec/2011:23:06:07 +0100] SLPReg of "IP4500" failed with status -20!
    D [24/Dec/2011:23:06:19 +0100] send_slp_browse(0x7f7d52017c90 = "IP4500_Duplex")
    E [24/Dec/2011:23:06:19 +0100] SLPReg of "IP4500_Duplex" failed with status -20!
    D [24/Dec/2011:23:06:35 +0100] Report: clients=0
    D [24/Dec/2011:23:06:35 +0100] Report: jobs=499
    D [24/Dec/2011:23:06:35 +0100] Report: jobs-active=0
    D [24/Dec/2011:23:06:35 +0100] Report: printers=2
    D [24/Dec/2011:23:06:35 +0100] Report: printers-implicit=0
    D [24/Dec/2011:23:06:35 +0100] Report: stringpool-string-count=199735
    D [24/Dec/2011:23:06:35 +0100] Report: stringpool-alloc-bytes=14344
    D [24/Dec/2011:23:06:35 +0100] Report: stringpool-total-bytes=3718136
    D [24/Dec/2011:23:06:38 +0100] cupsdNetIFUpdate: "lo" = localhost:631
    D [24/Dec/2011:23:06:38 +0100] cupsdNetIFUpdate: "eth0" = 192.168.2.9:631
    D [24/Dec/2011:23:06:38 +0100] cupsdNetIFUpdate: "lo" = localhost:631
    D [24/Dec/2011:23:06:38 +0100] cupsdNetIFUpdate: "eth0" = [v1.fe80::1e6f:65ff:fe51:1b3+eth0]:631
    D [24/Dec/2011:23:06:38 +0100] send_slp_browse(0x7f7d52023050 = "IP4500")
    E [24/Dec/2011:23:06:38 +0100] SLPReg of "IP4500" failed with status -20!
    D [24/Dec/2011:23:06:50 +0100] send_slp_browse(0x7f7d52017c90 = "IP4500_Duplex")
    E [24/Dec/2011:23:06:50 +0100] SLPReg of "IP4500_Duplex" failed with status -20!
    /etc/samba/smb.conf
    load printers = yes
    printing = cups
    printcap = cups
    [printers]
    path = /var/spool/samba
    printable = yes
    public = yes
    writable = no
    /etc/cups/printers.conf
    # Printer configuration file for CUPS v1.5.0
    # Written by cupsd on 2011-12-24 22:25
    # DO NOT EDIT THIS FILE WHEN CUPSD IS RUNNING
    <Printer IP4500>
    UUID urn:uuid:f9850f70-d898-39ad-4e0a-9edfecf4977b
    Info Canon iP4500 series
    Location Keller
    MakeModel Canon PIXMA iP4500 - CUPS+Gutenprint v5.2.7
    DeviceURI usb://Canon/iP4500%20series?serial=42E635
    State Idle
    StateTime 1306084752
    Type 45084
    Accepting Yes
    Shared Yes
    JobSheets none none
    QuotaPeriod 0
    PageLimit 0
    KLimit 0
    DenyUser xy
    OpPolicy default
    ErrorPolicy stop-printer
    </Printer>
    <Printer IP4500_Duplex>
    UUID urn:uuid:14fcd3ca-2118-380e-5033-79beb09bb3b7
    Info Canon iP4500 series (Duplex)
    Location Keller
    MakeModel Canon PIXMA iP4500 - CUPS+Gutenprint v5.2.7
    DeviceURI usb://Canon/iP4500%20series?serial=42E635
    State Idle
    StateTime 1324761079
    Type 45084
    Accepting Yes
    Shared Yes
    JobSheets none none
    QuotaPeriod 0
    PageLimit 0
    KLimit 0
    OpPolicy default
    ErrorPolicy stop-printer
    </Printer>

    Hi,
    I can, unfortanetly, confirm this problem for me with a Brother HL-2030 and an HP Officejet 5600 series.
    cups error log
    D [03/May/2012:21:42:46 +0200] Report: printers=3
    D [03/May/2012:21:42:46 +0200] Report: printers-implicit=0
    D [03/May/2012:21:42:46 +0200] Report: stringpool-string-count=10577
    D [03/May/2012:21:42:46 +0200] Report: stringpool-alloc-bytes=13088
    D [03/May/2012:21:42:46 +0200] Report: stringpool-total-bytes=192536
    D [03/May/2012:21:43:48 +0200] cupsdNetIFUpdate: "lo" = localhost:631
    D [03/May/2012:21:43:48 +0200] cupsdNetIFUpdate: "eth0" = 192.168.2.100:631
    D [03/May/2012:21:43:48 +0200] cupsdNetIFUpdate: "tun0" = 10.8.0.1:631
    D [03/May/2012:21:43:48 +0200] cupsdNetIFUpdate: "lo" = localhost:631
    D [03/May/2012:21:43:48 +0200] cupsdNetIFUpdate: "eth0" = [v1.fe80::201:2eff:fe27:6993+eth0]:631
    D [03/May/2012:21:43:48 +0200] Report: clients=0
    D [03/May/2012:21:43:48 +0200] Report: jobs=233
    D [03/May/2012:21:43:48 +0200] Report: jobs-active=0
    D [03/May/2012:21:43:48 +0200] Report: printers=3
    D [03/May/2012:21:43:48 +0200] Report: printers-implicit=0
    D [03/May/2012:21:43:48 +0200] Report: stringpool-string-count=10577
    D [03/May/2012:21:43:48 +0200] Report: stringpool-alloc-bytes=13088
    D [03/May/2012:21:43:48 +0200] Report: stringpool-total-bytes=192536
    D [03/May/2012:21:44:50 +0200] cupsdNetIFUpdate: "lo" = localhost:631
    D [03/May/2012:21:44:50 +0200] cupsdNetIFUpdate: "eth0" = 192.168.2.100:631
    D [03/May/2012:21:44:50 +0200] cupsdNetIFUpdate: "tun0" = 10.8.0.1:631
    D [03/May/2012:21:44:50 +0200] cupsdNetIFUpdate: "lo" = localhost:631
    D [03/May/2012:21:44:50 +0200] cupsdNetIFUpdate: "eth0" = [v1.fe80::201:2eff:fe27:6993+eth0]:631
    D [03/May/2012:21:44:50 +0200] Report: clients=0
    D [03/May/2012:21:44:50 +0200] Report: jobs=233
    D [03/May/2012:21:44:50 +0200] Report: jobs-active=0
    D [03/May/2012:21:44:50 +0200] Report: printers=3
    D [03/May/2012:21:44:50 +0200] Report: printers-implicit=0
    D [03/May/2012:21:44:50 +0200] Report: stringpool-string-count=10577
    D [03/May/2012:21:44:50 +0200] Report: stringpool-alloc-bytes=13088
    D [03/May/2012:21:44:50 +0200] Report: stringpool-total-bytes=192536
    printers.conf
    # Printer configuration file for CUPS v1.5.0
    # Written by cupsd on 2011-12-24 13:14
    # DO NOT EDIT THIS FILE WHEN CUPSD IS RUNNING
    <Printer CUPS-PDF>
    UUID urn:uuid:ad99f5dd-2577-355f-759c-6b2941a88d34
    Info Virtual PDF Printer
    Location Zion
    MakeModel Generic CUPS-PDF Printer
    DeviceURI cups-pdf:/
    State Idle
    StateTime 1309396700
    Type 8450124
    Accepting Yes
    Shared Yes
    JobSheets none none
    QuotaPeriod 0
    PageLimit 0
    KLimit 0
    OpPolicy default
    ErrorPolicy stop-printer
    </Printer>
    <Printer HL2030>
    UUID urn:uuid:1b453a5d-ade0-3ddb-45e4-c5bcfe1feabd
    Info Brother HL-2030 series
    Location Zion
    MakeModel Brother HL-2030 Foomatic/hl1250 (recommended)
    DeviceURI usb://Brother/HL-2030%20series?serial=G6J274210
    State Idle
    StateTime 1324728260
    Type 8433668
    Accepting Yes
    Shared Yes
    JobSheets none none
    QuotaPeriod 0
    PageLimit 0
    KLimit 0
    OpPolicy default
    ErrorPolicy stop-printer
    </Printer>
    <Printer HP5600>
    UUID urn:uuid:8d882659-3c7e-319f-5072-38d14683cfaf
    Info HP Officejet 5600
    Location
    MakeModel HP Officejet 5600 Series, hpcups 3.11.10
    DeviceURI hp:/usb/Officejet_5600_series?serial=CN838F31ZQ04B2
    State Idle
    StateTime 1324728896
    Type 8425484
    Accepting Yes
    Shared Yes
    JobSheets none none
    QuotaPeriod 0
    PageLimit 0
    KLimit 0
    OpPolicy default
    ErrorPolicy stop-printer
    </Printer>
    smb.conf
    # NOTE: If you have a BSD-style print system there is no need to
    # specifically define each individual printer
    [printers]
    comment = All Printers
    path = /var/spool/samba
    browseable = yes
    # Set public = yes to allow user 'guest account' to print
    guest ok = yes
    writable = no
    printable = yes
    Did you find a solution in the meantime?

  • .gif Images saved as static images, not animated

    Using the most recent version of Firefox mobile on Android 4.1.2 on a Samsung Galaxy S3. I can download animated .gif images via Firefox to my phone and the saved file will display as a static image. If I download an animated .gif image with the proprietary browser the saved image will display as an animated image.
    Thanks in advance,
    Evan

    Thanks for bringing to the notice, I'm filing a bug regarding this.

Maybe you are looking for

  • Multiple lines of Condition types in Purchase order header

    Dear Consultants,         We assigned certain condition types in the access sequences. This access sequence has 4 condition tables. User can maintain condition records at any level; viz SiteArticle OR Deli.CountryHTS code OR Deli.CountryHTS codeShipp

  • Oracle 817 client not available in ODBC Data Source Administrator pick list...

    I have installed Oracle 817 client on a PC. I can see the server, I can see the instance. I can log into the instance using SQLPlus with no problem. The product I'm using requires an ODBC connection configured in the ODBC Data Source Administrator. W

  • Closing or cancelling series of purchase orders

    Hello Forum, I need to cancel or close lots of purchase orders. I was thinking of using dtw, but in the templates it doesn't seem to be possible to change a documents status? How to solve this? Thanks Chan

  • Application coding and clustering

    We are going to develop a web system using iPlanet as web server running http and jsp, weblogic as application server running Java bean RMI inbetween. We have to decide whether to run the app server tire in one box or two(clustered). The idea of havi

  • Error :in opening  posting period

    For opening posting period April08-March 09 what to do? Posting varient is created for current posting period,now for new posting period is it so to create new varient ? & if new varient created then how to assign to company code as one current varie