Convert tiff -> pdf

The MagickWand interface is a new high-level C API interface to ImageMagick core methods. We discourage the use of the core methods and encourage the use of this API instead. Post MagickWand questions, bug reports, and suggestions to this forum.
Post Reply
ropet

Convert tiff -> pdf

Post by ropet »

I'm trying to convert a tiff image to a pdf image. The tiff file is a tiffG4
It look okej but the pdf is not redable in adobe acrobat reader.
Do i do anny thing wrong ??

MagickWandGenesis();

wand = NewMagickWand();
status = MagickReadImage(wand,"c:\\1.tif");
status = MagickSetImageFormat(wand, "PDF" );
MagickGetImageBlob(wand,&ImageLen);

memcpy(*Image,FilePonter,ImageLen);
DestroyMagickWand( wand );
MagickWandTerminus();

infd = open("c:\\1.pdf", O_RDWR | O_CREAT);
write(infd,Image,ImageLen);
close(infd);
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Convert tiff -> pdf

Post by magick »

This snippet reads an image in the TIFF format, converts it to PDF as an inline blob, and writes the result to disk:
  • wand = NewMagickWand();
    status = MagickReadImage(wand,"1.tif");
    status = MagickSetImageFormat(wand, "PDF" );
    blob = MagickGetImageBlob(wand,&length);

    DestroyMagickWand( wand );
    MagickWandTerminus();

    infd = open("1.pdf", O_RDWR | O_CREAT, 0644);
    write(infd,blob,length);
    close(infd);
ropet

Re: Convert tiff -> pdf

Post by ropet »

I copy your code and test it on my image. Iget one pdf but is not okej to display in acrobar reader.
I run the convert program on it, then it work ok.

My image is tiff tiffG4 black&white ( no grayscale or collor )

I test this under windows.
Version: ImageMagick 6.3.7 12/25/07 Q8
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Convert tiff -> pdf

Post by magick »

Can you post a URL to your image, 1.tif? We converted a G4 TIFF image with the MagickWand program and the convert command and both produced a valid PDF image. We're using ImageMagick 6.3.7-9.
ropet

Re: Convert tiff -> pdf

Post by ropet »

Can i send it by mejl ?
ropet

Re: Convert tiff -> pdf

Post by ropet »

I have 2 test images on a webserver
http://ropet.mine.nu/Images/
001.TIF
002.TIF

thanks for all help i can get
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Convert tiff -> pdf

Post by magick »

We tried your script with 001.TIF and 002.TIF and create 001.PDF and 002.PDF respectively and they both displayed without complaint with Adobe Acrobat 8.0. We're using ImageMagick 6.3.7-9.
ropet

Re: Convert tiff -> pdf

Post by ropet »

This is my test program i get a pdf fil thet is blank ( white )

Code: Select all

int main(int argc,char **argv)
{

	int ImageLen =0;
	int infd;

	MagickWand *wand;
	unsigned char *blob;
	size_t length;
	MagickBooleanType   status;


	MagickWandGenesis();

	wand = NewMagickWand();
	status = MagickReadImage(wand,"c:\\tewmp\\001.tif");
	status = MagickSetImageFormat(wand, "PDF" );
	blob = MagickGetImageBlob(wand,&length);

	infd = open("c:\\tewmp\\1.pdf", O_RDWR | O_CREAT, 0644);
	write(infd,blob,length);
	close(infd);
	DestroyMagickWand( wand );
	MagickWandTerminus();
}
Last edited by ropet on 2008-01-08T15:39:02-07:00, edited 1 time in total.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Convert tiff -> pdf

Post by magick »

Download http://www.virginimage.org/download/1.pdf, created with your code snippet.
ropet

Re: Convert tiff -> pdf

Post by ropet »

I get the last version and make the test. And My pdf files is on
ropet.mine.nu/images
001.pdf
002.pdf

And they is not så god.
I runing under windows and vc++ 6
I have test Q8 and Q16
I see in the pdf file is generated whith Q16
Post Reply