Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Anyone interested in a FAQ on creating a 'quick pdf' from a text file 4

Status
Not open for further replies.

GriffMG

Programmer
Mar 4, 2002
6,288
1
38
FR
I needed to create a simple PDF from a text file for a customer yesterday and ported some VB code from somewhere else.

It's just a single function with an infile and an out file - and not very pretty code (sorry).



Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.
 
You can print to a PDF printer like primoPDF.

Cetin Basoz
MS Foxpro MVP, MCP
 
Hi Cetin

I know you can print to a pdf printer - I use PrimoPDF a lot, it's very good. This is just a bit of native VFP code which reads a text file (.txt) and outputs a pdf version.

I was wondering if anyone else would have a use for it!


Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.
 
Ok I'll try to make sense of it!

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.
 
Ah sorry, I failed to read the title. Yes sure I would be interested as well:)


Cetin Basoz
MS Foxpro MVP, MCP
 
I have created a FAQ here

faq184-7355


Not the prettiest bit of code...

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.
 
Martin,
I have downloaded it and after stripping out the html and then correcting the bugs I could get a working code. Bugs:
You have:

On error do usual ....

but no "usual" function. I simply removed that line. In the same function you use m.CRLF but that doesn't exist. After correction PDFWrite now looks like:
Code:
FUNCTION PDFWRITE
    PARAMETERS m.OUTFILENAME
    PRIVATE I, m.OUTFILENAME,m.STRING,m.TEMPBIT
*removed
    *ON ERROR DO USUAL WITH LINENO(),PROGRAM()
*added
    CRLF = CHR(13)+CHR(10)

    m.STRING = ""
    FOR I = 1 TO ALEN(ARRDATA)
        m.TEMPBIT = ARRDATA(I)
        IF TYPE("m.tempbit") = "C" .AND. !EMPTY(m.TEMPBIT)
            m.STRING = m.STRING + m.TEMPBIT+m.CRLF
        ENDIF
    NEXT
    STRTOFILE(m.STRING,m.OUTFILENAME)
    RETURN(.T.)

I don't know if it is due or not but the conversion only works for the 1st page. Other pages are lost. Maybe it was designed for 1 page length text?

Cetin Basoz
MS Foxpro MVP, MCP
 
Thanks Cetin

Usual() is an error handler and you're right m.crlf is a public !

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.
 
Sorry, it assumes pages are delineated by the std chr(12).

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.
 
All updated.

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.
 
Thanks Dave!

(can't remember when I last got a star!)

I have some more work to do on it - the xref table at the end is very much an estimate, errors in which Acrobat Reader can easily cope with, but other readers may be a bit fussier...

Still it's useful

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.
 
Thank you too

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.
 
And... another.

boyd.gif

SweetPotato Software Website
My Blog
 
Thank you as well.



Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.
 
I have finally worked out how to calculate the lengths of the streams and the proper values to go in the xref block, which were not critical - as most readers ignore them.

However PDFXchange viewer flagged them as corrupt, so I have spent the time required to fix them and updated the FAQ.

Thank you for your encouragement.



Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top