Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 77309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:48:36+00:00 2026-05-10T20:48:36+00:00

The function below prints a color raster image to a PCL-5 printer. The function

  • 0

The function below prints a color raster image to a PCL-5 printer. The function was adapted from a 2-color (1bpp) printing function we had that worked perfectly, except for the grainy 2-color printing. The problem is that the image comes out with a large black bar extending from the right of the image to the edge of the page like this:

  IMAGE#########################################   IMAGE#########AREA COMPLETELY BLACK###########   IMAGE######################################### 

The image itself looks perfect, otherwise.

Various PCL-to-PDF tools don’t show the image at all, which leads me to believe I’ve forgotten do to something. Appropriate resets (\u001bE\u001b%-12345X) were sent before, and page-feeds after.

Any PCL experts out there? I’ve got the PCL 5 Color Technical Reference Manual, and it’s gotten me this far. This last thing is driving me crazy though.

*Edit: I now know what command is causing the problem, but I don’t know why:

  stream('\u001b*r0F');  

This should keep the image rotated along with the page (portrait, landscape). If I remove this, the problem goes away. I can compensate by rotating the bitmap beforehand, but I really want to know what caused this!

   static void PrintImage()     {         // Get an image into memory         Image original = Image.FromFile('c:\\temp\\test.jpg');         Bitmap newBitmap = new Bitmap(original, original.Width, original.Height);          stream(String.Format('\u001b*p{0:d}x*p{1:d}Y', 1000, 1000));// Set cursor.         stream('\u001b*t300R');                                     // 300 DPI         stream(String.Format('\u001b*r{0:d}T', original.Height));   // Height         stream(String.Format('\u001b*r{0:d}S', original.Width));    // Width          stream('\u001b*r3U');      // 8-bit color palette         stream('\u001b*r0F');      // Follow logical page layout (landscape, portrait, etc..)         // Set palette depth, 3 bytes per pixel RGB         stream('\u001b*v6W\u0000\u0003\u0000\u0008\u0008\u0008');           stream('\u001b*r1A');      // Start raster graphics         stream('\u001b*b0M');      // Compression 0 = None, 1 = Run Length Encoding          // Not fast, but fast enough.           List<byte> colors = new List<byte>();         for (int y2 = 0; y2 < original.Height; y2++)         {             colors.Clear();             for (int x2 = 0; x2 < original.Width; x2++)             {                 Color c = newBitmap.GetPixel(x2, y2);                 colors.Add(c.R);                 colors.Add(c.G);                 colors.Add(c.B);             }              stream(String.Format('\u001b*b{0}W', colors.Count));     // Length of data to send             streamBytes(colors.ToArray());                           // Binary data         }         stream('\u001b*rB');   // End raster graphics  (also tried *rC -- no effect)     } 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T20:48:37+00:00Added an answer on May 10, 2026 at 8:48 pm

    There are a few problems with your code. First off your cursor position code is incorrect, it should read:

    '\u001b*p{0:d}x1:d}Y', 1000, 1000 

    This equates to:

    <esc>*p1000x1000Y 

    you had:

    <esc>*p1000x*p1000Y 

    When joining PCL commands together you match up the same parameterized value and group and then simply add value + parametrized character + value + parametrized character etc. Ensure that the final parametrized character is a capital letter which signifies the end of the PCL command.

    Also when defining an image I recommend you also specify the width & hight in decipoints, this should help with the scaling of the image (*r3A) on the page so add this (just after your resolution command should be an okay place for it):

    Int32 deciHeight = original.Height / (int)original.HorizontalResolution * 720; Int32 deciWidth = original.Width / (int)original.VerticalResolution * 720; stream('\u001b*t{0:d}h{1:d}V', deciHeight, deciWidth)); 

    The other recommendation is to write all of this to file (watch your encodings) and use one of the handful of PCL viewers to view your data vs. always printing it. Should save you some time and a forest or two! I’ve tried all of them and wold recommend spending the $89 and purchasing pclWorks. They also have a complete SDK if you are going to do a lot of PCL. We don’t use that as we hardcode all PCL ourselves but it does look good.

    As for rotation, we’ve had problems on some device, You could just rotate the the jpg first (original.RotateFlip) an then write it out.

    I don’t have much time today but hope that my comments assist. I can test your code on Monday or Tuesday and work with it and post any further comments.

    Keep in mind that even though PCL is a standard its support from manufacturer to manufacturer and device to device can be a problem and vastly different. When doing basic things most devices seem okay; however, if you get into macros or complex graphics you will find difference.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 115k
  • Answers 116k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This is a duplicate, but I don't have time to… May 11, 2026 at 10:30 pm
  • Editorial Team
    Editorial Team added an answer if the format of the string is set in stone,… May 11, 2026 at 10:30 pm
  • Editorial Team
    Editorial Team added an answer CString GetCallingFilename(bool includePath) { CString filename; GetModuleFileName(AfxGetInstanceHandle(), filename.GetBuffer(MAX_PATH), MAX_PATH); filename.ReleaseBuffer();… May 11, 2026 at 10:30 pm

Related Questions

I wrote the two methods below to automatically select N distinct colors. It works
I need to know how the performance of different XML tools (parsers, validators, XPath
How come unserialize isn't restoring my array? See code below.. // prints a:1:{s:8:txn_type;s:32:recurring_payment_profile_cancel;} echo
I have a simple accordion type page containing a list of H3 headers and

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.