skrivardriver tiff

tiffSTAMP with Microsoft Visual C

The following example shows how to use the tiffSTAMP ActiveX interface together with Microsoft Visual C.

 


#define INPUT_FILE "in.tif"

//Add basic COM-functionality
#include <objbase.h>

//Just used for this example here (printf):
#include <stdio.h>

//Import the interface table. Tiffstamp provides the table in the
//DLL itself, no further files needed. In the ./Debug - subdirectory
//the compiler creates the files "dcstmp10.tlh" and "dcstmp10.tli".
//Read "./Debug/dcstmp10.tlh" to learn more about tiffstamp.
//All declarations are available in the namespace "dcstmp10" now.

//TODO: Provide a path to the DLL-file here:
#import "dcstmp10.dll"

void main()
{

  //Enable COM in this application
  CoInitialize(NULL);

  printf("Running...\n");


  //Create a smart pointer to ITiffStamp.
  //ItiffstampPtr is not the actual interface, but a template C++ class
  //(_com_ptr_t) that contains an embedded instance of the raw Itiffstamp pointer.
  //While destructing, the destructor makes sure to invoke Release() on the internal
  //raw interface pointer. Further, the operator -> has been overloaded to direct all
  //method invocations to the internal raw interface pointer.
  //Learn more about smart pointers reading the help under "_COM_SMARTPTR_TYPEDEF",
  //"#import" and "_com_ptr_t".

  dcstmp10::ItiffstampPtr pTiffStamp;


  //Now create a real instance of tiffstamp using a "progid".

  pTiffStamp.CreateInstance("dcstmp10.tiffstamp");


  //Now all properties of TiffSTAMP are available. Read the tiffSTAMP helpfile
  //to learn more. Note: Constants are declared in the dcstmp10-namespace only.
  pTiffStamp->CopyMode = dcstmp10::cmXOR;
  pTiffStamp->DefaultDPI = 300;
  pTiffStamp->CreateDirectories = false;
  pTiffStamp->ScanSubdirectories = false;
  pTiffStamp->Fontname = "Arial";
  pTiffStamp->Halftone = false;
  pTiffStamp->Page = 0;

  //Create Text-Label
  pTiffStamp->Labeled = true;
  pTiffStamp->LabelMacro = "@-100,50P@4,0C@270A@18HSTAMPED!";

  //Create no Watermark
  pTiffStamp->Stamped   = false;
  pTiffStamp->StampLeft = 10;
  pTiffStamp->StampTop  = 10;
  pTiffStamp->Stretched = false;
  //pTiffStamp->Stamp = "stamp.tif";

  //I/O - filenames
  pTiffStamp->Source = INPUT_FILE;
  pTiffStamp->Target = "out.tif";

  //Execute and show errors
  if (pTiffStamp->Run())
  printf("Ok.\n");
  else
  printf("Error: " + pTiffStamp->ErrorMsg + "\n");


  //Add a breakpoint here to view console output
  printf(".\n");
}


   © 2010 EDSG - European Data Systems Group
Industrigatan 42 hus 6, 571 38 Nässjö, Sweden
Hotline: +46 8 5592 5980   www.edsg.se