home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 4 / CDPD_IV.bin / fish / 911-930 / ff925 / donsgenies / frenchgenies.lha / Rexx / ImprimePageAvecPost.pprx < prev    next >
Text File  |  1993-08-03  |  6KB  |  137 lines

  1. /*
  2. @BImprimePageAvecPost @P @I Ecrit et © par Don Cox             
  3. @IN'est pas du Domaine Publique. Tous Droits Réservés.
  4. Traduit et amélioré par Fabien Larini le 31/07/93.
  5.     
  6. Ce Génies permet d'imprimer la page courante à l'aide de l'interpréteur
  7. Postscript Post. Vous devez avoir installé Post correctement. Vous devez
  8. également configurer les préférences graphiques de votre imprimante 
  9. (surtout la taille de la page et la densité). L'avantage est que vous 
  10. pouvez imprimer les fichiers EPS et utiliser les fonts Adobe Type 1 plutôt
  11. que leurs conversions en CG. Il demande et sauve le répertoire où il doit
  12. stocker les fichiers temporaires et où se trouve Post.    
  13. */
  14.  
  15. /*PrintPageUsingPost*/
  16. /* This genie uses the public domain Postscript interpreter "Post" to print
  17. the current page. The advantages are that you can print .eps files on a 
  18. non-Postscript printer and that you can use real Type 1 fonts, rather than 
  19. converted versions.  The files "post" and "init.ps" should be in a drawer 
  20. called "post" in your "PPage:" drawer (if not, modify the indicated line in 
  21. the genie), the necessary .psfont files in CGFonts:ps, and "post.library" in
  22. libs:  You do NOT need "Conman". 
  23. Make sure the assigns for PPage: and CGFonts: are set up in your startup-sequence or user-startup files. 
  24. It is also essential to set the Limits in your printer graphics preferences to the correct page size in pixels i.e. the printer's dots-per-inch * page size in inches. Typical figures are 1500 by 2100. */
  25. /* Note: There is a bug in Post which means that it will refuse to print colour bitmaps on colour printers under WB 2.04. It seems to be OK under WB 1.3. 
  26. Also, gradient fills do not work in colour. Colour separations and B&W are OK. 
  27. Versions of Post older than 1.7 have problems with files from Quark XPress and Freehand.
  28. There is also a bug in ProDraw which results in its printing incorrectly when page sizes are set in pixels.
  29. */
  30. /* Written by Don Cox. Copyright. Not Public Domain. All rights reserved. */
  31.                                                                   
  32. trace n
  33. signal on error
  34. signal on syntax
  35. address command
  36. call SafeEndEdit.rexx()
  37. call ppm_AutoUpdate(0)
  38. cr="0a"x
  39.  
  40. /* Demande des données a sauver dans le fichier de configuration */
  41. fichiercfg="rexx:ImprimePageAvecPost.cfg"
  42.     
  43. idem = 0                                                     
  44. post = ""
  45. tempdir = ""
  46.    
  47. /* Demande si nouvelle config */
  48. if exists(fichiercfg) then do
  49.     idem = ppm_Inform(2,"Utilisation de la configuration sauvée ?","Non","Oui")
  50.     end
  51.  
  52. if (~exists(fichiercfg) | idem=0) then do
  53.     /* Quel est le répertoire temporaire */
  54.     tempdir = ppm_GetFileName("Choix du Répertoire Temporaire","","")
  55.     if tempdir = "" then exit_msg("Opération Annulée")
  56.     /* Récupération du répertoire */
  57.     pos = max(lastpos("/",tempdir),lastpos(":",tempdir))
  58.     tempdir = delstr(tempdir,pos+1)
  59.  
  60.     /* Où est Post ? */
  61.     post =  ppm_GetFileName("Choix du répertoire de Post", "", "post")
  62.     if post = "" then exit_msg("Opération Annulée")
  63.     /* Récupération du répertoire */
  64.     pos = max(lastpos("/",post),lastpos(":",post))
  65.     post = delstr(post,pos+1)
  66.     /* Test de la présence de Post dans le répertoire choisi */
  67.     if ~exists(post"post") then exit_msg("Post ne se trouve pas dans le répertoire choisi")    
  68.     
  69.     if ppm_Inform(2,"Sauvegarder dans le fichier de configuration ?", "Non", "Oui") = 1 then do
  70.         if open(cfg,fichiercfg,"W") then do
  71.             call writeln(cfg,tempdir)
  72.             call writeln(cfg,post)
  73.             call close(cfg)
  74.         end
  75.         else
  76.             exit_msg("Impossible de sauvegarder dans le fichier de configuration")
  77.         end
  78.     end
  79. else if idem = 1 then do
  80.             if open(cfg,fichiercfg,"R") then do
  81.                 tempdir = readln(cfg)
  82.                 post = readln(cfg)
  83.                 call close(cfg)
  84.                 end
  85.              else
  86.                 exit_msg("Impossible de lire le fichier de configuration")
  87.       end
  88.    
  89. thispage = ppm_CurrentPage()
  90. oldoutput = ppm_GetPSOutput()
  91. call ppm_SetPSFontDownload(0)
  92. call ppm_SetPSOutput(tempdir"IPAP.ps")
  93. success = ppm_PrintPagePS(thispage,1,1)
  94. if success ~=1 then exit_msg("Sauvegarde temporaire du fichier Postscript impossible")
  95.  
  96. ipaptemp = tempdir||"IPAP"
  97.  
  98. /* Y a-t-il des espaces dans ipaptempps */
  99. ipaptempps = tempdir||"IPAP.ps"
  100. if lastpos(" ",ipaptempps) ~=0 then ipaptempps = '22'x||ipaptempps||'22'x
  101.  
  102. /* Set up a text file in temp directory and then send it to a temporary command window */
  103. conwindow = "CON:40/40/500/200/NewWindow"
  104. call open out, ipaptemp, write  /* This wipes out any existing ram:temp  */
  105. call writeln out, "cd "post /* post is in drawer "Post" in "PPage:" - if not, change this line  */
  106. call writeln out, "post init.ps "ipaptempps /* To use lots of fonts in one document, add memory to Post here. See Post documentation. */
  107. call writeln out, "delete "ipaptempps
  108. call writeln out, "endcli"  /* if you have problems, comment this line out so the CLI stays on screen with Post error mesages */
  109. call close out
  110.                                   
  111. /* Y a-til des esapces dans ipaptemp */
  112. if lastpos(" ",ipaptemp) ~=0 then ipaptemp = '22'x||ipaptemp||'22'x  
  113. "newcli" conwindow ipaptemp /* open a CLI and use temp/temp as a set of commands */
  114.  
  115. call ppm_SetPSOutput(oldoutput)
  116. call exit_msg()
  117.  
  118. end
  119.  
  120. error:
  121. syntax:
  122.     do
  123.     exit_msg("Arrêt du Génie dû à l'erreur: "errortext(rc)) 
  124.     end
  125.  
  126. exit_msg:
  127.     do
  128.     parse arg message
  129.     if message ~= "" then
  130.     call ppm_Inform(1,message,)
  131.     call ppm_ClearStatus()
  132.     call ppm_PPageToFront()
  133.     call ppm_AutoUpdate(1)
  134.     exit
  135.     end
  136.  
  137.