FRX2Any PDF Add to

139 views
Skip to first unread message

randy.stevens25

unread,
Apr 11, 2018, 11:49:25 AM4/11/18
to FRX2Any
Hi Marat,

I have FRX2Any version 14.02.00 and am having issues with adding to my PDF in the correct order.  I am creating a PDF statement that contains several different reports.  The first report I create looks fine but the subsequent report seems to overwrite the first report even though I have the cAddTo set appropriately with the same file location and I have the nAddtotype set to 1.

What could I be doing wrong?  If I pause my app after the first report I can see it there, then let it go to the second report and it is then only the second report - duplicated so that the second report appears twice now.

This is essentially my procedure for creating the PDF.  I am creating and releasing the object between reports in case that can cause an issue.

********************************************************************************************************************************************************
lcFRX2AnyLibrary = 'FRX2Any'
SET CLASSLIB TO &lcFRX2AnyLibrary IN FRX2Any.APP ALIAS FRX2Any
loFile = CREATEOBJ('FRX2Any.PDFFile')
IF TYPE('loFile') = 'O'
*-- Unlock FRX2Any
loFile.UNLOCK('XXXXX')  && I Removed the unlock code for posting

*-- NOTE: loFile.cExportFileName should not include file extension. For example: loFile.cExportFileName = "ReportOutput"
loFile.cExportFileName = JUSTSTEM(pcPDFName)
* Not first page then add to the existing PDF
IF plAppend = .T.           && plAppend tells me if I need to begin appending to the existing file
loFile.cAddTo  = pcPDFName+'.PDF'
loFile.nAddtotype = 1
ENDIF 

*-- NOTE: loFile.cSaveFolder should contain only path to the output file. For example: loFile.cSaveFolder = "c:\MyApp\MyOutPut\"
loFile.cSaveFolder     = ADDBS(JUSTPATH(pcPDFPath))

*-- Force FRX2Any to display conversion process status
loFile.lDisplayStatus  = .T.

*-- Specifies that output file will be displayed after creation
loFile.nOutPutType = cnOUTPUT_FILE
*-- Force FRX2ANY to use localized name of the font(s). 
*-- Set up this property to true, if your OS used translated font names (Arial Fett,  Arial Negrita, Arial Italique) 
loFile.lTranslateFontStyle = .T.
*-- Specify a Code Page. 
loFile.nCodePage = 1252

