Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XFRX 1

Status
Not open for further replies.

John Stephen

Programmer
Jan 29, 2019
50
AU
XFRX allows appending one PDF after another one, however this only seems to be catered for by having a different report for each time. I need to generate a whole bunch of PDF files appended to one in a loop using the same form. Is this possible? TIA, John
 
Hi Mike, thanks but I get that. The problem is that it is based on the report form not the PDF file name, so to generate hundreds of pdf's to append I would have to have a different report form for each PDF generated.
REPORT FORM report1 OBJECT m.loSession NOPAGEEJECT
REPORT FORM report2 OBJECT m.loSession
So I would have to create reports forms Report3, Report4, Report5 and so on. Even in a loop and adding a numbered extension by copying each report form from the first one and adding the number to the JustFName I think it would likely break it.
Cheers, John
 
Can you not do it by setting a printjob/endprintjob?

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
From the help...
PRINTJOB ... ENDPRINTJOB initializes the printer and certain system variables that affect printed output. It can send control codes to the printer, eject a page from the printer before and/or after a print job, initialize the printer column number, and control the number of copies printed.

PRINTJOB performs these tasks:

Sends starting printer control codes, stored in the system variable _PSCODE, to the printer. For more information on printer control codes, see the System Variables Overview topic and your printer manual.

Ejects a page if the system variable _PEJECT is set to BEFORE or to BOTH.

Sets the system variable _PCOLNO to 0. _PCOLNO stores the printer column number.

ENDPRINTJOB performs these tasks:

Sends ending printer control codes, stored in the system variable _PECODE, to the printer. You can reset the printer to the configuration it had before PRINTJOB was issued.

Ejects a page if the system variable _PEJECT is set to AFTER or to BOTH.

Loops back to PRINTJOB to print another copy of the report if the _PCOPIES system variable is set to a value higher than 1 (the default). The value of the system variable _PCOPIES determines the number of copies. When the number of copies printed equals the value of _PCOPIES, Visual FoxPro exits the loop. Program control then begins with the command immediately following ENDPRINTJOB.

PRINTJOB and ENDPRINTJOB may be executed only from within a program. You may not nest PRINTJOB ... ENDPRINTJOB commands.

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Thank you but I am not sure how this has anything to do with XFRX appending a PDF on to another PDF
 
I was thinking you could put your report form commands within a printjob/endprintjob section
thus string them all together.

I don't understand why you need to use a different name for each one, unless they have different criteria or layout

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
John, can you explain in a little more detail why you "would have to create reports forms Report3, Report4, Report5 and so on."

Put another way, what is different between these different reports? Are they in fact all the same report - that is, the same layout, etc. and based on the same FRX - but with different data each time? If so, I don't understand why you need to have Reprt3, Report4, etc.

I am just now looking at some code I wrote a few years ago. The code generates a PDF which consits of a bunch of invoices which are all addressed to the same customer. The code looks roughly like this:

Code:
SCAN <the customer table>
  SCAN <the invoice table> FOR <the current customer>
    *Prepare a cursor for the current invoice
    ...
    IF <this is the last invoice for this customer>
      REPORT FORM Invoice OBJECT loXFRX
    ELSE
      REPORT FROM Invoice NOPAGEEJECT OBJECT loXFRX
    ENDIF
  ENDSCAN
ENDSCAN

Is this anything like your scenario?

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Because apparently XFRX uses different report forms
to activate the append see the forms 1 and 2 below. So the forms have to have different names. The code below allows one append, I am just trying to figure out how to make this many appends on the one PDF
Code:
loListener=XFRX("XFRX#LISTENER") 

USE demoreps\invoices ORDER customer
LOCAL m.loSession, m.lnRetval
m.loSession = XFRX("XFRX#LISTENER")
m.lnRetval = loSession.SetParams("output.pdf",,,,,,"PDF")
IF m.lnRetval = 0
   REPORT FORM report1 OBJECT m.loSession NOPAGEEJECT
   REPORT FORM report2 OBJECT m.loSession
ELSE
   ? m.lnRetval, m.loSession.ErrorMessage(m.lnRetVal)
ENDIF
 
Sorry, John, but I still don't get it - especially the point about the forms (reports?) having to have different names. I don't see why that's required.

That said, the utility that Tom recommended looks like it could be a good solution for you. It has a command-line version, which means it can be run from within VFP without the user needing to be aware of it.

In addition, some PDF drivers have a facility for appending successive PDFs together. Some years ago I used a driver called Docucom which offered that feature and which worked very well. I don't know if it still exists, but it's likely other products have a similar feature.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
I think it is because each has different criteria, different invoice numbers or some such.
John perhaps does not know which parameters to specify or how?

Code:
LOSESSION.PROCESSREPORT("TRANSMIT","MYTABLE.ISSUREF=M.ISSUREF")

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
THanks for all the suggestions, sleeping on this I have a few ideas starting to gel. In any case thanks Tom for your suggestion which looks like a good alternative to trying to use the APPEND in XFRX if I can't make that work. Cheers, John
 

Thanks to all especially Nigel because appending to an existing PDF is simple. Here is an example which also gives options for inserting at page numbers

Code:
*// Options using SetParams()
 *AppendToFile (Logical)
 *Specifies whether the generated document will be appended to an existing file. This parameter can be either logical, numeric or a string, with the following meaning:
 * .F. An existing document will be overwritten 
 * .T. The generated report will be appended at the end of the existing document

 *Numeric
 * 0 An existing document will be overwritten
 * nnn (Page number) The generated report will be inserted to the existing document at the given page number.
 *String “R” The page will be replaced with the generated report.
 * “R:”  The page range will be replaced with the generated report.
 *“R4:8”  The generated report will be inserting between pages 3 and 9, replacing pages 4,5,6,7 and 8.

*// Example: The TEST.FRX report will be appended to the existing TEST.PDF document. If the TEST.PDF file does not exist, it will be created.
 Oxfrx = XFRX("XFRX#LISTENER")
 lnRetVal = Oxfrx.SetParams("test.pdf",,,,,,"PDF",,,,.T.)
 IF lnRetVal = 0
 REPORT FORM test object oxfrx
 ENDIF

REPORT FORM test object oxfrx NOPAGEEJECT
REPORT FORM Generic object oxfrx
 
Still can't make this work
I am trying to append a series of reports into one PDF using a loop. The code below scans through an invoice header file and selects an item cursor to produce each report on the report form Test. It runs but for some reason doesn’t add anything to the original PDF (Invoices.pdf). I couldn’t find an example using a loop like this. Could you please help

Code:
Oxfrx= xfrx("XFRX#INIT")
Oxfrx=oXFRX("XFRX#LISTENER")

SELECT Invhdr
SCAN
*// Get items from a child table here
*// Select the child table
lnRetVal = Oxfrx.SetParams("Invoices.pdf",,,,,,"PDF",,,,.T.)
IF lnRetVal = 0
REPORT FORM Test object oxfrx NOPAGEEJECT
ENDIF
SELECT Invhdr
ENDSCAN
Oxfrx.Finalize()
Oxfrx.Release
 
John,

I'm not sure about this, but there are two possible issues.

First, normally when you use NOPAGEEJECT, you need to do so for each report except the last. So you would normally do your REPORT FORM within the loop, using NOPAGEEJECT, then do another REPORT FORM outside the loop, without the NOPAGEEJECT.

You might try doing that here. But, having said that, the XFRX docs indicate that you don't use NOPAGEEJECT at all when appending to PDFs. This is the sample code that the docs show:

Code:
LOCAL m.loXFRX, m.lnRetVal
m.loXFRX = XFRX("XFRX#LISTENER")
m.lnRetVal = m.loXFRX.SetParams("test.pdf",,,,,,"PDF",,,,.T.)
IF m.lnRetVal = 0
   REPORT FORM test OBJECT m.loXFRX
ENDIF

Source:
This looks similar to your own code, but without the NOPAGEEJECT. So that might be something to try first.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
No that didn't make any difference, but I will try doing one outside the loop
Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top