Universal Document Converter
Product Overview
Download
Purchase
Tutorials
Developer Solutions
Support Service
About fCoder SIA


      Site search
   


      Popular conversions
PDF to JPG converter
Convert Word to PDF
Convert PDF to TIFF
Autocad to PDF converter
Convert Word to JPG
Powerpoint to PDF converter
Printing to PDF
Convert Excel to PDF
Convert DJVU to PDF
Convert Web Page to PDF

      Video tutorials
Show tutorial



Main page>Developer Solutions>Examples>PHP>Excel Spreadsheets to PDF

Converting Excel Spreadsheets to PDF for PHP


'----------------------------------------------------------------------
' 1) Microsoft Excel 97 or above should be installed and activated on your PC.
'
' 2) Universal Document Converter 5.2 or above should also be installed.
'
' 3) Apache WEB server and PHP 4.0 or above should be installed and adjusted.
'----------------------------------------------------------------------
 <?PHP  
	
  //Create Universal Document Converter object 
	
  $objUDC = new COM("UDC.APIWrapper");
	
  //Set up Universal Document Converter 
		
  $itfPrinter = $objUDC->Printers("Universal Document Converter");
		
  $itfProfile = $itfPrinter->Profile;
		
  $itfProfile->PageSetup->ResolutionX = 300;
  $itfProfile->PageSetup->ResolutionY = 300;
  $itfProfile->PageSetup->Orientation = 0;
	
  $itfProfile->FileFormat->ActualFormat = 7;
  $itfProfile->FileFormat->PDF->ColorSpace = 24;
  $itfProfile->FileFormat->PDF->Compression = 4;
  $itfProfile->FileFormat->PDF->Multipage = 2;
	
  $itfProfile->OutputLocation->Mode = 1;
  $itfProfile->OutputLocation->FolderPath = '&[Documents]\UDC Output Files\\';
  $itfProfile->OutputLocation->FileName = '&[DocName(0)].&[ImageType]';
  $itfProfile->OutputLocation->OverwriteExistingFile = 1;
		
  $itfProfile->PostProcessing->Mode = 0;
			
  //Create MS Excel object and open the file
		
  $file = 'my_file.xls';
	
  $ExcelApp = new COM("Excel.Application");
  $ExcelBook = $ExcelApp->Workbooks->Open($file,0,1);
	
  //change the orientation of the active worcksheet
	
  $ExcelWorksheet = $ExcelBook->ActiveSheet;
  $ExcelPageSetup = $ExcelWorksheet->PageSetup;
  $ExcelPageSetup->Orientation = 2;
	
  //Printing the curent sheet
	
  $ExcelWorksheet->PrintOut(1,1,1,False,"Universal Document Converter");
	
  //Close the document
	
  $ExcelBook->Close(False);
	
  //Close Excel
	
  $ExcelApp->Quit;
	
  echo "READY!";
		
 ?> 


© fCoder SIA About fCoder SIA | Privacy Policy | Site Map