Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Output a report in PDF format
Message
From
13/04/2010 05:18:26
 
 
To
13/04/2010 04:52:29
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2003
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01455338
Message ID:
01459893
Views:
329
I've restored the main alias and also the pointer just after the report was called the first time (preview). This works. I would appreciate it if you can look at he code still, just to make sure I am doing it correct. I'm also interested how your RS preview works. I would prefer doing it the correct way.

Here is my code:

*!* Initialize event
LOCAL  cRSServerFolder, cGdiPlusX
cRSServerFolder = 'n:\bkb\RsDev'
DO (ADDBS(cRSServerFolder) +'ReportSculptor.App')

cGdiPlusX=addbs(_oRSGO.RS_Root) + 'GdiPlusX\system.app'   &&System_lean renamed to system
do (cGdiPlusX)
set classlib to "C:\Program Files\Microsoft Visual FoxPro 9\Ffc\_ReportListener.VCX"  additive
*!* Print command button
IF ISBLANK(thisform.txtDeclREF.value) then
	WAIT WINDOW 'You have TO enter a REFERENCE TO be used on printout!' timeout 2
	thisform.txtDeclREF.SetFocus
	RETURN
ELSE
	lcRef = thisform.txtDeclREF.value
ENDIF

SELECT lotcurs

COUNT TO lnRecCnt
IF lnRecCnt > 0 then
	REPORT FORM declletter TO PRINTER PROMPT preview
	thisform.cmdEmail.Enabled = .T.
	SELECT lotcurs   && code added to get rid of PDF error 13/10/2010
	GOTO top              && code added to get rid of PDF error 13/10/2010
	IF thisform.chkEmailVet.Value = 1 then
		lnAnswer = MESSAGEBOX('Are you sure you want to email the State VET?',4+32+256,'Email confirmation')
		IF lnAnswer = 6 then
			WAIT WINDOW 'Preparing email...' TIMEOUT 3

			LOCAL  cRSServerFolder, cGdiPlusX
                                                                 *!* For every run the filename differs
			cRSServerFolder = 'n:\bkb\RsDev'
			DO (ADDBS(cRSServerFolder) +'ReportSculptor.App')

			cGdiPlusX=addbs(_oRSGO.RS_Root) + 'GdiPlusX\system.app'   &&System_lean renamed to system
			do (cGdiPlusX)

			set classlib to addbs(home()) + "FFC\" + "_ReportListener.VCX"  additive
			gcBuyer = thisform.cbuyer

			IF ISBLANK(thisform.txtDeclREF.value) then
				WAIT WINDOW 'You have TO enter a REFERENCE TO be used on printout!' timeout 2
				thisform.txtDeclREF.SetFocus
				RETURN
			ELSE
				lcRef = thisform.txtDeclREF.value
			ENDIF

			cFrx= 'declletter.frx'
			=frx2rs(cFrx, 5 , .F.)			&& .T. = Preview

			thisform.sendemail()
			
			*!* Copy and clear files
			lcfrom = 'w:\send\' + ALLTRIM(gcExpFile) + '.pdf'
			lcTo = 'w:\send\Talman reports\RVF\Emails send\' + ALLTRIM(gcExpFile) + '.pdf'
			COPY FILE (lcfrom) TO (lcTo)
			DELETE FILE (lcFrom)
		ELSE
			WAIT WINDOW 'Email cancelled on users request!' TIMEOUT 2
		ENDIF
	ENDIF
ELSE
	WAIT WINDOW 'You have to list the records before printing them!' TIMEOUT 2
ENDIF
*!* RS program
*** Note ***

*** Do NOT Compile this prg
*** This prg is just to set you up for trying samples in this Demo Project
*** After running this, you should be able to run all stuff inside this project.
*** To verify succesfull dev setup - run helloworld test script

***See readme.txt for run time deployment instructions

*!*	clear all

*!*	********************RS / GDI+X  Inititalision sequence **********
*!*	local cRootFolder,cGdiPlusX
*!*	cRootFolder = justpath(justpath(sys(16,1)) )
*!*	do addbs(cRootFolder) + 'ReportSculptor.App'

*!*	** Initialise GdiPlusX supplied in subfolder of this project
*!*	** (Required version 1.20 with EMF support!)
*!*	cGdiPlusX=addbs(_oRSGO.RS_Root) + 'GdiPlusX\system.app'   &&System_lean renamed to system
*!*	do (cGdiPlusX)

*!*	set classlib to addbs(home()) + "FFC\" + "_ReportListener.VCX"  additive  &&Remove if you already did it elsewhere
*!*	*******************************************************************


*!*	set default to (cRootFolder)
*!*	set procedure to sys(16,1) additive
*!*	set path to ;data;FreeTables;forms;GRAPHICS;LIBS;PROGS;REPORTS additive

*** Important !!!

