C# Example

The Amyuni PDF Converter is our Printer Driver that enables you to convert any documents to PDF format. If you have any questions about installing and using the Amyuni PDF Converter please post them here.
Post Reply
Iggi
Posts: 3
Joined: Mon Jan 02 2006

C# Example

Post by Iggi »

Hi, I'm looking for a c# example of PDF Converter.
I need to convert a fil (doc, xls, jpg, tif) into pdf

where can I find it ?

thanks
Iggi
Posts: 3
Joined: Mon Jan 02 2006

Post by Iggi »

Hi, try this:

// Reference cdintf.dll in installation root of PDF Creator Developper version

string strLicensTo;
string printerName;
string strActivationCode;

strLicensTo = "Evaluation Version Developer";
printerName = "Amyuni PDF Converter";
strActivationCode = "07EF...";

CDIntfEx.CDIntfExClass cdi= new CDIntfEx.CDIntfExClass();

cdi.PDFDriverInit(printerName);
cdi.DriverInit(printerName);
cdi.EnablePrinter(strLicensTo, strActivationCode);
cdi.DefaultFileName = @"C:\Test\AAA.pdf";
cdi.FileNameOptionsEx = 3; //NoPrompt + UseFileName
cdi.SetDefaultPrinter();
cdi.BatchConvert(@"C:\Test\AAA.doc");
cdi.RestoreDefaultPrinter();
cdi.FileNameOptions = 0;
It works correctly, but my question is: it is correct ? :shock:

cdintf.dll is correct Dll ? or it is a wrapper of someting else ?

Answer please ...


Thanks and best regards
Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan »

Hello,

I will post here a C# sample that prints Crystal Reports to PDF using CDintfNet.dll (.Net version of CDIntf).

You can download the .Net version of CDIntf from: http://www.amyuni.com/downloads/cdintf250.zip

Code: Select all

private void Print_Click(object sender, System.EventArgs e)
{
                // Initialize the PDF Printer if not initialized yet
	if ( !initialized )
	Initialize();

                // Set FileNameOptions and output file name.
               cdiNet.FileNameOptions =  Declarations.NoPrompt+           Declarations.UseFileName;
               cdiNet.DefaultFileName = outputNet;
	
               // Initialize a new Crystal report object
              CrystalReport1 report = new CrystalReport1();
              //Select the Printer to which the report will be printed
              report.PrintOptions.PrinterName = Declarations.PrinterName;

             //Print the report, set startpageN and endPageN to 0 to print all   document
             report.PrintToPrinter(1,false,0,0);

cdiNet.FileNameOptions = 0;
}

private void Initialize()
{
	// if already called then exit
	if (initialized)
	return;
			
	// If not called than initialize it
	cdiNet.DriverInit(Declarations.PrinterName);
	cdiNet.EnablePrinter (Declarations.LicensedTo, Declarations.ActivationCode);

	// Set the Printer as Default, this is needed only if you can not print to a specific printer
	cdiNet.SetDefaultPrinter();

	// Set initialized to true
	initialized = true;
}
Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan »

Hello,

CDIntf.dll can be used as an AcitiveX or as a DLL.

We have a special .Net version of CDIntf that contains the main functions of CDintf (and not all of them). You can use it if you wish.

Hope this helps.
Iggi
Posts: 3
Joined: Mon Jan 02 2006

Post by Iggi »

Joan wrote:Hello,

CDIntf.dll can be used as an AcitiveX or as a DLL.

We have a special .Net version of CDIntf that contains the main functions of CDintf (and not all of them). You can use it if you wish.

Hope this helps.
Thanks,
but the method BatchConvert in CDIntfEx.dll not exist in CDIntfNet.dll

How con I convert a file in pdf using CDIntfNet.dll ?
Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan »

You can open the file using its corresponding application (automation) and print it to the PDF printer similarly to the code posted above.

Hope this helps.
Post Reply