not working

If you are a VFP developer and have any questions about using our products from VFP here is the place to post them.
Post Reply
eccountable1
Posts: 2
Joined: Thu Nov 11 2004

not working

Post by eccountable1 »

I inherited a project from another developer that had TONS of duplicated code with the calls to the Amyuni ActiveX control throughout. We are using v2.03. I have 15 years VFP experience and have spent 30+ hours trying to get this to work. I am stumped - what did I miss?

So I tried to simplify it by making a custom class that containted my object reference to the Amyuni control. It will not print a single report, but if I try to create a second report and put them together, the second reports comes out and not the first. The CLOSE() method (below) fails because the first file is never created. My program looks like this:

oPdf=CREATEOBJECT('pdfconvert', 'F:\archive\invoice\',lcfilename)
REPORT FORM coversheet TO PRINTER NOCONSOLE
oPdf.append()
REPORT FORM Invoice TO PRINTER NOCONSOLE
oPdf.close()


IN the Init, I have:
LPARAMETERS pcDirectory, pcFileStem
this.oFile = CREATEOBJECT('cdintf.cdintf')
this.oFile.driverinit( 'Amyuni PDF Converter' )
this.oFile.SetDefaultConfig()
this.oFile.filenameoptions = 03
this.oFile.setdefaultprinter()
this.icDirectory=ALLTRIM(pcDirectory)
this.icfilestem=ALLTRIM(pcFileStem)
this.oFile.defaultdirectory = ALLTRIM(pcDirectory)
this.oFile.defaultfilename = ALLTRIM(pcDirectory) + ALLTRIM(pcFileStem) + '.pdf'
this.oDocument = CREATEOBJECT('cdintf.document')
SET PRINTER TO NAME ('Amyuni PDF Converter')

The Append Method:
* each time we call this, put a different number on the end of the file name
* so that we have each print run in a different file
&& increment the next temp file number
this.inTempcount=this.intempcount+1
this.oFile.defaultdirectory = this.icDirectory
&& set the output file name as the filename+temp file number
this.oFile.defaultfilename = this.icDirectory + this.icfilestem + ALLTRIM(STR(this.inTempcount))+'.pdf'


The Close method:
* clean up all temp files and roll them into a single PDF file
IF this.inTempcount > 0 && if we incremented the temp file counter
this.oDocument.open(this.icDirectory + this.icfilestem +'.pdf') && open the original PDF
LOCAL lnI
FOR lnI=1 TO this.inTempCount && open each of the temp files and append them to the original
this.oDocument.append(this.icdirectory + this.icfilestem + ALLTRIM(STR(lni))+'.pdf')
ERASE (this.icdirectory + this.icfilestem + ALLTRIM(STR(lni))+'.pdf') && dump un-used temp files
NEXT
this.inTempCount = 0 && reset time file counter in case a new print job starts
&& write the new file
this.oDocument.save(this.icdirectory + this.icfilestem + '.pdf')
ENDIF
eccountable1
Posts: 2
Joined: Thu Nov 11 2004

firgured it out

Post by eccountable1 »

The report form had the printer setup coded in the FRX so when it ran, the output was being sent to the Laserprinter instead of Amyuni . Note to all that follow: clean out printer driver info manually from the FRX before trying to use Amyuni.

USE reportform.frx
replace tag with ''
replace tag2 with ''

then remove DRIVER, DEVICE, and OUTPUT from the EXPR memo field. I automated this with STRTRAN() function.

Good luck.

Nelson Johnson
888-343-3487
Post Reply