xcReportForm = LEFT(SYS(2005),RAT("\",SYS(2005)))+pcReportName
lnResult = loFile.SAVE(xcReportForm)
IF lnResult<>0
=MESSAGEBOX('PDF Creation Error#: '+ALLTRIM(STR(lnResult)),16,'PDF Create Error')
ENDIF
loFile.RELEASE()


Thanks,

Randy Stevens


Marat Chariev

unread,
Apr 11, 2018, 12:11:11 PM4/11/18
to frx...@googlegroups.com
Try to use code below:

lcFRX2AnyLibrary = 'FRX2Any'
SET CLASSLIB TO &lcFRX2AnyLibrary IN FRX2Any.APP ALIAS FRX2Any
loFile = CREATEOBJ('FRX2Any.PDFFile')

IF TYPE('loFile') = 'O'
*-- Unlock FRX2Any
loFile.UNLOCK('XXXXX')  && I Removed the unlock code for posting

xcReportForm = LEFT(SYS(2005),RAT("\",SYS(2005)))+pcReportName



*-- NOTE: loFile.cExportFileName should not include file extension. For example: loFile.cExportFileName = "ReportOutput"
*-- MC loFile.cExportFileName = JUSTSTEM(pcPDFName)
loFile.cExportFileName = JUSTSTEM(xcReportForm)

* Not first page then add to the existing PDF
IF plAppend = .T.           && plAppend tells me if I need to begin appending to the existing file
*-- MC loFile.cAddTo  = pcPDFName+'.PDF'
*-- PDF output file will be added to another existing PDF file (specified in loFile.cAddTo)
loFile.cAddTo = FULLPATH(pcPDFName+'.PDF')
loFile.nAddtotype = 1
ENDIF

*-- NOTE: loFile.cSaveFolder should contain only path to the output file. For example: loFile.cSaveFolder = "c:\MyApp\MyOutPut\"
*-- MC loFile.cSaveFolder = ADDBS(JUSTPATH(pcPDFPath))
loFile.cSaveFolder = ADDBS(JUSTPATH(xcReportForm))

*-- Force FRX2Any to display conversion process status
loFile.lDisplayStatus  = .T.
*-- Specifies that output file will be displayed after creation
loFile.nOutPutType = cnOUTPUT_FILE

*-- Force FRX2ANY to use localized name of the font(s).
*-- Set up this property to true, if your OS used translated font names (Arial Fett,  Arial Negrita, Arial Italique)
loFile.lTranslateFontStyle = .T.

*-- Specify a Code Page.
loFile.nCodePage = 1252

*-- MC xcReportForm = LEFT(SYS(2005),RAT("\",SYS(2005)))+pcReportName

lnResult = loFile.SAVE(xcReportForm)
IF lnResult<>0
=MESSAGEBOX('PDF Creation Error#: '+ALLTRIM(STR(lnResult)),16,'PDF Create Error')
ENDIF
loFile.RELEASE()





From: randy.stevens25 <randy.s...@gmail.com>
To: FRX2Any <frx...@googlegroups.com>
Sent: Wednesday, April 11, 2018 11:49 AM
Subject: FRX2Any PDF Add to

--
You received this message because you are subscribed to the Google Groups "FRX2Any" group.
To unsubscribe from this group and stop receiving emails from it, send an email to frx2any+u...@googlegroups.com.
To post to this group, send email to frx...@googlegroups.com.
Visit this group at https://groups.google.com/group/frx2any.
For more options, visit https://groups.google.com/d/optout.


randy.stevens25

unread,
Apr 12, 2018, 1:07:01 PM4/12/18
to FRX2Any
Hi Marat,

Thank you for that.  I did try that code but I'm still not clear on what I'm doing wrong.  I have created a new test that you where you can just run the .prg and see what results I'm seeing.  At least I hope:

Code is between asterisks
**************************************
CREATE CURSOR TempData (field1 n(10,0),field2 c(30), field3 c(30))

INSERT INTO TempData (field1,field2,field3) VALUES (123456,'Field 2 Contents for 123456','Field 3 Contents for 123456')

lcFRX2AnyLibrary = 'FRX2Any'
SET CLASSLIB TO &lcFRX2AnyLibrary IN FRX2Any.APP ALIAS FRX2Any
loFile = CREATEOBJ('FRX2Any.PDFFile')
IF TYPE('loFile') <> 'O'
=MESSAGEBOX('Object creation failed!',16,'Error')
RETURN
ENDIF

loFile.UNLOCK('xxxxxx-xxxxxx-xxxxxx-xxxxxx-xxxxxx-xxxxxx-xxxxxx-xxxxxx')

loFile.cExportFileName = 'Frx2AnyTest'

loFile.cSavefolder = 'c:\foxtemp\'

SELECT TempData
lnResult = loFile.SAVE('c:\foxtemp\Frx2AnyTest.frx')

=MESSAGEBOX('Now check PDF for contents noticing 123456 is there and its the only page',16,'Continue')

UPDATE TempData SET Field1 = 654321, Field2 = 'Field2 contents for 654321', Field3 = 'Field3 contents for 654321'

loFile.cAddTo = 'c:\foxtemp\Frx2AnyTest.pdf'
loFile.nAddtotype = 1
loFile.nOutputType = 1
SELECT TempData

=MESSAGEBOX('Now after creation, check PDF for contents and notice that 123456 is NO longer there and 654321 is there on both pages!',16,'Continue')

lnResult = loFile.SAVE('c:\foxtemp\Frx2AnyTest.frx')

RELEASE loFile

CLOSE DATABASES 
**************************************

randy.stevens25

unread,
Apr 12, 2018, 1:07:01 PM4/12/18
to FRX2Any
I apologize if this is duplicating but it appeared that my post did not go through so I'm posting it again.

I have included an example piece of code (between the asterisks) that you can run for yourself and see if you get the same results I get which is that the first time the PDF is created it contains the first data fields and then the second time after the data is changed the PDF then contains only the second field values on both pages.  I would expect page one to contain the first set of field values then page two to contain the second set of values but I only see the second set of values on both pages.

**************************************
CREATE CURSOR TempData (field1 n(10,0),field2 c(30), field3 c(30))

INSERT INTO TempData (field1,field2,field3) VALUES (123456,'Field 2 Contents for 123456','Field 3 Contents for 123456')

lcFRX2AnyLibrary = 'FRX2Any'
SET CLASSLIB TO &lcFRX2AnyLibrary IN FRX2Any.APP ALIAS FRX2Any
loFile = CREATEOBJ('FRX2Any.PDFFile')
IF TYPE('loFile') <> 'O'
=MESSAGEBOX('Object creation failed!',16,'Error')
RETURN
ENDIF

loFile.UNLOCK('XXXXXX-XXXXXX-XXXXXX-XXXXXX-XXXXXX-XXXXXX-XXXXXX-XXXXXX')

loFile.cExportFileName = 'Frx2AnyTest'

loFile.cSavefolder = 'c:\foxtemp\'

SELECT TempData
lnResult = loFile.SAVE('c:\foxtemp\Frx2AnyTest.frx')

=MESSAGEBOX('Now check PDF for contents noticeing 123456 is there and its the only page',16,'Continue')

Marat Chariev

unread,
Apr 12, 2018, 1:39:14 PM4/12/18
to FRX2Any
Hi Randy
Try to run code below. First it will create PDF file Frx2AnyTest1 in c:\foxtemp\ folder
Then it will convert same report into PDF file Frx2AnyTest2 in c:\foxtemp\ folder and merge Frx2AnyTest1 with Frx2AnyTest2
Resulting file will be Frx2AnyTest2 (this PDF file will contains info from both PDF files)  See attached files. 


***********************************
CREATE CURSOR TempData (field1 n(10,0),field2 c(30), field3 c(30))

INSERT INTO TempData (field1,field2,field3) VALUES (123456,'Field 2 Contents for 123456','Field 3 Contents for 123456')

lcFRX2AnyLibrary = 'FRX2Any'
SET CLASSLIB TO &lcFRX2AnyLibrary IN FRX2Any.APP ALIAS FRX2Any
loFile = CREATEOBJ('FRX2Any.PDFFile')
IF TYPE('loFile') <> 'O'
=MESSAGEBOX('Object creation failed!',16,'Error')
RETURN
ENDIF

loFile.UNLOCK('xxxxxx-xxxxxx-xxxxxx-xxxxxx-xxxxxx-xxxxxx-xxxxxx-xxxxxx')

loFile.cExportFileName = 'Frx2AnyTest1'

loFile.cSavefolder = 'c:\foxtemp\'

SELECT TempData
lnResult = loFile.SAVE('c:\foxtemp\Frx2AnyTest.frx')

=MESSAGEBOX('Now check PDF for contents noticing 123456 is there and its the only page',16,'Continue')

UPDATE TempData SET Field1 = 654321, Field2 = 'Field2 contents for 654321', Field3 = 'Field3 contents for 654321'

loFile.cAddTo = 'c:\foxtemp\Frx2AnyTest1.pdf'
loFile.nAddtotype = 1
loFile.nOutputType = 1
SELECT TempData

=MESSAGEBOX('Now after creation, check PDF for contents and notice that 123456 is NO longer there and 654321 is there on both pages!',16,'Continue')


loFile.cExportFileName = 'Frx2AnyTest2'

loFile.cSavefolder = 'c:\foxtemp\'

lnResult = loFile.SAVE('c:\foxtemp\Frx2AnyTest.frx')

RELEASE loFile

CLOSE DATABASES 


***********************************
Frx2AnyTest1.pdf
Frx2AnyTest2.pdf

randy.stevens25

unread,
Apr 12, 2018, 4:47:54 PM4/12/18
to FRX2Any
Thank you so much Marat!  I see how it works now.  I'll just have to adjust my process to work with it.

Randy
Reply all
Reply to author
Forward
0 new messages