Le 7 août 09 à 00:40, Richmond Mathewson a écrit :

Peter Alcibiades wrote:
Richmond, don't you want cups-pdf if its Ubuntu? Its real simple. Just gives you a virtual printer which is a file. Or is there something else?

Peter

Richmond Mathewson-2 wrote:

Print to PDF?

I think I am reinventing the wheel . . .

advice welcomed.
_______________________________________________


I know how to produce pdf files from a 'regular' Mac or Linux
program . . . come on, Peter, give me a wee bit of credit . . .    :)

But I should like to have a universal method whereby I can print
directly from a text field in a RunRev stack/standalone to PDF
regardless of the platform the stack is running on.

For instance:

put field "X" into URL "file:test.pdf"

[which, bye-the-bye, produces a text file with the suffix .pdf]

which ACTUALLY produces a PDF file.

or:

open file "test.pdf" for write
write field "X" to file "test.pdf"

[which, bye-the-bye, also produces a text file with the suffix .pdf]

as one can EXPORT images as PNG, JPEG, GIF and so on, it would be
lovely if one could do something of the sort with text files:

write field "X" to file "test.pdf" as PDF

---------------------------------
Imagine a RunRev stack that can cope with the complexities of
producing really decent texts using highly complex writing systems
such as those used in the Indian subcontinent; now, with unicode
and so on, that is perfectly reasonable, and that sort of program
can pump out html files with the end result.

BUT . . .

suppose, owing to the complexity of that sort of writing system, coupled
with the fact that the unicode standard has not got designated slots
for all the written forms, the producer of the RunRev stack has had to produce
his/her own, non-standard unicode font to cope with those problems.

The end result should produce PDF files (that embed the special font) as there is a very slim chance that an end-user/reader of such texts would have
that specialist font on their system.

Hi Richmond
The solution I am currently implementing is an export of the htmlText of a field to a LaTeX (text) file and then using the shell command "pdflatex" && tFilePath to ouput pdf. It does not do the actual printing. There is also XeTeX which is a variant of TeX which implements support for unicode input and AAT or OT fonts. It has been recently ported to Windows and Linux. Use of a LaTeX package enables creates hyperlinks and bookmarks int the pdf output. GUI applications are also available. All of this is freeware and actively maintained. Resources are
general: http://www.tug.org/texlive/acquire.html
mac: http://www.tug.org/mactex/

here is a sample (temporary) code I use for experimentation. It collects several fields of a card (from a dictionary stack) to produce corresponding LaTeX code

-- TeX handlers and functions
function html2TeX theText
   replace "<p>" with empty in theText
   replace "</p>" with cr & cr in theText
   replace "<b>" with "{\bf " in theText
   replace "</b>" with "}" in theText
   replace "<i>" with "{\em " in theText
   replace "</i>" with "}" in theText
   -- special characters
   replace "&quot;" with quote in theText
   replace "&#9;" with comma in theText
   replace "&amp;" with backslash & "&" in theText
-- here I get rid of unsupported tags
   replace "<" with tab & "<" in theText
   replace ">" with ">" & tab in theText
    set the itemdelimiter to tab
   put the number of items of theText into n
   repeat with i = n down  to 1
      get item i of theText
      if char 1 of it is "<" then
         delete item i of theText
      end if
   end repeat
   replace tab with empty in theText
   -- deal now with < and >
   replace "&lt;" with "$<$" in theText
   replace "&gt;" with "$>$" in theText
   --   clean up cr's
   put the number of lines of theText into n
   repeat with i = n down  to 2
      get line i of theText
      if it is empty and line (i-1) of theText is empty then
         delete line i of theText
      end if
   end repeat
   return theText
end html2TeX

-- collect fields. Entries are from the rev's dictionary

function card2TeX theCard
   goCard theCard
   put 1 into n
   put backslash & "section{" & fld "name" & "}" into line n of theText
put backslash & "label{" & the short name of this card & "}" after line n of theText
   add 1 to n
   put backslash & "paragraph{Type}" into line n of theText
   add 1 to n
   put fld "type" into line n of theText
   add 1 to n
   put backslash & "paragraph{History}" into line n of theText
   add 1 to n
put "Introduced in version" && fld "introduced" into line n of theText
   get fld "changed"
   if it is not empty then
      put comma && "changed in version" && it after line n of theText
   end if
   get fld "removed"
   if it is not empty then
      put comma && "removed in version" && it after line n of theText
   end if
   put "." after line n of theText
   add 1 to n
   put backslash & "paragraph{Platforms}" into line n of theText
   add 1 to n
   put empty into line n of theText
   get fld "macos"
   if it is true then
      put "Mac classic, " after line n of theText
   end if
   get fld "osx"
   if it is true then
      put "Mac OS X, " after line n of theText
   end if
   get fld "win32"
   if it is true then
      put "Windows, " after line n of theText
   end if
   get fld "unix"
   if it is true then
      put "Linux, " after line n of theText
   end if
   delete last char of line n of theText
   delete last char of line n of theText
   put "." after line n of theText
   put addTeXpar(theText,"Summary","summary") into theText
   put addTeXpar(theText,"Syntax","syntax") into theText
   put addTeXpar(theText,"Description","description") into theText
   put addTeXpar(theText,"Example","example") into theText
   put addTeXpar(theText,"Synonyms","synonyms") into theText
      put addTeXpar(theText,"Related","related") into theText
   put addTeXpar(theText,"Synonyms","synonyms") into theText
put addTeXpar(theText,"Categories","categories") into theText -- useless?
   return theText
end card2TeX

-- handle sectioning
function addTeXpar theText,theTitle,theField
   put the number of lines of theText into n
   add 1 to n
   put backslash & "subsection{" & theTitle &"}" into line n of theText
   add 1 to n
   get the htmlText of fld theField
   if theField is in "syntax,example,related" then
      get "{\tt " & it & "}"
   end if
    replace comma with comma & space in it
   put html2TeX(it) into line n of theText
   return theText
end addTeXpar

cheers
        François

_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to