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

  • SEARCH
  • Home
  • 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 9223553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:06:14+00:00 2026-06-18T04:06:14+00:00

I need to print some vector data (or to be more exact: some dots

  • 0

I need to print some vector data (or to be more exact: some dots and polylines) using Linux. When I ask Google for that it shows me many tutorials and documentations – but all for end users, no programming examples.

So does anybody know a good programmers HOWTO/tutorial that shows printing under Linux?

Thanks!

  • 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. Editorial Team
    Editorial Team
    2026-06-18T04:06:15+00:00Added an answer on June 18, 2026 at 4:06 am

    CUPS doesn’t have its own document description API. It doesn’t need one: formats like PostScript, PDF, and JPEG are first-class citizens of CUPS. You use whatever program or API you like to create a such a file, and you then send it to CUPS (with lpr or with the CUPS API) and CUPS will transform it to the appropriate internal format and send it to the printer.

    So, for your case, you might use a vector graphics library like Cairo to author PostScript, and then you send that off to CUPS for printing. Here’s a simple C example:

    // compile with:
    //   gcc -Wall -o cairo_print cairo_print.c `pkg-config --cflags --libs cairo` `cups-config --cflags --libs`
    
    #include <stdio.h>
    #include <cairo.h>
    #include <cairo-ps.h>
    #include <cups/cups.h>
    
    // A4 width, height in points, from GhostView manual:
    //   http://www.gnu.org/software/gv/manual/html_node/Paper-Keywords-and-paper-size-in-points.html
    #define WIDTH  595  
    #define HEIGHT 842  
    
    int main(int argc, char** argv) {
      if (argc!= 2){
        fprintf (stderr, "usage: %s word\n", argv[0]);
        return 1;
      }
    
      // setup
      char* tmpfilename = tempnam(NULL,NULL);
      cairo_surface_t* surface = cairo_ps_surface_create(tmpfilename, 
                                                         WIDTH, 
                                                         HEIGHT);
      cairo_t *context = cairo_create(surface);
    
      // draw some text
      cairo_select_font_face(context, 
                             "Arial Black", 
                             CAIRO_FONT_SLANT_NORMAL, 
                             CAIRO_FONT_WEIGHT_NORMAL);
      cairo_set_font_size(context, 30);
      cairo_move_to(context, WIDTH/2, HEIGHT/2);
      cairo_show_text(context, argv[1]); // the text we got as a parameter
    
      // draw a dotted box
      const double pattern[] = {15.0, 10.0};
      cairo_set_dash(context, pattern, 2, 0);
      cairo_set_line_width(context, 5);
      cairo_rectangle(context, WIDTH*0.33, HEIGHT*0.33, WIDTH*0.5, WIDTH*0.5);
      cairo_stroke(context);
    
      // finish up
      cairo_show_page(context);
      cairo_destroy(context);
      cairo_surface_flush(surface);
      cairo_surface_destroy(surface);
    
      // print
      cupsPrintFile(cupsGetDefault(), tmpfilename, "cairo PS", 0, NULL);
      unlink(tmpfilename);
    
      return 0;
    }
    

    Strictly you don’t need that temporary file: the CUPS API allows you to construct a stream and you can emit the page data into that (but a file is handy for debugging).

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

Sidebar

Related Questions

I need to sort then print the result increasing and decreasing. I have some
I need a script that inserts a number at some point into a file
I need to print out receipts that inserted into my database, and the latest
I need to print report page that has couple of background images on it.
I have written some C++ code that generates a std::vector. I also have a
I am trying to show that there is a wierd bump in some data
I'm having trouble transferring some data contained in a vector between my functions. The
I need to export both simple geometry and a vector field to some VTK
So I have some lidar data that I want to calculate some metrics for
I am storing some simple strings to a vector, and I want to print

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.