Microsoft Print to PDF

This forum is for ideas and or code to be contributed for general use.
Post Reply
Message
Author
User avatar
slobodan1949
Posts: 80
Joined: Mon Apr 25, 2011 8:57 am
Location: SERBIA
Contact:

Microsoft Print to PDF

#1 Post by slobodan1949 »

PDF PRINTER Microsoft Print to PDF and eXpress++


ENG

I have long been waiting for a program to generate PDF files from any text
and which will be an integral part of windows. Finally arrived:

Microsoft Print to PDF

But (there is always someone but) many parameters cannot be set for this pdf printer:

- cannot specify your pdf file name
- cannot specify your folder in which the pdf file will be written
- the start of the PDF reader cannot be switched off and on after the PDF file has been generated
- the file dialog requesting the name of the PDF file cannot be switched off or on

So far, this has not been documented by Microsoft

And then comes Roger Donnay and eXpress ++ ...

The best thing about the whole story is that eXpress ++ is great for working with
printer: Microsoft Print to PDF and gives you the ability to have it all
the functions listed above.

For example, the basic command DCPRINT ON

- from the given string: aTxt,
- create the specified file: PDFTEST.PDF,
- in the specified folder: "D: \ PDF DOCUMENTS"
- does not open a file-dialog for entering the file name (Save As)
- either does not call the PDF reader or
- calls the default PDF reader and displays the pdf file in it: PDFTEST.PDF


SRB

Odavno sam čekao program za generisanje PDF fajlova iz bilo kog teksta
a koji će biti sastavni deo windows-a. Najzad je stigao:

Microsoft Print to PDF

Ali (uvek ima neko ali) tom pdf printeru se ne mogu zadati mnogi parametri:

- ne može se zadati svoj naziv pdf fajla
- ne može se zadati svoj folder u koji će pdf fajl biti upisan
- ne može se isključiti i uključiti start PDF readera posle generisanja PDF fajla
- ne može se isključiti ili uključiti file-dialog sa upitom za naziv PDF fajla

Za sada ovo nije dokumentovano kod Microsofta

I tada dolazi Roger Donnay i eXpress++...

U celoj priči najlepše je to, što eXpress++ odlično podržava rad sa
printerom: Microsoft Print to PDF i daje vam mogućnost da imate sve
gore nabrojane funkcije.

Na primer, osnovna komanda DCPRINT ON

- iz zadatog niza : aTxt,
- kreira zadati fajl : PDFTEST.PDF,
- u zadatom folderu : "D:\PDF DOCUMENTS"
- pri tom ne otvara file-dialog za upis naziva fajla (Save As)
- pri tom ili ne poziva PDF reader ili
- poziva zadati PDF reader i u njemu prikazuje pdf fajl: PDFTEST.PDF
* ---

Code: Select all

FUNCTION PRINT2PDF(cPDFfilePath,aTxt)

LOCAL oPrinter, i, aOptions
LOCAL nFolder, cFolder, x

// cPDFfilePath je PDF fajl koji se generiše iz programa
// cPDFfilePath is a PDF file generated from the program

   cPDFfilePath := "D:\PDF DOCUMENTS\PDFTEST.PDF"

// cTxt je niz koga sačinjavaju redovi teksta iz nekog tekst dokumenta: test.txt
// cTxt is a array made up of lines of text from a text document: test.txt
// cTxt := {row1,row2,row3,... row2000}

* ---
// Napravi folder ako ga nema
// Create a folder if it doesn't exist

nFolder:=rat("\",cPDFfilePath)
if nFolder>0
   cFolder:=left(cPDFfilePath,nFolder-1)
   DIRMAKE(cFolder)  // XbToolsIII
endif

// obriši PDF fajl ako ga ima
// delete the PDF file if it exists

IF FExists(cPDFfilePath)
   FErase(cPDFfilePath)
ENDIF

* ---


// aktiviraj PDF printer
// activate PDF printer
                                                          // MS Windows 10, 11...
  DCPRINT ON TO oPrinter NAME "Microsoft Print to PDF" ;  // PDF printer Free
  TOFILE OUTFILE (cPDFfilePath)                           // eXpress++

  IF oPrinter = NIL .OR. !oPrinter:lActive
     RETURN .F.
  ENDIF

      DCPRINT FONT "8.Consolas"  // eXpress++

      x:=0

      FOR i = 1 TO len(aTxt)

      x:=x+1

         @ x,2 DCPRINT SAY aTxt[i]  // eXpress++

         IF x==60

            DCPRINT EJECT // eXpress++

            x:=0

         ENDIF


      NEXT i

      DCPRINT OFF  // eXpress++

   // sačekaj da se PDF fajl generiše
   // wait for the PDF file to be generated:

      DO WHILE FSize(cPDFfilePath) < 10  // 10 byte
        Sleep(50)
      ENDDO

   // prikaži PDF fajl iz PDF reader-a:
   // show PDF file from PDF reader:

      DC_SpawnUrl(cPDFfilePath) // eXpress++ // Default PDF reader
                                // Adobe Acrobat Reader DC 11...
   *
   * or:
   *
   *  exedir := strtran(appname(.t.),appname())
   *  RUNSHELL('"'+cPDFfilePath+'"', exedir+"SumatraPDF.EXE")  // Sumatra PDF reader
   *  RUNSHELL('"'+cPDFfilePath+'"', exedir+"FoxitReader.EXE") // Foxit PDF reader

RETURN .T.

User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Microsoft Print to PDF

#2 Post by rdonnay »

I am pleased that you find DCPRINT useful for your PDF purposes.

I use it a lot myself, mostly with Microsoft Print to PDF and BullZip.
The eXpress train is coming - and it has more cars.

Wolfgang Ciriack
Posts: 478
Joined: Wed Jan 27, 2010 10:25 pm
Location: Berlin Germany

Re: Microsoft Print to PDF

#3 Post by Wolfgang Ciriack »

It is too bad, that the Microsoft Print to PDF do not support PDF/A format.
Does bullzip driver suport it ?
_______________________
Best Regards
Wolfgang

User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Microsoft Print to PDF

#4 Post by rdonnay »

This is from the bullzip.com web page:

PDF/A-1b support for long time storage of PDF documents.
The eXpress train is coming - and it has more cars.

Wolfgang Ciriack
Posts: 478
Joined: Wed Jan 27, 2010 10:25 pm
Location: Berlin Germany

Re: Microsoft Print to PDF

#5 Post by Wolfgang Ciriack »

But bullzip is only free for max 10 Users. So i decided to stay with Microsoft Print to Pdf and convert them from Pdf to Pdf/A with my viewer.
_______________________
Best Regards
Wolfgang

User avatar
Tom
Posts: 1165
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: Microsoft Print to PDF

#6 Post by Tom »

L&L creates PDF/A aswell.

Code: Select all

LlXSetParameter(hOptJob, LL_LLX_EXTENSIONTYPE_EXPORT, "PDF", "PDF.PDFAMode","1")
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

User avatar
SlavkoDam
Posts: 79
Joined: Wed Apr 27, 2022 10:12 am
Location: Negotin, Serbia
Contact:

Re: Microsoft Print to PDF

#7 Post by SlavkoDam »

PDF files can also be created with export module of PowerWin library. It supports not only PDF, but also Word, Excel and HTML formats. Export reports can include various data types, such as text, images, browsers and quick-browsers, database files, arrays, shapes and links. PowerWin library don't use any external drivers or tools.
Best regards,

Slavoljub Damnjanovic
SD-SoftDesign, Alaska Software Technology Partner
https://www.sd-softdesign.com
https://www.sd-softdesign.rs

Post Reply