GetContent() method

Gets content from PDF file.

XFRX version: 19.0

pdfReader::GetContent(m.liPage, m.luDest, m.liFlag, m.lcFileName)

Parameters

liPage
Number of pages the reader reads from. If the value is -1, then the reader reads content from all pages .

m.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.

TypeTextRectangleHorizontal and
vertical line
ImagesOther lines and curvesAppend mode for destination
VariableYesNoNoNoNoYes
Flat fileYesNoNoNoNoYes
XFRX#DRAWYesYesYesYesNoYes
XFRX#XMLYesYesYesYesNoNo
PDFL#INITYesYesYesYesYesYes

m.liFlag

BitValueDescription
01append mode for content
9512the output is a file
101024the output is a XFRX#DRAW,  XFRX#XML and PDFL#INIT object

m.lcFileName
 Output file name for XFRX#DRAW,  XFRX#XML, PDFL#INIT

Return value

Boolean.
.T. if content readed or .F. if not.

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()