0

I'm trying to generate a pdf file with the lib haru on c++.

But I don't know how to write a text in a filled rectangle:

// draw and fill/stroke a rectangle
HPDF_Page_SetRGBFill(page, 0.75, 0.75, 0.75);
HPDF_Page_Rectangle(page, 50, 100, 200, 50);
HPDF_Page_FillStroke(page);

// try to put a text in the rectangle.
HPDF_Page_SetFontAndSize (page, HPDF_GetFont (pdf, "Helvetica", "CP1252"), 8);
HPDF_Page_BeginText (page);
HPDF_Page_TextOut (page, 70, 120, "test");
HPDF_Page_EndText (page);

There is no bug returned, but the text is not printed.

What is the problem ?

Thank you !

EDIT:

Ok the problem was that i forgot to change the fill color: I had to add:

HPDF_Page_SetRGBFill(page, 0.0, 0.0, 0.0);

before the PDF_Page_BeginText function.

Alfred
  • 307
  • 1
  • 2
  • 16
  • First Sanity Check: are you **sure** you are printing the text in another color? (a) Your code suggests you are not; (b) you should check your generated PDF. – Jongware Jan 29 '14 at 13:48
  • Ok thanks @Jongware it was that: i forgot to change the color ^^ – Alfred Jan 29 '14 at 13:54

0 Answers0