paint Image on PDF.

Added by Ron Tidwell 10 months ago

I am creating another PDF that includes a bar code image on it.

When running I get follow errors:

[2017-Mar-23 10:51:42.029652] 14723 - [info] "WebRequest: took 0.37ms"
[2017-Mar-23 10:51:44.908575] 14723 [/ eSGwaXnoToH7g5UB] [error] "Wt: error during event handling: WPdfImage::drawImage(): cannot load image: ?_=file%3a///home/rtidwell/PDF/RTidwell/BarImage.png&wtd=eSGwaXnoToH7g5UB"

Wt::WPainter::Image Documentation say its want a URL. So I used Wt::Resource to create the URL.

Wt::WFileResource *BarImage = new  WFileResource(BarcodeFile);

If create an anchor and set this link to it, the anchor works and image is displayed in the browser. Below is code used trying to paint the image.

Wt::WPainter::Image BarCode = Wt::WPainter::Image(BarImage->url(),BarcodeFile);
Wt::WPointF BarPoint = Wt::WPointF(40,cury);
cury += 30;

I am sure I am doing some stupid any help would be appreciated.

Thank you,

Replies (2)

RE: paint Image on PDF. - Added by Koen Deforche 10 months ago

Hey Ron,

The WPainter API has some general requirements (an image URL for use in e.g. SVG/WCanvasPaintDevice, and a local URL to be able to determine the image size necessary for some implementations), but the PDF target adds as a requirement that the image must be a available locally (it will not download an image through the given URL).

So you need to pass an image either as a file ("/tmp/image.png") or as a data URL (data:base64...).


RE: paint Image on PDF. - Added by Ron Tidwell 10 months ago

Thank you!!! That worked.