creation of a pdf
- Silvio.Falconi
- Posts: 4956
- Joined: Thu Oct 18, 2012 7:17 pm
creation of a pdf
I save a text on a variable cPdf
this text must taken between two quotes of an italian electronic invoice
<Attachment> </Attachment>
cFile-> xml file
hFile := FOpen( cFile )
nFileLines := FLineCount( cfile )
i := 1
DO WHILE i <= nFileLines
HB_FReadLine( hFile, @Linea )
Linea := LTrim( Linea )
cField := hb_AtX( "<[^>]*>", Linea, .F. )
cField := SubStr( cField, 2, Len( cField ) -2 )
IF cField == 'Attachment
How take the text between the quotes <Attachment> </Attachment> and create a pdf ?
this text must taken between two quotes of an italian electronic invoice
<Attachment> </Attachment>
cFile-> xml file
hFile := FOpen( cFile )
nFileLines := FLineCount( cfile )
i := 1
DO WHILE i <= nFileLines
HB_FReadLine( hFile, @Linea )
Linea := LTrim( Linea )
cField := hb_AtX( "<[^>]*>", Linea, .F. )
cField := SubStr( cField, 2, Len( cField ) -2 )
IF cField == 'Attachment
How take the text between the quotes <Attachment> </Attachment> and create a pdf ?
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
- Marc Venken
- Posts: 727
- Joined: Tue Jun 14, 2016 7:51 am
Re: creation of a pdf
You open a XML file...
Maybe this function can help you...
Maybe this function can help you...
Code: Select all
function Xmlreader()
local aMail:={}
local hFile := FOpen( "c:\users\marc\downloads\archive.xml" )
Local oXmlDoc := TXmlDocument():New( hFile )
Local oXmlIter := TXmlIterator():New( oXmlDoc:oRoot ), oTagActual
while .T.
oTagActual = oXmlIter:Next()
If oTagActual != nil
if oTagActual:cName = "Email"
aadd(aMail,oTagActual:cData)
endif
if oTagActual:cName = "NewsletterID"
aadd(aMail,oTagActual:cData)
endif
if oTagActual:cName = "Subject"
aadd(aMail,oTagActual:cData)
endif
// MsgInfo( oTagActual:cName, oTagActual:cData )
// HEval( oTagActual:aAttributes, { | cKey, cValue | MsgInfo( cKey, cValue ) } )
Else
Exit
Endif
End
xbrowse(aMail)
FClose( hFile )
return nil
Marc Venken
Using: FWH 20.08 with Harbour
Using: FWH 20.08 with Harbour
- Marc Venken
- Posts: 727
- Joined: Tue Jun 14, 2016 7:51 am
Re: creation of a pdf
I print pdf like this
Maybe this is needed
#include "report.ch"
Maybe this is needed
#include "report.ch"
Code: Select all
function druk_rappel(nRappel)
Local nDruk:=0, nDrukafstand:= 0.5, nDrukstart:= 8.5, nType:=0
nType = nRappel
aFacturen ={}
Public oPrn
Public oF12,oF12B,oF12I,oF12U,oFlarge
cRapport = "c:\programmas\rappels\rappels\rappel_"+alltrim(klant->klant_nr)+".pdf"
ferase(cRapport)
PRINT oPrn FILE cRapport PREVIEW
DEFINE FONT oF12 NAME "CAMBRIA" SIZE 0, -10 OF oPrn
DEFINE FONT oF12B NAME "CAMBRIA" BOLD SIZE 0, -10 OF oPrn
DEFINE FONT oF12I NAME "CAMBRIA" ITALIC SIZE 0, -10 OF oPrn
DEFINE FONT oF10 NAME "CAMBRIA" SIZE 0, -10 OF oPrn
DEFINE FONT oF12U NAME "CAMBRIA" UNDERLINE BOLD SIZE 0, -10 OF oPrn
DEFINE FONT oFLarge NAME "CAMBRIA" BOLD SIZE 0, -22 OF oPrn
oPrn:startpage()
hoofding(oPrn,"RAP") // afdruk hoofding
nDruk = nDrukstart
do case
case nType = 1 // eerste rappel per mail
oPrn:cmsay (nDruk,2,"Betreft : Openstaande facturen",oF12b)
oPrn:cmsay (nDruk+1.0,2,"Geachte klant,",oF12)
oPrn:cmsay (nDruk+2.0,2,"Met dit ",oF12)
oPrn:cmsay (nDruk+2.5,2,"overschr",oF12)
oPrn:cmsay (nDruk+3.0,2,"Gelieve ",oF12)
oPrn:cmsay (nDruk+4,2,"Hieronder kan U het overzicht vinden van de openstaande facturen : ",oF12)
endcase
nDruk = nDruk + 4 + 1
// Facturen blok
oPrn:cmsay (nDruk,2," Document Datum Verval Datum Bedrag Dagen",oF12u)
nDruk += nDrukafstand
nSubsaldo := 0
facturen->(dbgotop())
do while !facturen->(eof())
if !facturen->select
facturen->(dbskip())
loop
endif
cFactuur = "d:\facturen\" + alltrim(str(facturen->factuur,6))+".pdf"
if file(cFactuur)
aadd(afacturen,{cFactuur,cFactuur})
else
msginfo("Factuur "+cFactuur+" niet gevonden")
endif
oPrn:cmsay (nDruk,2.3,str(facturen->factuur,6,0),oF12)
oPrn:cmsay (nDruk,4.3,dtoc(facturen->datum),oF12)
oPrn:cmsay (nDruk,7.3,dtoc(facturen->vervaldat),oF12)
oPrn:cmsay (nDruk,11.5,str(facturen->totaal,9,2),oF12,,,,1)
oPrn:cmsay (nDruk,13.5,str( (date()-facturen->vervaldat),9,0),oF12,,,,1)
nDruk += nDrukafstand
facturen->(dbskip())
enddo
nDruk += nDrukafstand
*/
do case
case nType >= 1
oPrn:cmsay (nDruk,2,"Gelieve te storten op rekening : ",oF12)
nDruk += nDrukafstand+0.5
oPrn:cmsay (nDruk,2,"Hopend op een spoedige regeling, verblijven wij,",oF12)
nDruk += 2
oPrn:cmsay (nDruk+0,2,"Met de meeste hoogachting,",oF12)
oPrn:cmsay (nDruk+0.5,2,"De Boekhouding",oF12)
endcase
nDruk += 2
oPrn:cmsay (nDruk,2,"Vragen over deze a" ,oF10)
oPrn:endpage()
//oPrn:Preview()
ENDPRINT
oF12:end();oF12B:end();oF12I:end();oF12U:end();oFlarge:end();oPrn:end()
return
Marc Venken
Using: FWH 20.08 with Harbour
Using: FWH 20.08 with Harbour
- Silvio.Falconi
- Posts: 4956
- Joined: Thu Oct 18, 2012 7:17 pm
Re: creation of a pdf
Marc Venken wrote:You open a XML file...
Maybe this function can help you...
Code: Select all
function Xmlreader() local aMail:={} local hFile := FOpen( "c:\users\marc\downloads\archive.xml" ) Local oXmlDoc := TXmlDocument():New( hFile ) Local oXmlIter := TXmlIterator():New( oXmlDoc:oRoot ), oTagActual while .T. oTagActual = oXmlIter:Next() If oTagActual != nil if oTagActual:cName = "Email" aadd(aMail,oTagActual:cData) endif if oTagActual:cName = "NewsletterID" aadd(aMail,oTagActual:cData) endif if oTagActual:cName = "Subject" aadd(aMail,oTagActual:cData) endif // MsgInfo( oTagActual:cName, oTagActual:cData ) // HEval( oTagActual:aAttributes, { | cKey, cValue | MsgInfo( cKey, cValue ) } ) Else Exit Endif End xbrowse(aMail) FClose( hFile ) return nil
thanks
I tried with
if oTagActual:cName = "Attachment"
aadd(aMail,oTagActual:cData)
endif
oTagActual: cName "Attachment" finds it but then doesn't save anything on cData
the same error make me
probably does not recognize the string which is then the content of the pdf file
however if I go to xbrowse and create the excel file he inserts the text of the pd
So, on Cdata there is something
Now How Create a Pdf with the content of cData?
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Re: creation of a pdf
Try this:
EMG
Code: Select all
FUNCTION MAIN()
ESTRAI( "your xml here" )
RETURN NIL
STATIC FUNCTION ESTRAI( cXml )
LOCAL cTxt := MEMOREAD( cXml )
LOCAL nSta, nLen, cPdf
cTxt = STRTRAN( cTxt, CHR( 4 ) + CHR( 130 ) + CHR( 4 ) + CHR( 0 ), "" )
cTxt = STRTRAN( cTxt, CHR( 4 ) + CHR( 81 ), "" )
nSta = AT( "<NomeAttachment>", cTxt ) + 16
nLen = AT( "</NomeAttachment>", cTxt, nSta ) - nSta
cPdf = SUBSTR( cTxt, nSta, nLen )
nSta = AT( "<Attachment>", cTxt ) + 12
nLen = AT( "</Attachment>", cTxt, nSta ) - nSta
cTxt = SUBSTR( cTxt, nSta, nLen )
cTxt = HB_BASE64DECODE( cTxt )
MEMOWRIT( cPdf, cTxt, .F. )
RETURN NIL
- Silvio.Falconi
- Posts: 4956
- Joined: Thu Oct 18, 2012 7:17 pm
Re: creation of a pdf
Harbour 3.2.0dev (r1712141320)Enrico Maria Giordano wrote:Try this:
EMGCode: Select all
FUNCTION MAIN() ESTRAI( "your xml here" ) RETURN NIL STATIC FUNCTION ESTRAI( cXml ) LOCAL cTxt := MEMOREAD( cXml ) LOCAL nSta, nLen, cPdf cTxt = STRTRAN( cTxt, CHR( 4 ) + CHR( 130 ) + CHR( 4 ) + CHR( 0 ), "" ) cTxt = STRTRAN( cTxt, CHR( 4 ) + CHR( 81 ), "" ) nSta = AT( "<NomeAttachment>", cTxt ) + 16 nLen = AT( "</NomeAttachment>", cTxt, nSta ) - nSta cPdf = SUBSTR( cTxt, nSta, nLen ) nSta = AT( "<Attachment>", cTxt ) + 12 nLen = AT( "</Attachment>", cTxt, nSta ) - nSta cTxt = SUBSTR( cTxt, nSta, nLen ) cTxt = HB_BASE64DECODE( cTxt ) MEMOWRIT( cPdf, cTxt, .F. ) RETURN NIL
Copyright (c) 1999-2016, http://harbour-project.org/
Compiling 'test.prg'...
test.prg(293) Error E0021 Incorrect number of arguments in AT
Passed: 3, expected: 2
test.prg(296) Error E0021 Incorrect number of arguments in AT
Passed: 3, expected: 2
2 errors
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
- Silvio.Falconi
- Posts: 4956
- Joined: Thu Oct 18, 2012 7:17 pm
Re: creation of a pdf
I tried to save only the cData
if oTagActual:cName = "NomeAttachment"
cNamePdf:= oTagActual:cData
endif
if oTagActual:cName = "Attachment"
cPdf := oTagActual:cData
endif
cTxt = HB_BASE64DECODE( cPdf )
MEMOWRIT( cNamePdf, cTxt, .F. )
seem to run ok
if oTagActual:cName = "NomeAttachment"
cNamePdf:= oTagActual:cData
endif
if oTagActual:cName = "Attachment"
cPdf := oTagActual:cData
endif
cTxt = HB_BASE64DECODE( cPdf )
MEMOWRIT( cNamePdf, cTxt, .F. )
seem to run ok
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: creation of a pdf
Use HB_AT() instead of AT() or link xhb.lib.Harbour 3.2.0dev (r1712141320)
Copyright (c) 1999-2016, http://harbour-project.org/
Compiling 'test.prg'...
test.prg(293) Error E0021 Incorrect number of arguments in AT
Passed: 3, expected: 2
test.prg(296) Error E0021 Incorrect number of arguments in AT
Passed: 3, expected: 2
2 errors
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- Silvio.Falconi
- Posts: 4956
- Joined: Thu Oct 18, 2012 7:17 pm
Re: creation of a pdf
Emg now run with Hb_atEnrico Maria Giordano wrote:Try this:
EMGCode: Select all
FUNCTION MAIN() ESTRAI( "your xml here" ) RETURN NIL STATIC FUNCTION ESTRAI( cXml ) LOCAL cTxt := MEMOREAD( cXml ) LOCAL nSta, nLen, cPdf cTxt = STRTRAN( cTxt, CHR( 4 ) + CHR( 130 ) + CHR( 4 ) + CHR( 0 ), "" ) cTxt = STRTRAN( cTxt, CHR( 4 ) + CHR( 81 ), "" ) nSta = AT( "<NomeAttachment>", cTxt ) + 16 nLen = AT( "</NomeAttachment>", cTxt, nSta ) - nSta cPdf = SUBSTR( cTxt, nSta, nLen ) nSta = AT( "<Attachment>", cTxt ) + 12 nLen = AT( "</Attachment>", cTxt, nSta ) - nSta cTxt = SUBSTR( cTxt, nSta, nLen ) cTxt = HB_BASE64DECODE( cTxt ) MEMOWRIT( cPdf, cTxt, .F. ) RETURN NIL
on this tag I found a xsl style format How I can save it ?
I tried with HB_BASE64DECODE but not run ok
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: creation of a pdf
Mr. EMG
Please pardon my ignorance.
I am curious to know why you are using HB_BASE64DECODE in this code.
Can you please enlighten on this?
Thanks in advance.
Please pardon my ignorance.
I am curious to know why you are using HB_BASE64DECODE in this code.
Code: Select all
cTxt = SUBSTR( cTxt, nSta, nLen )
cTxt = HB_BASE64DECODE( cTxt )
MEMOWRIT( cPdf, cTxt, .F. )
Thanks in advance.
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Re: creation of a pdf
Because the PDF is encoded Base64 inside the file XML:
<Attachment>...base64code...</Attachment>
EMG
<Attachment>...base64code...</Attachment>
EMG
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: creation of a pdf
ThanksEnrico Maria Giordano wrote:Because the PDF is encoded Base64 inside the file XML:
<Attachment>...base64code...</Attachment>
EMG
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- Silvio.Falconi
- Posts: 4956
- Joined: Thu Oct 18, 2012 7:17 pm
Re: creation of a pdf
Emg,Enrico Maria Giordano wrote:Because the PDF is encoded Base64 inside the file XML:
<Attachment>...base64code...</Attachment>
EMG
Now here at School we have an electronic invoice with the style sheet incorporated,
so if I use base64code and converte it not run ok
any solution please ?
how many formats and which types can be incorporated in the electronic invoice here in Italy ?
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC