Today I needed to create a very big test dataset with associated PDFs.
Rather than messing with PDF printers, which are slow even when they
work, I hacked this up to create a very simple PDF file completely
programmatically - just pass it the required filename and the text you
want in it.

Note that if you open in Acrobat Reader it will convert it to the
current format and prompt to save when you close it, but it's still a
valid PDF even if you don't.


* -- This makes a very simple PDF file programmatically without faffing
with PDF printers.
* -- See
http://www.jpedal.org/PDFblog/2010/10/make-your-own-pdf-file-part-4-hello-world-pdf/
Lparameters lcOutFile, lcText
Local llOk

        llOk = .t.
        
        Try 
                lnFontSize = 12
                lnLeft = 0
                lnTop = 720

                Set Textmerge on noshow
                Set Textmerge Delimiters To "#|","|#"
                Set Textmerge to (lcOutfile)

                \\%PDF-1.4
                \1 0 obj <</Type /Catalog /Pages 2 0 R>>
                \endobj
                \2 0 obj <</Type /Pages /Kids [3 0 R] /Count 1>>
                \endobj
                \3 0 obj<</Type /Page /Parent 2 0 R /Resources 4 0 R
                /MediaBox [0 0 500 800] /Contents 6 0 R>>
                \endobj
                \4 0 obj<</Font <</F1 5 0 R>>>>
                \endobj
                \5 0 obj<</Type /Font /Subtype /Type1 /BaseFont
                /Helvetica>>
                \endobj
                \6 0 obj
                \<</Length 44>>
                \stream
                \BT /F1 #|lnFontSize|# Tf #|lnLeft|# #|lnTop|# Td
                (#|lcText|#)Tj ET
                \endstream
                \endobj
                \xref
                \0 7
                \0000000000 65535 f
                \0000000009 00000 n
                \0000000056 00000 n
                \0000000111 00000 n
                \0000000212 00000 n
                \0000000250 00000 n
                \0000000317 00000 n
                \trailer <</Size 7/Root 1 0 R>>
                \startxref
                \406
                \%%EOF


                Set Textmerge off
                Set textmerge to
        
        Catch 
                llOk = .f.
        Finally
                Set Textmerge delimiters to
        EndTry
                
                
Return llOk




-- 
  Alan Bourke
  alanpbourke (at) fastmail (dot) fm


_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/1340721459.9395.140661094238649.274da...@webmail.messagingengine.com
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to