*** As indicated in Redme.txt, for compiling purposes
*** ALL CODE BELOW THIS POINT has to be appended (copied) to some of YOUR run time
*** visible code libraries.( Along with other general purpose functions you use)
*** See developer's guide for more info on integration.

*** Do NOT include and compile this prg into your development environment
*** Code below is used by this demo project as setup routine when you are going through samples
*** once you integrate RS, you should use your own develpment environment
*** for developing RS based reports. This project is just for demo purposes.


************************************
function rsGlobalObjectSetup
	lcExt = TTOC(DATETIME(),1)

	gcExpFile = ALLTRIM(gcBuyer) + 'RVFdecl' + ALLTRIM(lcExt)
    with _oRSGO

        **Global properties applied at RS Engine instantiation
        .xfrx_active = 'Y'  &&Change to 'Y' if you are using XFRX
        .xfrx_path   = '\XFRX127'   &&Set your own XFRX run time path


        .rs_EngineClass = 'MyRS'    && RS Engine Subclass used to customise RS Engine
        &&(Just below this function)

        .LanguagesEnabled=.f.   && To use or create localisation set to .t.
        .myLanguage = 'English' && Set to your own language (if translation exist)
        && See Localise_Strings.prg for creating new language table/translation

		.rsExportFolder = 'W:\send'
        .rsExportStem=(gcExpFile)  &&Name of export file without extension


    endwith

function pic4rs
    lparameters cFile
    local lcTmpPic,cBmpAsStr
    lcTmpPic=addbs(getenv('temp')) + sys(2015) + '.' + justext(cFile)
    cBmpAsStr = filetostr(cFile)
    =strtofile( cBmpAsStr ,  lcTmpPic   )
    **Temporary File Created will be later erased by RS
    return lcTmpPic



    ***Supporting Function for .LoadFrx() method
function RsFrx
    lparameters cFrxFile,cForClause,cWhileClause,cScope,cSummary
    if type('cFrxFile') <> 'C'
        return .f.
    endif
    if vartype(cForClause) <> 'C' or len(alltrim(cForClause)) = 0
        cForClause  = '.t.'
    endif
    if vartype(cWhileClause) <> 'C'  or len(alltrim(cWhileClause)) = 0
        cWhileClause = '.t.'
    endif

    local loReportListener,oRptStream
    oRptStream =  createobject('Frx2RsConverter')
    loReportListener = createobject("RsFrxReader")
    loReportListener.oRSRead  = oRptStream

    report form (cFrxFile) for &cForClause while &cWhileClause object loReportListener

    loReportListener.release
    loReportListener=null

    return oRptStream


    ********************************************************************
    * Customise RS Engine Calss via this subclass
    * Attach your own pageheader/footer, call your own preview form etc.
    ********************************************************************
define class MyRS as rsEngine

    lAutoPageHeader=.t.
    lAutoPageFooter=.t.
    rsPublicsHeader='Report Sculptor Version 0.95 Beta'  && Set your own default header/footer strings here
    rsPublicsFooter='Report Sculptor Version 0.95 Beta'  && Then retry HelloWorld example to verify customisation
    && More Customisation tips will folow later

    *** And don't forget that this subclass and above ini function have to be appended to some run time
    *** visible code library.( Along with other general purpose functions you use)


    **To Run your own custom form , remove comment from this line
    * rsPreviewScx = '.\Forms\myRsPreview.scx'
    rsPreviewWindowType=1   &&) Modeless
 

    procedure WithFile  && Invoked from .OutPut() method after file created
        lparameters cFile
      
        ****Customize if you need to distribute export file,
        ****Copy,rename,Edit,Show in browser or watever else you might want to do
      
        wait wind cFile + Chr(13) + 'Created Sucessfully' timeout 2
      


    procedure EmailOutput && Invoked from RS Preview Form / Button Export pressed
        lparameters cFile


        ***Simple emailing using Outlook
        ***Customize to implement your own emailing

        #define oleEmailItem 0
        local oOutlook,oEmail
        oOutlook = createobject('Outlook.Application')
        oEmail = oOutlook.CreateItem(oleEmailItem)

        oEmail.to = 'admin@report-sculptor.com'
        oEmail.CC = ''
        oEmail.subject='Report Sculptor - Sample'
        oEmail.body='I Love Report Sculptor :) '
        oEmail.Attachments.add(cFile)
        oEmail.display






    ** Calling RS preview (for customization purpses)
    ** Remove 'my_'  if you want to show your customized form.
    ** Beware that pictures might not show properly, so
    ** add them specifically to each button.
    ** They can be found under subfolder 'graphics'
    
    procedure my_RsPreview
        local cForm
        cForm = this.rsPreviewSCX

        do form (cForm) with this name oPreviewForm noshow

        if this.rsPreviewWindowType > 0
            oPreviewForm.windowtype= 1
        endif

        oPreviewForm.show()
    endproc


enddefine
Thanks

Irene
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform