Ejemplo n.º 1
0
WPdfImage::WPdfImage(const WLength& width, const WLength& height)
  : width_(width),
    height_(height),
    painter_(nullptr)
{
  myPdf_ = true;

  pdf_ = HPDF_New(error_handler, this);
  if (!pdf_)
    throw WException("Could not create libharu document.");

  HPDF_SetCompressionMode(pdf_, HPDF_COMP_ALL);

  page_ = HPDF_AddPage(pdf_);

  font_ = nullptr;

  x_ = y_ = 0;

  HPDF_Page_SetWidth(page_, width_.toPixels());
  HPDF_Page_SetHeight(page_, height_.toPixels());
  HPDF_Page_GSave(page_);

  trueTypeFonts_ = new FontSupport(this, FontSupport::TrueTypeOnly);

#if HPDF_VERSION_ID>=20300
  HPDF_UseUTFEncodings(pdf_);
#endif
}
Ejemplo n.º 2
0
  virtual void handleRequest(const Wt::Http::Request& request,
                             Wt::Http::Response& response)
  {
    response.setMimeType("application/pdf");

    HPDF_Doc pdf = HPDF_New(error_handler, 0);
    HPDF_UseUTFEncodings(pdf);

    renderReport(pdf);

    HPDF_SaveToStream(pdf);
    unsigned int size = HPDF_GetStreamSize(pdf);
    HPDF_BYTE *buf = new HPDF_BYTE[size];
    HPDF_ReadFromStream (pdf, buf, &size);
    HPDF_Free(pdf);
    response.out().write((char*)buf, size);
    delete[] buf;
  }
Ejemplo n.º 3
0
hpdf_doc::hpdf_doc(const char* filepath) 
{
	h_pdf = HPDF_New(error_handler, NULL); 

	HPDF_UseCNTFonts(h_pdf);
	HPDF_UseCNTEncodings(h_pdf); // set CHT fonts and encoding

	HPDF_UseUTFEncodings(h_pdf);

	strcpy(filename, filepath);

	f_page_width = def_f_width;
	f_page_length = def_f_length;
	f_margin_top = def_f_margin_top;
	f_margin_left = def_f_margin_left;
	f_margin_bottom = def_f_margin_bottom;
	f_margin_right = def_f_margin_right;

	h_direction = HPDF_PAGE_PORTRAIT;
}