bb.donnay-software.com

Donnay Software Web Forums
It is currently Mon May 25, 2020 9:59 am

All times are UTC - 7 hours




Post new topic Reply to topic  [ 12 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Wed Mar 15, 2017 6:54 am 
Offline

Joined: Mon Feb 01, 2010 8:45 am
Posts: 122
The printer "Microsft Print To PDF" is a part of WIN10
Has anyone done this ?
How ?

_________________
Klaus


Top
 Profile  
 
PostPosted: Wed Mar 15, 2017 7:06 am 
Offline
Site Admin
User avatar

Joined: Wed Jan 27, 2010 6:58 pm
Posts: 4124
Location: Boise, Idaho USA
I am now working in Win 10 and I have been meaning to test this.

I will get to it soon.

_________________
The eXpress train is coming - and it has more cars.


Top
 Profile  
 
PostPosted: Tue Apr 11, 2017 12:34 pm 
Offline
User avatar

Joined: Tue Jul 28, 2015 5:15 am
Posts: 94
DCPRINT works fine for me with Microsoft Print to PDF.

I use it as a printer. The printer name is not pre-defined. The printer select window will allow you to select this printer.
You than need to specify the file name of your choice.


Top
 Profile  
 
PostPosted: Tue Apr 11, 2017 10:39 pm 
Offline

Joined: Mon Feb 01, 2010 8:45 am
Posts: 122
I know that, but this is not what i want.
I want use the OUTFILE clause as with Bullzip PDF or Microsoft Image Writer.

_________________
Klaus


Top
 Profile  
 
PostPosted: Wed Apr 12, 2017 7:42 am 
Offline
Site Admin
User avatar

Joined: Wed Jan 27, 2010 6:58 pm
Posts: 4124
Location: Boise, Idaho USA
I understand that you want it to work like Bullzip but I don't yet know how to do that.
I'll try to get to it this week.

_________________
The eXpress train is coming - and it has more cars.


Top
 Profile  
 
PostPosted: Wed Apr 12, 2017 8:20 am 
Offline

Joined: Thu Jan 28, 2010 9:11 pm
Posts: 605
Location: Steven Point, Wisconsin USA
I see an example for C# that uses there PrinterDocument object and PrinterSettings object. Then they use the doc.Printout() method with one of the parameters being OutputFileName. However, I do not yet know how to make that work in Xbase++.

http://stackoverflow.com/questions/3189 ... me-in-c-sh

I don't use the Xbase++/Express++ printing much so my exposure is limited.


Top
 Profile  
 
PostPosted: Wed Apr 12, 2017 9:01 am 
Offline
Site Admin
User avatar

Joined: Wed Jan 27, 2010 6:58 pm
Posts: 4124
Location: Boise, Idaho USA
Quote:
PrinterDocument object and PrinterSettings object


This is how Bullzip works. I had to put code in _DCPRC.PRG to use their ActiveX control for routing the output to a file.
See below.

It will take time to figure out how to do this with the Microsoft Print to PDF.

Also, this technique is not thread-safe.
You must be careful not to run more than 1 print job simultaneously.
I found this out when using BULLZIP in an application that creates PDF reports in multiple threads.

Code:
      #if XPPVER > 1900000
      IF Upper(cPrinterName) == 'BULLZIP PDF PRINTER' .AND. ;
        AScan(XbpPrinter():new():list(),{|c|Upper(c)=='BULLZIP PDF PRINTER'})>0
        ::lToFile := .f.
        lToFile := .f.
        ::oBullZip := ActiveXObject():create('Bullzip.PDFPrinterSettings')
        ::oBullZip:SetValue('Output',::cOutFile)
        ::oBullZip:SetValue('ShowSaveAs','never')
        ::oBullZip:SetValue('ShowSettings','never')
        ::oBullZip:SetValue('ShowPdf','no')
        ::oBullZip:SetValue('ConfirmOverwrite','no')
        ::oBullZip:SetValue('ShowProgressFinished','no')
        ::oBullZip:SetValue('ShowProgress','no')
        ::oBullZip:WriteSettings()
      ENDIF
      #endif

_________________
The eXpress train is coming - and it has more cars.


Top
 Profile  
 
PostPosted: Wed Apr 12, 2017 8:13 pm 
Offline

Joined: Thu Jan 28, 2010 9:11 pm
Posts: 605
Location: Steven Point, Wisconsin USA
I found this code at the stackoverflow link provide in the post two items above. This c# code gave me the idea that the way the Micrsoft Print to PDF drive was implemented is in the standard windows printer dialog was you just define the xbpprinter:setprintfile() method to the desired file name. I did not check Roger's DCPRINT code to see if the TOFILE OUTFILE was implementing the :setprintfile() method but I thought is was. So in my included code snippet below, I just simply took my screen print routine that sends the capture screen image oBitMap to the current default printer, which prints it normally on a printer, and changed the code to instead use the DCPRINT ... TOFILE OUTFILE .... commands to see if took the screen image, generated it as a PDF and sent it to the desired file.

Well it appears to work correctly without any special Express++ code changes or handling. You just specify your "Microsoft Print to PDF" driver as the printer and use the TO FILE c:\pdfexport\test111.pdf clause and it generated the attached PDF file which is an exact replica of the printed page. So it is working as desired.

Code:
XbpPrinter:setPrintFile()
Set file to print to.

:setPrintFile( [<cFileName>] ) --> cOldFileName | NIL

Parameters
<cFileName>
<cFileName> must be set either to a legal file name to spool to or to the #define constant XBPPRN_FILE_PROMPT. Passing a null string ("") resets the "print to file" option.

Return
The method returns the name of the file previously set or "", if printing to a file was previously disabled. If the driver does not support this option, the return value is NIL.

Description
This method is used to re-direct print output to a file. If the constant XBPPRN_FILE_PROMPT is used for <cFileName>, the user is prompted for a file name when the :startDoc() method is executed. 


Code:
/// <summary>
/// Convert a file to PDF using office _Document object
/// </summary>
/// <param name="InputFile">Full path and filename with extension of the file you want to convert from</param>
/// <returns></returns>
public void PrintFile(string InputFile)
{
    // convert input filename to new pdf name
    object OutputFileName = Path.Combine(
        Path.GetDirectoryName(InputFile),
        Path.GetFileNameWithoutExtension(InputFile)+".pdf"
    );

    // Set an object so there is less typing for values not needed
    object missing = System.Reflection.Missing.Value;

    // `doc` is of type `_Document`
    doc.PrintOut(
        ref missing,    // Background
        ref missing,    // Append
        ref missing,    // Range
        OutputFileName, // OutputFileName
        ref missing,    // From
        ref missing,    // To
        ref missing,    // Item
        ref missing,    // Copies
        ref missing,    // Pages
        ref missing,    // PageType
        ref missing,    // PrintToFile
        ref missing,    // Collate
        ref missing,    // ActivePrinterMacGX
        ref missing,    // ManualDuplexPrint
        ref missing,    // PrintZoomColumn
        ref missing,    // PrintZoomRow
        ref missing,    // PrintZoomPaperWidth
        ref missing,    // PrintZoomPaperHeight
    );
}



Code:
      oPrinter1 := XbpPrinter():new()
      aPrinters := oPrinter1:list()
      nPrinter := ascan(aPrinters,{|x| upper(x)=='SCREENPRINT'})

      DCPRINT ON TO oPrinter NAME aPrinters[nPrinter] ORIENTATION 2 RESOLUTION {300,300} TOFILE OUTFILE C:\PDFEXPORT\TEST111.PDF         
      @ 0,1 DCPRINT BITMAP oBitMap PRINTER oPrinter SCALE 2 
      @ 64,1 DCPRINT SAY 'Printed by ' + m->SCompCode + '/' + m->oper_init  PRINTER oPrinter     
      DCPRINT OFF PRINTER oPrinter


The above code creates the printer object, gets the default printer, which I set as the "Microsoft Print to PDF" driver, set the output file to "C:\PDFEXPORT\TEST111.PDF" and then prints out the screen image captured in oBitMap. It generated the PDF, readable by Adobe DC and with the specified filename. No manual intervention. The test111.pdf generated is included in the attached test111.zip file.

Attachment:
test111.zip [247.72 KiB]
Downloaded 348 times


Top
 Profile  
 
PostPosted: Thu Apr 13, 2017 5:31 am 
Offline

Joined: Thu Jan 28, 2010 1:22 am
Posts: 863
Location: Sijsele, Belgium
Hi Cliff,

Thanks for sharing this. It is working as a charm. No need anymore to do an install of PdfCreator (which we were using). I modified my software to check if 'Microsoft print to PDF' is available and use it as standard PDF writer/creator if it is.

It is very fast, much faster according to PDFCreator. The PDF is larger, but this is not a big deal.

_________________
Best regards,

Chris.
www.aboservice.be


Top
 Profile  
 
PostPosted: Thu Apr 13, 2017 6:22 am 
Offline
Site Admin
User avatar

Joined: Wed Jan 27, 2010 6:58 pm
Posts: 4124
Location: Boise, Idaho USA
Wow! I didn't expect it to be that simple, especially after my experiences with Win2PDF and BullZip.

Here's a little test program that works.
Now I'm going to add support for Microsoft Print to PDF as a print previewer.

Code:
#INCLUDE "dcdialog.CH"
#INCLUDE "dcprint.CH"

FUNCTION Main()

LOCAL oPrinter, i

DCPRINT ON NAME "Microsoft Print to PDF" TOFILE OUTFILE ('Print2Pdf.Pdf') ;
   TO oPrinter

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

FOR i := 1 TO 50
   @ i,10 DCPRINT SAY 'This is line ' + Alltrim(Str(i))
NEXT

DCPRINT OFF

RETURN nil

* ----------

PROC appsys ; RETURN

_________________
The eXpress train is coming - and it has more cars.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ]  Go to page 1, 2  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group