Hi,

I am having difficulty getting PDF rendering to work.

I am trying the simple example from the WPdfRenderer
documentation (exact code below).

When I run it, I don't get any errors and a PDF file
is generated. The PDF file contains a line with red
background (good so far), but there is no text in it.

Upon closer examination, there is text that can be
selected on the line, but it's not visible, and when
copy/pasting into a text editor I get some Chinese
characters rather than "Hello, world!": 䡥汬漬⁷潲汤‡

I guess this is a font/encoding problem, but I'm not
sure how to further diagnose/debug it. Any ideas?

Some information that may be relevant:
  - Wt version is 3.2.3
  - OS is Ubuntu 10.04, 64-bit
  - libharu version is 2.3.0 RC2
  - to use WPdfRenderer I had to link to the following
    additional libraries (besides libhpdf):
     - libpango-1.0
     - libpangoft2-1.0
     - libpng
  

Thanks,
Nate

Code:

#include <iostream>
#include <Wt/Render/WPdfRenderer>
#include "hpdf.h"

void error_handler(HPDF_STATUS error_no, HPDF_STATUS detail_no, void*)
{
    std::cout << "HPDF error: " << error_no << ", detail: " << detail_no << 
'\n';
    std::exit(1);
}

int main()
{
     HPDF_Doc pdf = HPDF_New(error_handler, 0);
     HPDF_UseUTFEncodings(pdf); // enables UTF-8 encoding with true type fonts
     HPDF_Page page = HPDF_AddPage(pdf);
     HPDF_Page_SetSize(page, HPDF_PAGE_SIZE_A4, HPDF_PAGE_PORTRAIT);

     Wt::Render::WPdfRenderer renderer(pdf, page);
     renderer.setMargin(2.54);
     renderer.setDpi(96);

     renderer.render("<p style=\"background-color: #c11\">Hello, world !</p>");

     HPDF_SaveToFile(pdf, "hello.pdf");
     HPDF_Free(pdf);
}

                                          
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
witty-interest mailing list
witty-interest@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to