Thread: CAIRO - error when converting txt to pdf

  1. #16
    Registered User
    Join Date
    Dec 2012
    Posts
    8
    Quote Originally Posted by Salem View Post
    I just downloaded libcairo2 onto my Ubuntu system, tried post #14 and it works just as expected. I get a valid PDF file with the text clearly visible.
    At this point, I'd say there is something wrong with the library you installed, or something in the way you're building the code.

    What is your actual programming environment? You've mentioned windows.h and that you're using gcc.

    If you can, do a "build->clean" and a "build->rebuild all"
    Then post your build log.
    I am using DEV-C ++ and code:blocks for windows. they both set the same problem when I execute.

    I downloaded CAIRO. When I opened the downloaded object, there were the objects BIN, INCLUDE, LIB, MANIFEST, SHARE AND SRC. I just put the bin, include and lib files into the respective way of DEV-C++. I did not do anything with manifest, share and src.

    Is it correct way to install cairo?

    How did you install CAIRO?

  2. #17
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    If you did not build cairo I don't know how you managed to link your code. I can get cairo from here: Download And since I am using a 32 bit compiler I read the page and landed on here: GTK+ Download: Windows (32-bit) since it's one of the GTK+ dependencies. The thing is, what you get by downloading cairo from there is a DLL. You have to use the Win32 API to load and use a DLL in your code. So I'm going to ask exactly where did you get cairo from and what did you download?

  3. #18
    Registered User
    Join Date
    Dec 2012
    Posts
    8
    Quote Originally Posted by whiteflags View Post
    If you did not build cairo I don't know how you managed to link your code. I can get cairo from here: Download And since I am using a 32 bit compiler I read the page and landed on here: GTK+ Download: Windows (32-bit) since it's one of the GTK+ dependencies. The thing is, what you get by downloading cairo from there is a DLL. You have to use the Win32 API to load and use a DLL in your code. So I'm going to ask exactly where did you get cairo from and what did you download?
    Ok, everybody, I found out a solution to my problem. Now, I can write one line in pdf, I can write two lines in pdf, I can convert txt to pdf using C++ with DEV-C++ and code:blocks.

    I was downloading the include and lib of cairo library correctly. My mistake was that I was downloading the dll files that can make other funcions, but could not create a pdf file correcty. I was getting these dll from the site Using Cairo With GDI and I was wrong. So, the correct dlls I need are placed at GTK+ Download: Windows (32-bit).

    Now, this code and others can be executed with no problem.



    Code:
    #include <cairo.h>
    #include <cairo-pdf.h>
    
    int main(int argc, char **argv) {
        float position;
      cairo_surface_t *surface;
      cairo_t *cr;
      surface = cairo_pdf_surface_create("line.pdf", 504, 648);
      cr = cairo_create(surface);
      position=50.0;
      cairo_move_to(cr, 8.0, position);
      cairo_show_text(cr, "This is line 1");
      cairo_show_page(cr);
      cairo_surface_destroy(surface);
      cairo_destroy(cr);
    }

    I would like to thank everybody here. You all helped to solve this problem.

    THANK YOU VERY MUCH!!!
    Last edited by leonardoadoado; 12-05-2012 at 02:34 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. cairo-dock issue
    By Annonymous in forum Linux Programming
    Replies: 2
    Last Post: 06-03-2012, 12:14 AM
  2. Using image as a mask in cairo (a c library)
    By javaeyes in forum C Programming
    Replies: 3
    Last Post: 03-21-2012, 05:09 AM
  3. cairo, rasterizing text
    By javaeyes in forum C Programming
    Replies: 1
    Last Post: 03-06-2012, 08:51 PM
  4. cairo text extent weirdness
    By javaeyes in forum C Programming
    Replies: 3
    Last Post: 02-24-2012, 07:24 PM
  5. Cairo and GTK, still need a pixmap?
    By TriKri in forum Linux Programming
    Replies: 0
    Last Post: 03-18-2008, 04:18 PM