GetContent Method
Gets content from PDF file.
Object.GetContent(liPage, luDest, liFlag, lcFileName)
Parameters
liPage
Number of pages the reader reads from. If the value is -1, then the reader reads content from all pages .
luDest
Specifies the output type. It can be VFP memory variable, a flat file or a reference to XFRX#DRAW, XFRX#XML and PDFL#INIT object.
Type | Text | Rectangle | Horizontal and vertical line | Images | Other lines and curves | Append mode for destination |
---|---|---|---|---|---|---|
Variable | Yes | No | No | No | No | Yes |
Flat file | Yes | No | No | No | No | Yes |
XFRX#DRAW | Yes | Yes | Yes | Yes | No | Yes |
XFRX#XML | Yes | Yes | Yes | Yes | No | No |
PDFL#INIT | Yes | Yes | Yes | Yes | Yes | Yes |
liFlag
Bit | Value | Description |
---|---|---|
0 | 1 | append mode for content |
9 | 512 | the output is a file |
10 | 1024 | the output is a XFRX#DRAW, XFRX#XML and PDFL#INIT object |
lcFileName
Output file name for XFRX#DRAW, XFRX#XML, PDFL#INIT
Return value
Boolean.
.T. if content readed or .F. if not.
Remarks
Applies To: PDF#READER
XFRX version: 19.0
Variable and Flat file text data format:
The code page is UTF-8. The field separator is TAB character. Left and top values are in FRU.
<page number><font name><font size><bold><italic><cpdepage><left><top><text>
Examples
Using variable output
m.loPDFR = EVALUATE([xfrx("PDF#READER")]) *m.loPDFR.SetPasswords("owner","user") && set password for pdf file m.lcFile="BASE-UNI.pdf" IF m.loPDFR.openDocument(m.lcFile) < 0 RETURN ENDIF m.lnError=m.loPDFR.ReadDocument() LOCAL m.lcVar m.loPDFR.GetContent(1, @m.lcVar, 0) && reset variable to empty string m.loPDFR.GetContent(2, @m.lcVar, 1) ?m.lcVar m.lcVar="First Row"+CHR(13) m.loPDFR.GetContent(1, @m.lcVar, 1) && add content to variable m.loPDFR.GetContent(2, @m.lcVar, 1) ?m.lcVar m.loPDFR.closeDocument()
Using flat file output
m.loPDFR = EVALUATE([xfrx("PDF#READER")]) *m.loPDFR.SetPasswords("owner","user") && set password for pdf file m.lcFile="BASE-UNI.pdf" IF m.loPDFR.openDocument(m.lcFile) < 0 RETURN ENDIF m.lnError=m.loPDFR.ReadDocument() LOCAL m.lcFileOut m.lcFileOut=m.lcFile+".txt" m.loPDFR.GetContent(1, m.lcFileOut, 512+0) && create new file m.loPDFR.GetContent(2, m.lcFileOut, 512+1) MODI FILE (m.lcFileOut) m.lcFileOut=m.lcFile+".txt" =STRTOFILE("First Row"+CHR(13), m.lcFileOut) && VFP 6,7,8,9 m.loPDFR.GetContent(1, m.lcFileOut, 512+1) && add content to file m.loPDFR.GetContent(2, m.lcFileOut, 512+1) MODI FILE (m.lcFileOut) m.loPDFR.closeDocument()
Using XFRX#DRAW output
m.loPDFR = EVALUATE([xfrx("PDF#READER")]) *m.loPDFR.SetPasswords("owner","user") && set password for pdf file m.lcFile="BASE-UNI.pdf" IF m.loPDFR.openDocument(m.lcFile) < 0 RETURN ENDIF m.lnError=m.loPDFR.ReadDocument() LOCAL m.loXFF, m.loSession m.loXFF=EVALUATE([xfrx("XFRX#DRAW")]) m.loSession=EVALUATE([xfrx("XFRX#INIT")]) * create XXF cursor and transform to PDF m.loPDFR.GetContent(1, m.loXFF, 1024+0) m.loPDFR.GetContent(2, m.loXFF, 1024+1) m.lnRetVal = m.loSession.SetParams(m.lcFile+".pdf",,.T.,65001,,,"PDF") IF m.lnRetVal=0 m.loSession.SetOtherParams("DONOTZIPTEXTSTREAM",.T.) m.loSession.TransformReport(m.loXFF) ENDIF * open XXF table and transform to PDF m.loXFF.OpenDocument("some.xff") m.loPDFR.GetContent(1, m.lcFileOut, 1024+1) && add content to file m.loPDFR.GetContent(2, m.lcFileOut, 1024+1) MODI FILE (m.lcFileOut) m.lnRetVal = m.loSession.SetParams(m.lcFile+".pdf",,.T.,65001,,,"PDF") IF m.lnRetVal=0 m.loSession.SetOtherParams("DONOTZIPTEXTSTREAM",.T.) m.loSession.TransformReport(m.loXFF) ENDIF m.loPDFR.closeDocument()
Using XFRX#XML output
m.loPDFR = EVALUATE([xfrx("PDF#READER")]) *m.loPDFR.SetPasswords("owner","user") && set password for pdf file m.lcFile="BASE-UNI.pdf" IF m.loPDFR.openDocument(m.lcFile) < 0 RETURN ENDIF m.lnError=m.loPDFR.ReadDocument() LOCAL m.loXML, m.loSession m.loXML=EVALUATE([xfrx("XFRX#XML")]) m.loSession=EVALUATE([xfrx("XFRX#INIT")]) * create XML file and transform to PDF m.loPDFR.GetContent(1, m.loXML, 1024+0, lcfile+".xml") m.loPDFR.GetContent(2, m.loXML, 1024+1, lcfile+".xml") m.loXML.FinishDocument() m.loXML.OpenDocument(lcfile+".xml") m.lnRetVal = m.loSession.SetParams(m.lcFile+".pdf",,.T.,65001,,,"PDF") IF m.lnRetVal=0 m.loSession.SetOtherParams("DONOTZIPTEXTSTREAM",.T.) m.loSession.TransformReport(m.loXML) ENDIF m.loPDFR.closeDocument()
Using PDFL#INIT output
m.loPDFR = EVALUATE([xfrx("PDF#READER")]) *m.loPDFR.SetPasswords("owner","user") && set password for pdf file m.lcFile="BASE-UNI.pdf" IF m.loPDFR.openDocument(m.lcFile) < 0 RETURN ENDIF m.lnError=m.loPDFR.ReadDocument() LOCAL m.loPDFL m.loPDFL=EVALUATE([xfrx("PDFL#INIT")]) m.loSession=EVALUATE([xfrx("XFRX#INIT")]) * create new PDF file m.loPDFR.GetContent(1, m.loPDFL, 1024+0, lcfile+".pdf") m.loPDFR.GetContent(2, m.loPDFL, 1024+1, lcfile+".pdf") m.loPDFL.FinishDocument() * Append to existing PDF file m.loPDFL.CreateDocument(lcfile+".pdf", .T.) m.loPDFL.SetOtherParams("DONOTZIPTEXTSTREAM",.T.) m.loPDFR.GetContent(1, m.loPDFL, 1024+1) m.loPDFR.GetContent(2, m.loPDFL, 1024+1) m.loPDFL.FinishDocument() m.loPDFR.closeDocument()