dreamsys software

DreamSys Tiff to PDF API

Download DreamSys Tiff to PDF API

ATTENTION: A new version of this library is available that supports JPG (JPEG), BMP, TIFF and text as well! It can be used for for jpeg2pdf, jpg2pdf, bmp2pdf, tiff2pdf conversions, and creating text only pages as well as text overlays on your images! Please view the page for the Image to PDF Library instead of this page!

The DreamSys PDF API is a DLL that can convert TIFF images into a PDF. You can create multiple chapters (PDF Section) to organize your images, this will create bookmarks in the PDF to link to specific pages. The API is written in C++, but can be used in an application written in C, C++, C#, VB, Java or any other language that allows you to import functions from a DLL. The API will not load the actual TIFF data into memory until it is time to write that TIFF to the file, so it can handle very large PDFs while using very little memory. This API is also thread safe, you can create multiple PDFs on separate threads and they will not conflict.

You can freely use this API in your own programs as long as they are public and freely available. If you want to use this code in your own business applications, you can for a small fee, contact us for details. The source code is also available for purchase if you wish, please contact us for details on this as well!

If there are any features that you have in mind, or any bugs that you find, please post about them in the forum for this library by clicking here!

The API is written so that it can be used in C code as well, so it is exported as a C API. The API is very simple to use and flexible as well. Here is a quick example of how to use it in your code:

//Create a PDF object for tiff 2 pdf conversion...
PDF_HANDLE hPdf = DSSPDF_New("My PDF", "Rocky's Producer");

//Create a section (bookmark in the pdf) and add 2 pages to it.
SECTION_HANDLE hSec = DSSPDF_AddSection(hPdf, "Section 1");
DSSPDF_AddFilePage(hSec, "c:\\test1.tif");
DSSPDF_AddFilePage(hSec, "c:\\test2.tif");

//Create another section and add 2 pages to it.
hSec = DSSPDF_AddSection(hPdf, "Section 2");
DSSPDF_AddFilePage(hSec, "c:\\test3.tif");
DSSPDF_AddFilePage(hSec, "c:\\test4.tif");

//Save the PDF
DSSPDF_Save(hPdf, "c:\\test.pdf");

//Free the PDF data (this includes all the sections as well).

If you have need of a more flexible way of loading your TIFF files, you can call the function DSSPDF_AddPage and use the TIFF_DATA data structure. The function DSSPDF_AddFilePage makes use of this. Remember, you must make this code threadsafe if you want the API to remain thread safe! As an example of how to use this method, I will show you the implementation of the AddPage function.

//First you create a class (or set of functions) to wrap your way of loading
//the TIFF files.  In this case, we load from a file...

class TiffFileReader
	TiffFileReader(const string &fn);

		delete[] data;

	static int GetTiff(void *p, byte **dat, int *size);
	static void FreeTiff(void *p);

	int dataSize;
	byte *data;
	string fileName;

TiffFileReader::TiffFileReader(const string &fn)
	fileName = fn;

int TiffFileReader::GetTiff(void *p, byte **dat, int *size)
	TiffFileReader *tr = (TiffFileReader *)p;

	FILE *fp = fopen(tr->fileName.c_str(), "rb");

	if (!fp)
		return 0;

	fseek(fp, 0, SEEK_END);
	*size = (int)ftell(fp);

	tr->data = new byte[*size];
	*dat = tr->data;

	fseek(fp, 0, SEEK_SET);
	fread(tr->data, 1, *size, fp);

	return 1;

void TiffFileReader::FreeTiff(void *p)
	TiffFileReader *tr = (TiffFileReader *)p;

	delete tr;

Now, this is how we will use this method:

TIFF_DATA *td = new TIFF_DATA();
td->getTiff = TiffFileReader::GetTiff;
td->freeTiff = TiffFileReader::FreeTiff;

TiffFileReader *tr = new TiffFileReader(fileName);

td->data = tr;


Questions or comments on the API? Please feel free to contact us if you need help using the API or have additional questions, or check the forums.

Blog Entries
Blob Entry 1
Blob Entry 2
Blob Entry 3
Blob Entry 4
Blob Entry 5
Blob Entry 6