Announcement

Collapse
No announcement yet.

How about some creating pdfs with ghostscript, then viewing them and printing it also

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How about some creating pdfs with ghostscript, then viewing them and printing it also

    I need a way to create and save PDF files.
    One need was is when we get a text files as reports from a daily used website where we some credit card and debit cards are processed.
    Yep, you got to log in and go to a very unuser friendly web site for that and for your efforts, they give you a text file or text as a report in a web browser window to print.
    I do not want have to keep this manually and i prefer a pdf file to save if i can get it.
    So this is working for that need and for other useful needs.
    What i am using is basically RedMon-Redirection Port Monitor version 1.9, and ghostscript version 9.22 to create the pdf file i want to keep.
    I use the postscript virtual printer driver that can be found in the LIB directory of ghostscript.
    All our computers are 32 bit windows operating system because our vendor still creates 16-bit executables but this is working on windows XP Pro, 7 Pro, and 10 Pro.

    So lets get to it.
    I installed ghostscript 9.22 then copied the files from the directory "c:\program files\gs\gs9.22" to a directory named "c:\gspdf" then removed ghostscript.
    You will be needing some ghostcript font files found at sourceforge.net. I had to down load file from there and had to use the program 7-zip to extract the files, because they were not in a zip file.
    I will list the font files that are on my computers so you can have a reference to file dates, sizes and etc.

    In a batch file that will be listed later, you can find web locations for all this.

    I am not using in production prfile32.exe that prints a postcript file to a windows printer but you will see me using that here.
    prfile32.exe comes from http://lerup.com by Peter Lerup in the Printfile program for 32 bit operating systems.
    I really prefer a command line tool to print postscript(.ps) files. But i have another possible trick up my sleeve I am not using or tried yet.

    I am using the pdf viewer Foxit Reader for my default PDF viewer.

    There are many websites that tell you how to set up RedMon and Ghostscript PDF virtual printer but I going to give what I did, but not as through.
    If you never setup Redmon, just download it and run the setup.exe from any location but a good place might be under a directory called "C:\UTILITY\RedMon".
    Of course you need to be an administrator to set this up silly.
    Next, use add a printer, in windows 10, you have to go to something like add printer not found or something like that, but get into it.
    The first thing your going to do is add local printer and create a new port, then you select "Redirected Port" and it will be likely "RPT1:" for the first port added from the RedMon utility.
    If you set up another port later for another virtual printer, it will be "RPT2:"
    For the printer driver, select you have a disk and point it to the LIB directory in where your ghostscript files are located.
    Just for the heck, the first time I added a postscript printer drive, I used HP Colorlaser 4550 PS" that comes with windows.
    I did not know about the postscript printer driver that came with ghostscript 9.22.
    And if you really want to get crazy, I even used the CutePDF Writer driver to do some testing because CutePdf was already loaded.
    Don't worry yourself, I did some test and they speed is the same because i think CutePDF makes use of ghostscript.
    I named my printer "StoreAsPdf". It will not matter. Make the printer name where it will fall under your default printer name so you can see it more, because your going to like this.
    Now that the printer is installed but not ready yet, there some changes you might want to make.
    Go into printer properties for the virtual printer you created.
    In Advanced section, many people said to set the printer to use "Print directly to the printer". This will make it print slow and some of my computers even choked on it.
    I have my setting to use the print spooler and print after the last page, but you do as you want and if there is a problem let me know ASAP.
    Next go into the Device Setting. Set the "Job Timeout" to "1" second and set the "Send CTRL-D After Each Job" to "NO".
    Do not ask me why to set those setting from the line above, I am just following the crowd here.
    But during much testing, also there is a listing in the Device Setting about Font Substitution Table. And I changed Courier and Times fonts to "Don't Substitute".
    Those 2 are going to be 2 of 3 that where the default is to substitute the font. I did not change Arial at this time where it is substituted with "Helvetica".
    For Security, I always give users or everyone rights to control the printer. I found that if not, it is hard to clear print jobs from the spooler. That has been my history.

    Ok now we are really getting to best part.
    Making changes to Port Settings and then Configure Port.
    Set Run to "Hidden"
    Place a check mark in the check box in "Run As User"
    Uncheck the Print Errors box
    Do not mess with with log file at this time, disable that.
    Shut down delay is 300 by default and ok for me, how about you? I really don't know what that means.
    Output needs to be "Program handles output" for how I am doing things.
    Redirect this port to the program is going to be the location of the batch file you are going to create and use to make all this happen.
    You have to decide where you want the batch file at while testing it is good to have it some where that you can easily edit the batch file to make this your joy of what happens.
    Maybe a good place will be in the directory like mine where i put the ghostscript program at "c:\gspdf" and when you are all done sometime from now, maybe the "c:\windows" directory might be the best place for it so that a user cannot mess with it.
    ok i am going to make another post to the forums for the file setup i have.

    Ok you are wondering about a few things, for each way you want things to happen in a different way, you have to go though add printer again. So all the settings for this printer in properties is not going to affect other printers, not even in the Device Settings where you changed the font substitution to don't substitute. But one thing at a time. Lets get this working first.
    p purvis

  • #2
    Ok, did you get the fonts yet, get them at sourceforge and extract them anyway you can.
    Create a directory where you have LIB and BIN directory of ghostscript. Name it "Fonts".
    Put the fonts into that directory.
    Here is my tree for "c:\gspdf"
    Code:
    cd C:\GSPDF
    +---bin
    +---fonts
    +---fontsold
    +---lib
    +---redmon
    +---zlib
        +---doc
    opps i got redmon in the too, ok put the redmon files in there, they do not take up much room.
    fontsold is a old set of fonts that i found, you will not need that directory or what is in it either, but definitely put your fonts
    you downloaded in the "fonts" directory.

    here is a listing of the fonts directory that i have
    Code:
     Directory of C:\gspdf\fonts
    
    03/01/2018  12:28 PM    <DIR>          .
    03/01/2018  12:28 PM    <DIR>          ..
    12/27/2002  05:33 AM            42,833 a010013l.afm
    12/27/2002  05:33 AM            69,958 a010013l.pfb
    12/27/2002  05:33 AM             2,951 a010013l.pfm
    12/27/2002  05:39 AM            42,749 a010015l.afm
    12/27/2002  05:39 AM            72,436 a010015l.pfb
    12/27/2002  05:39 AM             2,939 a010015l.pfm
    12/27/2002  05:47 AM            42,708 a010033l.afm
    12/27/2002  05:47 AM            71,712 a010033l.pfb
    12/27/2002  05:47 AM             2,931 a010033l.pfm
    12/27/2002  05:51 AM            42,967 a010035l.afm
    12/27/2002  05:51 AM            75,330 a010035l.pfb
    12/27/2002  05:51 AM             2,963 a010035l.pfm
    12/26/2002  05:44 AM            42,970 b018012l.afm
    12/26/2002  05:44 AM           110,877 b018012l.pfb
    12/26/2002  05:44 AM             2,957 b018012l.pfm
    12/26/2002  05:48 AM            42,632 b018015l.afm
    12/26/2002  05:48 AM            99,292 b018015l.pfb
    12/26/2002  05:48 AM             2,953 b018015l.pfm
    12/26/2002  06:01 AM            43,396 b018032l.afm
    12/26/2002  06:01 AM           118,551 b018032l.pfb
    12/26/2002  06:01 AM             2,985 b018032l.pfm
    12/26/2002  05:57 AM            43,083 b018035l.afm
    12/26/2002  05:57 AM           107,917 b018035l.pfb
    12/26/2002  05:57 AM             2,985 b018035l.pfm
    11/22/2002  05:28 PM            43,033 c059013l.afm
    11/29/2002  03:40 AM           116,384 c059013l.pfb
    11/22/2002  05:28 PM            42,851 c059016l.afm
    11/29/2002  03:40 AM           118,436 c059016l.pfb
    11/22/2002  05:24 PM            43,205 c059033l.afm
    11/29/2002  03:41 AM           117,393 c059033l.pfb
    11/22/2002  05:25 PM            43,017 c059036l.afm
    11/29/2002  03:42 AM           114,846 c059036l.pfb
    11/29/2002  03:34 AM             4,404 ChangeLog
    04/24/2001  07:18 AM            17,992 COPYING
    12/29/1999  10:24 AM             9,381 d050000l.afm
    12/29/1999  10:24 AM            45,955 d050000l.pfb
    01/15/2002  02:22 AM            27,164 fonts.dir
    01/05/2002  03:50 AM            27,164 fonts.scale
    12/31/2002  11:21 PM            42,882 n019003l.afm
    12/31/2002  11:21 PM            68,590 n019003l.pfb
    12/31/2002  11:21 PM             2,920 n019003l.pfm
    12/31/2002  11:21 PM            42,593 n019004l.afm
    12/31/2002  11:21 PM            72,400 n019004l.pfb
    12/31/2002  11:21 PM             2,920 n019004l.pfm
    12/31/2002  11:21 PM            43,493 n019023l.afm
    12/31/2002  11:21 PM            71,719 n019023l.pfb
    12/31/2002  11:21 PM             2,992 n019023l.pfm
    12/31/2002  11:22 PM            43,133 n019024l.afm
    12/31/2002  11:22 PM            73,879 n019024l.pfb
    12/31/2002  11:22 PM             2,980 n019024l.pfm
    11/22/2002  05:26 PM            42,680 n019043l.afm
    11/29/2002  03:44 AM            74,138 n019043l.pfb
    11/22/2002  05:26 PM            42,381 n019044l.afm
    11/29/2002  03:44 AM            75,310 n019044l.pfb
    11/22/2002  05:27 PM            42,911 n019063l.afm
    11/29/2002  03:45 AM            73,032 n019063l.pfb
    12/31/2002  11:20 PM            42,852 n019064l.afm
    12/31/2002  11:20 PM            77,734 n019064l.pfb
    12/31/2002  11:20 PM             2,952 n019064l.pfm
    12/31/2002  11:19 PM            43,346 n021003l.afm
    12/31/2002  11:19 PM           113,206 n021003l.pfb
    12/31/2002  11:19 PM             2,968 n021003l.pfm
    12/31/2002  11:19 PM            43,161 n021004l.afm
    12/31/2002  11:19 PM           108,822 n021004l.pfb
    12/31/2002  11:19 PM             2,968 n021004l.pfm
    12/31/2002  11:18 PM            43,339 n021023l.afm
    12/31/2002  11:18 PM           108,217 n021023l.pfb
    12/31/2002  11:18 PM             2,976 n021023l.pfm
    12/31/2002  11:18 PM            43,405 n021024l.afm
    12/31/2002  11:18 PM            96,211 n021024l.pfb
    12/31/2002  11:18 PM             2,988 n021024l.pfm
    12/26/2002  06:09 AM            26,723 n022003l.afm
    12/26/2002  06:09 AM            96,263 n022003l.pfb
    12/26/2002  06:10 AM            26,743 n022004l.afm
    12/26/2002  06:10 AM           120,373 n022004l.pfb
    12/26/2002  06:08 AM            26,904 n022023l.afm
    12/26/2002  06:08 AM           101,133 n022023l.pfb
    12/26/2002  06:10 AM            26,867 n022024l.afm
    12/26/2002  06:10 AM           114,228 n022024l.pfb
    11/22/2002  05:27 PM            43,497 p052003l.afm
    11/29/2002  03:48 AM           133,786 p052003l.pfb
    11/22/2002  05:27 PM            43,225 p052004l.afm
    11/29/2002  03:48 AM           133,139 p052004l.pfb
    11/22/2002  05:28 PM            43,482 p052023l.afm
    11/29/2002  03:48 AM           126,944 p052023l.pfb
    11/22/2002  05:23 PM            42,730 p052024l.afm
    11/29/2002  03:48 AM           131,673 p052024l.pfb
    07/18/2003  07:52 PM             2,393 README
    07/13/2002  02:13 AM             1,317 README.tweaks
    12/29/1999  10:24 AM             9,686 s050000l.afm
    12/29/1999  10:24 AM            33,709 s050000l.pfb
    02/04/2002  04:05 AM               183 TODO
    04/27/2007  05:03 AM             3,928 uninstal.txt
    12/26/2002  06:11 AM            38,911 z003034l.afm
    12/26/2002  06:11 AM           113,405 z003034l.pfb
    12/26/2002  06:11 AM             2,807 z003034l.pfm
                  96 File(s)      4,864,447 bytes
                   2 Dir(s)  13,673,086,976 bytes free
    create a text file in the top of the ghostscript directory called "pdfwrite.txt"
    there is a space at the begin of all lines except the top line and extra lines at the bottom do not seem to hurt either
    Code:
    -IC:\gspdf\lib;C:\gspdf\fonts
     -sDEVICE=pdfwrite
     -r600
     -dNOPAUSE
     -dSAFER
     -dQUIET
     -sPAPERSIZE=letter
     -dPDFFitPage
     -dCompatibilityLevel=1.4
     -sFONTPATH="c:\gspdf\fonts;c:\windows\fonts"
     -dPDFSETTINGS=/prepress
     -dAutoRotatePages=/PageByPage
    Because the resolution is set to 600 dpi in the virtual printer you just created.
    You should match that dpi here. You can experiment later.
    I like to AutoRotateMy files for now, you can remove that line
    I just found out about the ghostscript parameter -dPDFFitPage yesterday. I like it when selecting to print on a paper size differnet
    than Letter size like Legal, so far will just small testing, it looks good but you can remove that one too.

    Most my production is using this in the pdfwrite.txt file but testing looking to add the "-dPDFFitPage" line.
    Code:
    -IC:\gspdf\lib;C:\gspdf\fonts
     -sDEVICE=pdfwrite
     -r600
     -dNOPAUSE
     -dSAFER
     -dQUIET
     -sPAPERSIZE=letter
     -dCompatibilityLevel=1.4
     -sFONTPATH="c:\gspdf\fonts;c:\windows\fonts"
     -dPDFSETTINGS=/prepress
     -dAutoRotatePages=/PageByPage
    p purvis

    Comment


    • #3
      Now for the batch file you going to use.
      Now this I this one today in an effort to print the postcript file that this one creates and create a PDF file then copying the PDF file everywhere line a squirrel hiding his nuts for winter.

      i named my virutal printer StoreAsPdf so i have batch file name to match.

      gsstoreaspdf.bat
      Code:
      gsstoreaspdf.bat
      
      @echo off
      rem this routine will retrieve a postscript file using redmon utilities to create a redirection printer port
      rem this program assumes you have a program set that is the a default pdf viewer and printer but a viewer such as mupdf
      rem     is ok for just viewing and it is fast. this program does not use the mupdf program.
      
      rem this program uses:
      rem the postcript printer driver came from the lib directory of the ghostscript package from Artifex Software
      rem ghostscript version 9.22 from https://www.ghostscript.com/download/gsdnld.html
      rem ghoscript files where placed in c:\gspdf directory
      
      rem redfile.exe from RedMon http://pages.cs.wisc.edu/~ghost/redmon  University of Wisconsin-Madison
      rem redfile.exe is placed in the c:\utility\redmon directory
      
      rem prfile32.exe from http://lerup.com  by Peter Lerup
      rem prfile32.exe is placed in the c:\utiilty\printfile directory
      rem presonally i need a program to print the postscript file without all the special effects
      rem you can leave out the printing of the postscript file if you want to veiw the pdf file first then print
      rem     it out with the default pdf viewer.
      
      rem use environmental variables to keep the errors down in typing
      
      
      rem set the default directory of where to save the postscript file created and also where to save the pdf files
      SET STOREPDFDRIVE=%SYSTEMDRIVE%
      SET STOREPDFDIRECTORY=\storepdf
      
      rem create the directory if the directory does not exist then create it
      IF NOT EXIST "%STOREPDFDRIVE%%STOREPDFDIRECTORY%" md "%STOREPDFDRIVE%%STOREPDFDIRECTORY%"
      rem if the directory still does not exist read the stdin. This may not be needed
      IF NOT EXIST "%STOREPDFDRIVE%%STOREPDFDIRECTORY%" c:\utility\redmon\redfile NUL
      rem if the directory still does not exist abort this batch routine
      IF NOT EXIST "%STOREPDFDRIVE%%STOREPDFDIRECTORY%" GOTO END
      
      rem set the name of the files into environmental variables
      SET PDFFILETOSAVE=stored.pdf
      SET PDFFILETOSAVEPSX=stored.ps
      SET PDFSHAREDDOCUMENTDIRECTORY=%SYSTEMDRIVE%%HOMEPATH%\desktop\storepdf
      
      rem time is YYYYDDMM-HHMMSSMMM
      rem times are placed in files to keep file naming different. there may be unknown results if we dont do it
      rem set a time stamp to be used in the nameing the files
      rem even though we cannot get the millisecond of the time we will add a 0-zero to the end of the time for  
      SET hour=%time:~0,2%
      if "%hour:~0,1%" == " " set hour=0%hour:~1,1%
      SET MYPDFDAYTIME=%date:~-4%%date:~4,2%%date:~7,2%
      SET MYPDFHMSTIME=%hour%%time:~3,2%%time:~6,2%%time:~9,2%0
      
      rem create environmential variables for the file names. we need 2. one for the postscript file we are getting from stdin with redmons redfile
      
      SET FULLPDFFILETOSAVE=%MYPDFDAYTIME%-%MYPDFHMSTIME%-%PDFFILETOSAVE%
      SET FULLPDFFILETOSAVEPSX=%MYPDFDAYTIME%-%MYPDFHMSTIME%-%PDFFILETOSAVEPSX%
      c:\utility\redmon\redfile "%STOREPDFDRIVE%%STOREPDFDIRECTORY%\%FULLPDFFILETOSAVEPSX%"
      if not exist "%STOREPDFDRIVE%%STOREPDFDIRECTORY%\%FULLPDFFILETOSAVEPSX%" GOTO END
      "c:\gspdf\bin\gswin32c.exe" @"C:\gspdf\pdfwrite.txt" -sOutputFile="%STOREPDFDRIVE%%STOREPDFDIRECTORY%\%FULLPDFFILETOSAVE%" -c .setpdfwrite -f "%STOREPDFDRIVE%%STOREPDFDIRECTORY%\%FULLPDFFILETOSAVEPSX%"
      rem "c:\gspdf\bin\gswin32c.exe" @"C:\gspdf\pdfwrite.txt" -sOutputFile="%STOREPDFDRIVE%%STOREPDFDIRECTORY%\%FULLPDFFILETOSAVE%" -c .setpdfwrite -f -
      
      rem next line prints the postscript file to the defaul printer
      if exist "%STOREPDFDRIVE%%STOREPDFDIRECTORY%\%FULLPDFFILETOSAVEPSX%" c:\utility\printfile\prfile32 "%STOREPDFDRIVE%%STOREPDFDIRECTORY%\%FULLPDFFILETOSAVEPSX%"
      
      rem delete the postscript file because we do not need it any longer
      if exist "%STOREPDFDRIVE%%STOREPDFDIRECTORY%\%FULLPDFFILETOSAVEPSX%" del "%STOREPDFDRIVE%%STOREPDFDIRECTORY%\%FULLPDFFILETOSAVEPSX%"
      
      rem if the desired pdf file to create does not exist then abort the batch routine
      if not exist "%STOREPDFDRIVE%%STOREPDFDIRECTORY%\%FULLPDFFILETOSAVE%" GOTO END
      
      rem create some other directories to copy the pdf file into
      if not exist "%STOREPDFDRIVE%\pdfsaved" md "%STOREPDFDRIVE%\pdfsaved"
      if not exist "%ALLUSERSPROFILE%\pdfsaved" md "%ALLUSERSPROFILE%\pdfsaved"
      if not exist "%PDFSHAREDDOCUMENTDIRECTORY%" md "%PDFSHAREDDOCUMENTDIRECTORY%"
      
      rem copy the pdf file created into the other directories for hopefully safe keeping
      COPY     "%STOREPDFDRIVE%%STOREPDFDIRECTORY%\%FULLPDFFILETOSAVE%" "%PDFSHAREDDOCUMENTDIRECTORY%\%FULLPDFFILETOSAVE%"
      COPY     "%STOREPDFDRIVE%%STOREPDFDIRECTORY%\%FULLPDFFILETOSAVE%" "%STOREPDFDRIVE%%STOREPDFDIRECTORY%\zzzzz-%FULLPDFFILETOSAVE%"
      COPY     "%STOREPDFDRIVE%%STOREPDFDIRECTORY%\%FULLPDFFILETOSAVE%" "%ALLUSERSPROFILE%\pdfsaved\zzzzz-%FULLPDFFILETOSAVE%"
      COPY     "%STOREPDFDRIVE%%STOREPDFDIRECTORY%\%FULLPDFFILETOSAVE%" "%STOREPDFDRIVE%\pdfsaved\zzzzz-%FULLPDFFILETOSAVE%"
      
      rem display the pdf file from one of the directories where we placed a copy of the pdf file
      IF EXIST "%PDFSHAREDDOCUMENTDIRECTORY%\%FULLPDFFILETOSAVE%" START "" "%PDFSHAREDDOCUMENTDIRECTORY%\%FULLPDFFILETOSAVE%"
      rem if the pdf file is where we thought we wanted it then abort the batch file
      IF EXIST "%PDFSHAREDDOCUMENTDIRECTORY%\%FULLPDFFILETOSAVE%" GOTO END
      rem if the pdf file did not exist where we wanted it stored for user experience then load the pdf file from where it was created at.
      START " " "%STOREPDFDRIVE%%STOREPDFDIRECTORY%\%FULLPDFFILETOSAVE%"
      :END
      Attached Files
      p purvis

      Comment


      • #4
        2 more posting i think or maybe 3 and likey much more to come later

        now you got the whole thing on the first trip, usually you only get a piece of it don't you.

        here is basically what i have working now.
        this batch file does not create a postscript .ps file to print.
        this routine is without all the notation for faster processing
        this routine will create a pdf file with a date stamp in front of it and it will or should load your pdf viewer with the pdf file created
        you can get ride of the copying but i am leaving in here to copy pdf files into a couple of directories called "pdfsaved:"

        now if you have trouble with environmental variables and you want to see what is going on.
        just use the command in the batch file maybe at the top or bottom or somewhere in the batch process to check on what is the environmental variables
        use
        [code]
        SET > C:\SOMEDIRECTORY\SET1.TXT
        [code]
        or
        [code]
        SET > C:\SOMEDIRECTORY\SET1.TXT
        GOTO END
        [code]
        or
        [code]
        SET >> C:\SOMEDIRECTORY\SET1.TXT
        [code]

        you will see different variable either existing or not depending on operating system and if
        A big IF here, if you have checked to "RUN as User" in the port setting section.
        The problem here may be that you will NOTsee some ENVIRONMENTAL VARIABLES and also the user may not be able to delete the DPF files created for better or worst.

        These batch files assume you did check that "Run as User"

        here is what i have to does not print automatically which means i do not have to deal with the RedMon program "redfile.exe" or the ps printing program "PrFile32.exe.
        I just let let the user pick to print the pdf to a printer if they want to or not but it is confusing for a new user as they start picking the virtual printer that actual made this happen.
        But, you will not loose any PDF file. Where is that happy face icon you put on this forum

        so here it is and maybe just slightly more that you want be good to test with
        and if you use the START command like i am using and you want to because if you do not, then it will hold up other processes.
        you can use the "Print Test Page" in the virtual printer properties you just created to test the working of what you have created.

        gsstoreaspdf.bat
        Code:
        @echo off
        rem this routine will create a pdf file from redirection directly into ghostscript
        SET STOREPDFDRIVE=%SYSTEMDRIVE%
        SET STOREPDFDIRECTORY=\storepdf
        IF NOT EXIST "%STOREPDFDRIVE%%STOREPDFDIRECTORY%" md "%STOREPDFDRIVE%%STOREPDFDIRECTORY%"
        IF NOT EXIST "%STOREPDFDRIVE%%STOREPDFDIRECTORY%" GOTO END
        SET PDFFILETOSAVE=stored.pdf
        SET PDFSHAREDDOCUMENTDIRECTORY=%SYSTEMDRIVE%%HOMEPATH%\desktop\storepdf
        SET hour=%time:~0,2%
        if "%hour:~0,1%" == " " set hour=0%hour:~1,1%
        SET MYPDFDAYTIME=%date:~-4%%date:~4,2%%date:~7,2%
        SET MYPDFHMSTIME=%hour%%time:~3,2%%time:~6,2%%time:~9,2%0
        SET FULLPDFFILETOSAVE=%MYPDFDAYTIME%-%MYPDFHMSTIME%-%PDFFILETOSAVE%
        "c:\gspdf\bin\gswin32c.exe" @"C:\gspdf\pdfwrite.txt" -sOutputFile="%STOREPDFDRIVE%%STOREPDFDIRECTORY%\%FULLPDFFILETOSAVE%" -c .setpdfwrite -f -
        if not exist "%STOREPDFDRIVE%%STOREPDFDIRECTORY%\%FULLPDFFILETOSAVE%" GOTO END
        if not exist "%STOREPDFDRIVE%\pdfsaved" md "%STOREPDFDRIVE%\pdfsaved"
        if not exist "%ALLUSERSPROFILE%\pdfsaved" md "%ALLUSERSPROFILE%\pdfsaved"
        if not exist "%PDFSHAREDDOCUMENTDIRECTORY%" md "%PDFSHAREDDOCUMENTDIRECTORY%"
        COPY     "%STOREPDFDRIVE%%STOREPDFDIRECTORY%\%FULLPDFFILETOSAVE%" "%PDFSHAREDDOCUMENTDIRECTORY%\%FULLPDFFILETOSAVE%"
        COPY     "%STOREPDFDRIVE%%STOREPDFDIRECTORY%\%FULLPDFFILETOSAVE%" "%ALLUSERSPROFILE%\pdfsaved\%FULLPDFFILETOSAVE%"
        COPY     "%STOREPDFDRIVE%%STOREPDFDIRECTORY%\%FULLPDFFILETOSAVE%" "%STOREPDFDRIVE%\pdfsaved\%FULLPDFFILETOSAVE%"
        IF EXIST "%PDFSHAREDDOCUMENTDIRECTORY%\%FULLPDFFILETOSAVE%" START "" "%PDFSHAREDDOCUMENTDIRECTORY%\%FULLPDFFILETOSAVE%"
        IF EXIST "%PDFSHAREDDOCUMENTDIRECTORY%\%FULLPDFFILETOSAVE%" GOTO END
        START " " "%STOREPDFDRIVE%%STOREPDFDIRECTORY%\%FULLPDFFILETOSAVE%"
        :END
        Attached Files
        p purvis

        Comment


        • #5
          Had you considered some COM in PB to open MS Word, set font, etc, paste in text, and "Save as type: *.PDF" ?
          Dale

          Comment


          • #6
            Originally posted by Paul Purvis View Post
            I need a way to create and save PDF files.
            Paul, we've used a utility called Txt2PDF from Davinci since the early 2000's. We simply "Shell" to it to create the PDFs. We've generated well over a million reports using it. It hasn't been updated in over a decade, but its just rock solid. There are at least a few other shell-able Text2PDF utilities but I cannot speak to them. We stuck with Davinci because we also convert multi-page TIFFs from our scanner into PDFs for web viewing (included in same package). If your Ghostscript idea doesn't work out, you might take a look.

            As I suggested in another thread, you might see if your payment vendor provides an export file with transaction activity. We haven't saved daily gateway transaction reports since 2004, because we archive all the raw data. Once you have the data, you can generate your own reports, and they'd probably look nicer too!

            Comment


            • #7
              That folks was a lot of work and now you can view all you test printing without using CutePDF Writer and it all seems to be the same.
              You can actually make similar changes in CutePDF virtual printer drive in the Device Settings as well and also use the CutePdf virtual printer driver too. I could not see differences.
              I have had great much better results by adding the fonts from the windows operating system. Ghostscript will load the fonts when it needs them.
              By not allowing or allowing font substitution does make a difference in appearance. I just do not like ghostcript changing out Courier New to Courier.
              Dealing with fonts seems to be a big head ache for many things. If a program can generate a PDF file, that is the way to go i believe.
              Courier regular is aweful light for reading, specially printed on paper. There is a DarkCourier but i have not figured out a way to make that change in substitution, which probably is needed for a lot of conditions.

              now i did see this one post on the internet but ghostscript is not new to me but i am just a beginner to learning the ins and outs.
              because i am looking for a better method of automatic printing a pdf to a printer i did find this bit of information that may help produce a better ps file that can then be converted to a pdf file.
              i found this command line for ghostscript at
              https://stackoverflow.com/questions/...and-vice-versa

              Code:
              gs \
                -o output.pdf \
                -sDEVICE=pdfwrite \
                -dPDFSETTINGS=/prepress \
                -dHaveTrueTypes=true \
                -dEmbedAllFonts=true \
                -dSubsetFonts=false \del
                -c ".setpdfwrite <</NeverEmbed [ ]>> setdistillerparams" \
                -f input.ps
              also untried a program that prints to multiple printers using one print job.
              this might help where you are trying to save pdf files of what is being printed for whatever purpose

              Print to multiple printers at the same time
              (Runs on all Windows versions)
              The MultiPrinter port enables printing on up to 64 local and/or network printers at the same time.
              It is great for transmitting print documents to multiple departments in your organization.
              http://www.pcounter.com.au/mpp.html

              I have reasons for setting up multiple virtual printers to create pdf files for different reports or topics.
              The last batch listed file to create a pdf file is now in production.
              I will be batch processing these pdf files using pdf tools such as MuTools and xpdf to find text in pdf files then renaming them when i can to what source they came from, but this is far better than scanning paper to then OCR it and store it. I hope this will save you a lot of time. You should get good results from seeing your printed output for program design reasons on the programming side.
              Once again, i do not have time now to test on a 64 bit system. Those that do, please respond back with your results.
              If ghostscript creates any temporary files, which the print spooler surely will, i do not know of them.
              You can add paths to the fonts directory, the first font picked up is the font used. Maybe "C:Windows\fonts" should be listed first and not "c:\gspdf\fonts" in that ghostscript parameter named -sFONTPATH.
              There is much on the internet for reading, but use the spooling and not the print directly to printer for fast processing.
              The really speed slow down is the conversion of redirected ps file by way of stdin to ghostscipt and not the actually sending of the file through the print driver, but go ahead and try a few other postscript printer drivers.
              You can also have the virtual printer driver port ask you for a pdf file name to be saved without using this batch file at all and it can all take place in the RedMon port settings.
              There is a program to convert PCL files to PDF and that may be worth looking into but i have a need to also convert from PDF to TIFF files and this is going to be the same way I do it also.
              You can get fancy and what the directory of where you print these PDF files and do all kinds of stuff you can dream of.
              I used Mutools this morining and i was surprised how fast it worked with PDF files, specially begin PDF files, really BIG.

              Years back, I wondered why Foxit Reader was so much slower at printing a PDF file over a network.
              What i discovered was that when Adobe Reader printed the exact same info to the printer, that the files where a great bit smaller that Foxit Reader that i could not believe my eyes. You halt or keep printed documents in the spooler and go look into the spooler directory to see these differences in SPL files.
              I am not going to change but i just wonder what the difference will be in created PDF size using different PDF viewer/printer programs.
              Well i did a lot of work and time to get things to working.
              If you find a way to send the file to a PDF viewer with using the START command, I am all ears.
              if you remove the START command and are testing with the print test page in printer properties, you will see properties slow and not even respond with a message that a test page has been sent and that is only if you are wanting the batch file to produce a viewable PDF file on the spot immediately
              That is about it i think, if i left something out i will post back.
              Look at the text in a PDF file after you have printed it from a pdf viewer.
              p purvis

              Comment


              • #8
                Dale and Raymond, thank you.
                Dale, we do not have microsoft word on half our computers.
                Raymond, I have those tools too and created a couple text2pdf programs myself from the help here that work great, fast and produce small pdf files and exactly what i want and need.
                Raymond, as you know, tiff files on an IPad only show the first page. I set up a server to also handle faxes that come in and i have php code that uses tiff2pdf to convert those tiff files to pdf files where my brother can see those faxes from almost anywhere. Another place i have where you can drag a tiff file onto a small gui and it will create a pdf file in the same place the tiff comes from.
                The result is a file called filename.tif.pdf. from filename.tif so we can identify the file which it came. I have no issue getting my work to be saved. It is other peoples work that work for us.
                Sadly we have to redact some info from scanned documents that are sent to outside concerns, such as a court house.
                But my biggest problem for things out of my total control is other software that i have absolutely very little control over.
                Getting the data is my first concern because i want it keep for many reasons.
                Also some reports are fancy made with graphics printed on them too and not just plane text.
                We do not the volume of work on a daily basis to afford other ways provided by outside means.
                This will work and i cannot wait to try that multiple print program, I can catch all what goes to certain printers if this works.
                p purvis

                Comment


                • #9
                  Nothing is new under the sun. 16 years ago https://forum.powerbasic.com/forum/u...236#post105236

                  I've still got the PB source for it somewhere
                  --
                  [URL="http://www.camcopng.com"]CAMCo - Applications Development & ICT Consultancy[/URL][URL="http://www.hostingpng.com"]
                  PNG Domain Hosting[/URL]

                  Comment


                  • #10
                    ... , we do not have microsoft word on half our computers
                    I did not realize all were creating the .PDFs. Now I bow out.
                    Dale

                    Comment


                    • #11
                      Have you investigated the (free) community edition of Virtual Print Engine (VPE)? https://www.idealsoftware.com/en/pdf...rt-engine.html We use the paid-for version for everything we do at work.
                      Real programmers use a magnetized needle and a steady hand

                      Comment


                      • #12
                        FYI -- I don't know about XP, or Win7 but the Microsoft PDF printer driver is built into Windows 10 Pro. You set it up through SETTINGS | DEVICES | PRINTERS & SCANNERS

                        Comment


                        • #13
                          Originally posted by Bud Durland View Post
                          Have you investigated the (free) community edition of Virtual Print Engine (VPE)? https://www.idealsoftware.com/en/pdf...rt-engine.html We use the paid-for version for everything we do at work.
                          Wow! I'm impressed!

                          Just downloaded it and had a quick play with it. Just one 809KB DLL to distribute with your application. Two include files for development (I had to make a slight edit to one of the supplied PowerBASIC include files with PBWIn 10 - I commented out the initial #IF NOT DEF(WINAPI...#END IF) block at the start.

                          And here's a complete application to create a PDF ( no set up required of any kind - no need to instal Ghostscript, printer drivers etc)

                          Code:
                          #COMPILE EXE
                          #DIM ALL
                          #INCLUDE "win32api.inc"
                          #INCLUDE "vpe_api_c.inc"
                          #INCLUDE "vpe_symbols.inc"
                          
                          FUNCTION PBMAIN() AS LONG
                          CreatePDF "MyPDF"
                          ? "MyPDF.pdf created"
                           END FUNCTION
                          
                          FUNCTION CreatePDF(fname AS ASCIIZ) AS LONG
                            LOCAL hDoc AS DWORD
                              hDoc = VpeOpenDoc(0, fname, 0)
                              VpeWriteBox(hDoc, 1, 1, 5, 1.5, "Hello World!")
                              VpeLine(hDoc, 1.5, 3, 5, 6.5)
                              VpeWriteDoc(hDoc, fname & ".PDF")
                          END FUNCTION

                          I'll be buying at least the Standard Edition the next time i have a client project which needs this. At around $360, I can see that it will pay for itself very quickly.
                          --
                          [URL="http://www.camcopng.com"]CAMCo - Applications Development & ICT Consultancy[/URL][URL="http://www.hostingpng.com"]
                          PNG Domain Hosting[/URL]

                          Comment


                          • #14
                            Remember all that hassle a while ago about getting A BITMAP RESOURCE out of a DLL? (https://forum.powerbasic.com/forum/u...graphic-window)


                            Here's the above CreatePDF function with VPE doing it. Retrieve a bitmap from the DLL and embed it in the PDF:

                            Code:
                            FUNCTION CreatePDF(fname AS ASCIIZ) AS LONG
                              LOCAL hMod,hDoc AS DWORD
                              hMod = loadlibrary ("DemoData.DLL")
                                IF hMOd = 0 THEN ? "No module handle":EXIT FUNCTION
                                hDoc = VpeOpenDoc(0, fname, 0)
                                VpeWriteBox(hDoc, 1, 1, 5, 1.5, "Hello World!")
                                VpeLine(hDoc, 1.5, 3, 5, 6.5)
                              VpePictureResName(hDoc,2,2,4,4,hMod,"myBitmap")
                                VpeWriteDoc(hDoc, fname & ".PDF")
                            END FUNCTION
                            .
                            --
                            [URL="http://www.camcopng.com"]CAMCo - Applications Development & ICT Consultancy[/URL][URL="http://www.hostingpng.com"]
                            PNG Domain Hosting[/URL]

                            Comment


                            • #15
                              Raymond
                              See this posting of a program that I was able to write from the help of the forum members here. I think MCM inspired me by one of his post and Jose' did some hard work to help produce inc source code.
                              https://forum.powerbasic.com/forum/u...gramming/60598

                              Stuart thank you , where did you get the $360 dollars amount from?
                              Go to try out your code.
                              Be nice to just have a PDF viewer or good pdf batch printer even if paid for.
                              p purvis

                              Comment


                              • #16
                                Here's the above CreatePDF function with VPE doing it. Retrieve a bitmap from the DLL and embed it in the PDF,,, [Post#14 this thread 3/2/18 ]
                                You need to call "FreeLibrary" in that procedure ("CreatePDF") if ...

                                1. That procedure is called more than once per instance*
                                AND/OR
                                2. You believe in cleaning up after yourself and not waiting for Windows to do it when the process ends

                                Me, I'd call it in that procedure at the end, just so my "loadlibrary" and "freelibrary" calls appear in "matched pairs."

                                MCM
                                * for example, I have a program which produces 300 to 400 separate PDF files per run. (Different library, (Haru) but same principle!)
                                Michael Mattias
                                Tal Systems Inc.
                                Racine WI USA
                                mmattias@talsystems.com
                                http://www.talsystems.com

                                Comment


                                • #17
                                  The attached ZIP file has a small include file that we use with VPE. [zip file removed] I started it to make it easier to transition some reports from DDOC, but it fleshed out past that. Personally I prefer a single function call ("draw a solid black line.003" wide from here to here") instead of separate calls to set the color, pen size, etc. Also, by convention we use a variable 'cy' (ghost of DDOC, again) to keep track of the current vertical position on the page, and there's a macro (mCheckPage) that helps keeps all the elements of one print line together when you may be approaching the bottom.
                                  Real programmers use a magnetized needle and a steady hand

                                  Comment


                                  • #18
                                    Originally posted by Paul Purvis View Post
                                    Raymond
                                    See this posting of a program that I was able to write from the help of the forum members here. I think MCM inspired me by one of his post and Jose' did some hard work to help produce inc source code.
                                    https://forum.powerbasic.com/forum/u...gramming/60598

                                    Stuart thank you , where did you get the $360 dollars amount from?
                                    Go to try out your code.
                                    Be nice to just have a PDF viewer or good pdf batch printer even if paid for.
                                    I went into their online store and the Standard Edition SDK was 298 Euros which Google tells me is about USD367 today (it was a bit less when I checked originally)
                                    --
                                    [URL="http://www.camcopng.com"]CAMCo - Applications Development & ICT Consultancy[/URL][URL="http://www.hostingpng.com"]
                                    PNG Domain Hosting[/URL]

                                    Comment


                                    • #19
                                      Originally posted by Michael Mattias View Post

                                      You need to call "FreeLibrary" in that procedure ("CreatePDF") if ...

                                      1. That procedure is called more than once per instance*
                                      AND/OR
                                      2. You believe in cleaning up after yourself and not waiting for Windows to do it when the process ends

                                      Me, I'd call it in that procedure at the end, just so my "loadlibrary" and "freelibrary" calls appear in "matched pairs."

                                      MCM
                                      * for example, I have a program which produces 300 to 400 separate PDF files per run. (Different library, (Haru) but same principle!)
                                      Minimal code for demonstration purposes.
                                      --
                                      [URL="http://www.camcopng.com"]CAMCo - Applications Development & ICT Consultancy[/URL][URL="http://www.hostingpng.com"]
                                      PNG Domain Hosting[/URL]

                                      Comment


                                      • #20
                                        Originally posted by Bud Durland View Post
                                        The attached ZIP file has a small include file that we use with VPE. [ATTACH]n770437[/ATTACH] I started it to make it easier to transition some reports from DDOC, but it fleshed out past that. Personally I prefer a single function call ("draw a solid black line.003" wide from here to here") instead of separate calls to set the color, pen size, etc. Also, by convention we use a variable 'cy' (ghost of DDOC, again) to keep track of the current vertical position on the page, and there's a macro (mCheckPage) that helps keeps all the elements of one print line together when you may be approaching the bottom.
                                        Very nice, but you may like to delete the "VpeLicense hDoc... " line and repost the ZIP
                                        --
                                        [URL="http://www.camcopng.com"]CAMCo - Applications Development & ICT Consultancy[/URL][URL="http://www.hostingpng.com"]
                                        PNG Domain Hosting[/URL]

                                        Comment

                                        Working...
                                        X