>>CPSFILEPATH=Alltrim(cFullpath) && Original file will be picked from Here >>NEWPATH=Alltrim(NEWPATH) && New rewritten file will be Placed Here >> >>Create Cursor BILLCOMPRESS (POS C(254)) && Create Temporary Cursor Billcompress to Check Page Numbers >>Select BILLCOMPRESS >>Append From (m.CPSFILEPATH) Sdf && Appends in Standard Data Format >>*Count Number of Pages in PS File >>Locate For Alltrim(POS)='%%Page: 1 1' >>IF Found() >>Skip >>IF ALLTRIM(LEFT(POS,9))="<</Duplex" >>Replace POS With '<</Duplex false/PageSize [595 842] /Tumble false /ManualFeed false /MediaPosition 0>> setpagedevice'+ CHR(10) >>ENDIF >>ENDIF >> >>Set Textmerge On >>Set Textmerge To (m.NEWPATH) Noshow >>Scan >>\\<< TRIM(POS) >> >>\ >>Endscan >>Set Textmerge To >>Set Textmerge Off >>>
>Scan >\\<< TRIM(POS) >> >\ && THIS line adds CRLF into the file >Endscan >>
>CPSFILEPATH=Alltrim(cFullpath) && Original file will be picked from Here >NEWPATH=Alltrim(NEWPATH) && New rewritten file will be Placed Here > >Create Cursor BILLCOMPRESS (POS C(254)) && Create Temporary Cursor Billcompress to Check Page Numbers >Select BILLCOMPRESS >Append From (m.CPSFILEPATH) Sdf && Appends in Standard Data Format >*Count Number of Pages in PS File >Locate For Alltrim(POS)='%%Page: 1 1' >IF Found() > Skip > IF ALLTRIM(LEFT(POS,9))="<</Duplex" > Replace POS With '<</Duplex false/PageSize [595 842] /Tumble false /ManualFeed false /MediaPosition 0>> setpagedevice' > ENDIF >ENDIF > >STRTOFILE([], NEWPATH, .f.) >Scan > STRTOFILE(TRIM(POS)+CHR(10), NEWPATH, .t.) >Endscan >>
Scan CPSFILEPATH=Alltrim(Fullpath) NEWPATH=Alltrim(NEWPATH) Billcompress=FILETOSTR(m.CPSFILEPATH) Billcompress=STRTRAN(m.Billcompress,'<</Duplex true /Tumble false /ManualFeed false /MediaPosition 0>> setpagedevice',; '<</Duplex false/PageSize [595 842] /Tumble false /ManualFeed false /MediaPosition 0>> setpagedevice',1) STRTOFILE(m.Billcompress,m.NEWPATH,.F.) Select NEW_BILLS Wait Window "Inserting["+Alltrim(Str(Recno()))+" of "+Alltrim(Str(m.RECORDSFORSELECTA))+"]" Nowait ENDSCAN