- 23 -
8.3 Object rotation
Note: This paragraph applies both to VFP 9 and VFP 8.
To rotate a text or a picture in PDF output, add “#UR ROTATE” (without the quotation
marks) to the comment of the report field. The text or the picture will rotate
counterclockwise by the entered angle, e.g. to print vertically, add: “#UR ROTATE 90”.
8.4 Appending generated output to existing PDF Documents
Note: This paragraph applies both to VFP 9 and VFP 8.
From version 10.1, XFRX is able to append the generated report to an existing PDF
document. It is possible to append the report at the end of the document or at an
arbitrary position within the document: with either inserting the new pages or replacing
the pages in the existing PDF document.
In XFRX for VFP 8 this feature is controlled by a new parameter of SetParams(…)
method: tuAppend. Please see the SetParams method reference
na stránce 80 for more
information about setting this parameter.
In XFRX for VFP 9 you can interchangeably use the new parameter of SetParams(…)
method or AppendToFile property of the XFRXListener class.
It's not guaranteed that XFRX will be able to append to any PDF document. It
works fine with PDF documents generated by XFRX and we've successfully tested
PDFs from other sources, too, but the PDF specification allows for some internal
structures that XFRX wouldn't be able to decode. (To be precise: XFRX doesn’t
support linearized PDF documents and documents that use page tree structures).
Because of the way the PDF file is constructed, the size of the PDF document
never shrinks, even if the number of pages in the resulting PDF document is
smaller than in the original one.
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
8.5 Digital signatures in PDF
The digital signature can be used to validate the document content and the identity of
the signer. (You can find more at http://en.wikipedia.org/wiki/Digital_signature).
XFRX implements the "MDP (modification detection and prevention) signature" based
on the PDF specification version 1.7, published in November 2006.
- 24 -
The signing algorithm in XFRX computes the encrypted document digest and places it,
together with the user certificate, into the PDF document. When the PDF document is
opened, the Adobe Acrobat (Reader) validates the digest to make sure the document has
not been changed since it was signed. It also checks to see if the certificate is a trusted
one and complains if it is not. The signature dictionary inside PDF can also contain
additional information and user rights - see below.
At this moment XFRX supports invisible signatures only (Acrobat will show the
signature information, but there is no visual element on the document itself linking to
the digital signature). We will support visible signatures in future versions.
In the current version, XFRX is using the CMS/PKCS #7 detached messages signature
algorithm in the .net framework to calculate the digest - which means the .NET
framework 2.0 or newer is required. The actual process is run via an external exe -
"xfrx.sign.net.exe", that is executed during the report conversion process. In future, we
can alternatively use the OpenSSL library instead.
8.5.1 How to invoke the digital signing
(Note: the syntax is the same for VFP 9.0 and pre-VFP 9.0 calling methods)
To generate a signed PDF document, call the DigitalSignature method before calling
SetParams. The DigitalSignature method has 7 parameter:
The .pfx file. pfx, the "Personal Information Exchange File". This file contains the public
certificate and (password protected) private key. You get this file from a certificate
authority or you can generate your own for testing, which for example, OpenSSL
(http://www.slproweb.com/products/Win32OpenSSL.html). XFRX comes with a
sample pfx that you can use for testing.
The password protecting the private key stored in the .pfx file
per PDF specification:
1 - No changes to the document are permitted; any change to the document invalidates
2 - Permitted changes are filling in forms, instantiating page templates, and signing;
other changes invalidate the signature. (this is the default value)
3 - Permitted changes are the same as for 2, as well as annotation creation, deletion and
modification; other changes invalidate the signature.
per PDF specification: The name of the person or authority signing the document. This
value should be used only when it is not possible to extract the name from the signature;
for example, from the certificate of the signer.
- 25 -
per PDF specification: Information provided by the signer to enable a recipient to
contact the signer to verify the signature; for example, a phone number.
per PDF specification: The CPU host name or physical location of the signing.
per PDF specification: The reason for the signing, such as ( I agree ... ).
The demo application that is bundled with the package (demo.scx/demo9.scx) contains a
testing self-signed certificate file (TestEqeus.pfx) and a sample that creates a signed PDF
using the pfx. Please note Acrobat will confirm the file has not changed since it was
signed, but it will complaing the certificate is not trusted - you would either need to add
the certificate as a trusted one or you would need to use a real certificate from a
certification authority (such as VeriSign).
8.6 PDF/A support
PDF/A is an ISO standard for the digital preservation of electronic documents. PDF/A
document is a PDF document with specific restrictions that ensure that the document
will always display and print exactly the same way, no matter which platform or
document viewer is used:
No hidden or transparent content
All information needed to display the document is embedded (including fonts)
Document metadata stored as XML
No encryption, no password protection
No LZW compression
Displayed and printed content must match (all annotations must be printed)
There are currently two PDF/A specifications:
PDF/A-1 from 2005
PDF/A-2 from 2011
XFRX currently supports specification PDF/A-1 Level “B” (PDF/A-1b).
Note: Please note the PDF/A-enabled document files can be significantly larger than
regular PDF documents because the used fonts must always be included.
- 26 -
8.6.1 Invoking PDF/A
To generate a PDF/A document, call SetPDFA(.T.) method on the session object
before processing. This method is available in VFP8 and VFP9 session objects, as well as
the XFRX#DRAW object.
loObj = EVALUATE([XFRX("XFRX#LISTENER")])
lnRetVal = loObj.SetParams("pdfa9.pdf",,,1250,,,"PDF")
IF lnRetVal = 0
REPORT FORM demoreps\invoices object loObj
- 27 -
9 Word specific features
9.1 Password protection
Note: This paragraph applies both to VFP 9 and VFP 8. The setPasswords method is
implemented both in XFRXListener and XFRXSession classes.
To add passwords to Word documents, call SetPasswords() method before calling
You can omit either tcReadPassword or tcWritePassword. tlRequirePassword is optional
(default value is .F.). If set to .T., Word will ask for the password even when the
document is being opened first time after the generation (if tlNotOpenViewer parameter
of SetParams method is set to .F.).
9.2 Word document splitting
Note: This paragraph applies to VFP 8 only.
When the generated documents are very long, Word application has problem with the
conversion - it takes very long to convert it. To avoid this problem, XFRX can split the
generated document into more smaller documents. To set this up, call SplitDocument()
method before calling ProcessReport():
tnPagesp is the number of pages each of the resulting documents would have.
- 28 -
10 Flow layout document option
Note: This chapter links to several sample documents at our web site. If you are reading
an electronic version of this document, simply click the hyperlinks to download them. If
you are reading a printed version, here are the addresses:
Word documents, RTF documents, OpenOffice Writer documents and OpenOffice Calc
documents have two output options – “Absolute positioned layout” and “Flow layout”.
The generated documents often look the same, but the algorithms behind these options
are completely different. The absolute positioned layout always looks like the original
report, but is hard to edit and bigger in size. The flow layout may not always look exactly
the same, but it is a 'real' Word document - easily editable, with styles, page headers and
footers, paragraphs and tab stops, which is also shorter in size and faster to open.
Each of the output options have its own parameter code that is sent at the 7
(targetType) of the SetParams method:
Word document with absolute layout
Word document with flow layout
RTF document with absolute layout
RTF document with flow layout
OpenOffice Writer document with absolute layout ODT
OpenOffice Writer document with flow layout
OpenOffice Calc spreadsheet with absolute layout ODS
OpenOffice Calc spreadsheet with flow layout
This chapter describes the Flow layout output option – how it works and how it differs
from the Absolute positioned layout.
10.1 Running the conversion
Flow layout Word option is implemented as a new target type, so simply send “FDOC” as
the tcTarget parameter of the SetParams() method.
10.2 How it works
The logic is similar to the way how plain text option works. During the generation
process, XFRX takes each section – one by one – and tries to split it to individual lines.
Then each line is added to the output, respecting the vertical position of the line on the
- 29 -
paper and horizontal positions of individual objects. Vertically misaligned objects are
moved down to the closest baseline.
This report definition:
will be split to three lines and the resulting document will look like this:
As you can see all objects are aligned to the same baseline and the horizontal position is
set by a tab stop (left, right or center, depending on the field’s alignment). If you add any
graphics or pictures, these are added to the document and linked to the paragraph it
starts at, so if you add contents above the graphics, it will move down along with the
If XFRX cannot create distinct lines or if the text objects overlap one another, the
overlapping text object is placed at the exact position as a textbox.
- 30 -
>> converts to >>
10.3 Page headers and footers
Page headers and footers defined in the report are converted to page headers and footers
in the Word document, so for example, if you add a line in the middle of a page, the page
footer will not move to the next page header, but stay in place.
Even though most reports are converted without problems, there are certain scenarios
when the output wouldn’t look as expected. As stated above, all fields in one line are
aligned to the same baseline. In some reports, this can cause a problem, for example:
>> converts as >>
Not only is the “two” text too below, it is also printed over the “three” one (“three” is
placed too high to be on a separate line, so it is converted as a textbox). In this case, you
may want to tell the engine that “two” and “three” objects should always be treated as
absolute positioned textboxes.
To do this, add “#UR POSITIONABSOLUTE” as a comment of these fields:
Documents you may be interested
Documents you may be interested