Page 1 of 1

convert multiple images to single pdf with library MagicWand

Posted: 2018-08-12T23:30:14-07:00
by liuxiaomeng2270
HI,

I'm trying to convert multiple images to one single pdf with MagicWand in C code.
I can save one image to one pdf file.
But I can't find a way to load all images in one container or some object to save the raster image data.

Is anybody has the code flow or API of MagicWand that I can call to load all image to one Object or container?

Any suggestions?


THX

Re: convert multiple images to single pdf with library MagicWand

Posted: 2018-08-13T10:42:49-07:00
by snibgo
Here's a wand program, but with no error-checking, that writes two images to a PDF:

Code: Select all

#include <MagickWand/MagickWand.h>

int main(void)
{
  MagickWandGenesis();

  MagickWand *mw = NewMagickWand();
  MagickReadImage(mw,"rose:");

  MagickWand *aw = NewMagickWand();
  MagickReadImage(aw,"toes.png");

  MagickAddImage(mw,aw);

  MagickWriteImages(mw,"out.pdf",MagickTrue);

  if(mw) mw = DestroyMagickWand(mw);
  if(aw) aw = DestroyMagickWand(aw);

  MagickWandTerminus();

  return 0;
}