<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://dataflex.wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Danwalsh46</id>
	<title>DataFlex Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://dataflex.wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Danwalsh46"/>
	<link rel="alternate" type="text/html" href="https://dataflex.wiki/index.php?title=Special:Contributions/Danwalsh46"/>
	<updated>2026-05-02T22:39:55Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://dataflex.wiki/index.php?title=Print_to_a_file_using_reports&amp;diff=1832</id>
		<title>Print to a file using reports</title>
		<link rel="alternate" type="text/html" href="https://dataflex.wiki/index.php?title=Print_to_a_file_using_reports&amp;diff=1832"/>
		<updated>2008-03-29T16:58:31Z</updated>

		<summary type="html">&lt;p&gt;Danwalsh46: /* Using WinPDF Pro */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;How can I print directly to a file such as PDF or Postscript?&lt;br /&gt;
&lt;br /&gt;
==== Using WinPDF Pro ====&lt;br /&gt;
The example below uses WinPDF Pro printer driver for the PDF generation, Winprint (or at least the report object in VDF) for the reporting and MAPI for sending the mails directly.  Note that each invoice in this example is printed individually.&lt;br /&gt;
&lt;br /&gt;
Pardon the jumbled looking code, but with Win2PDF pro you can do the following:&lt;br /&gt;
&lt;br /&gt;
function JumpStartReport string sInvoice boolean bEmail string sEmailAddress returns boolean&lt;br /&gt;
    boolean bExists bMailed&lt;br /&gt;
    integer iToPrinter iRepObj iHr iMn iRetval&lt;br /&gt;
    string  sVal sDateTime sHr sMn sSetupFile sPath sFilename&lt;br /&gt;
    string  sKey sSubKey sOldRegRoot sOldRegBranch sCurrentDevice sMessage&lt;br /&gt;
    handle  hoMapiSession&lt;br /&gt;
    dWord   dWWSecurityOptions  dWWFileOptions dRetVal&lt;br /&gt;
    date    dToday&lt;br /&gt;
    //&lt;br /&gt;
    get Report_Object_Id To iRepObj&lt;br /&gt;
    //&lt;br /&gt;
    set pSelStart1 of iRepObj To sInvoice&lt;br /&gt;
    set pSelStop1  of iRepObj To sInvoice&lt;br /&gt;
    //&lt;br /&gt;
    if (bEmail) ;&lt;br /&gt;
        set OutPut_Device_Mode to PRINT_TO_PRINTER_NO_DIALOG&lt;br /&gt;
    else        ;&lt;br /&gt;
        set OutPut_Device_Mode to PRINT_TO_PRINTER&lt;br /&gt;
    //&lt;br /&gt;
    if (bEmail) begin&lt;br /&gt;
        move (&amp;quot;Please find attached your invoice&amp;quot; * sInvoice + &amp;quot;.&amp;quot;) to sMessage&lt;br /&gt;
        get  DFGetCurrentDevice of iRepObj to sCurrentDevice&lt;br /&gt;
        send DFSetDevice        of iRepObj    &amp;quot;Win2PDF&amp;quot;&lt;br /&gt;
        //&lt;br /&gt;
        get psHome of (phoWorkspace(ghoApplication))          to sPath&lt;br /&gt;
        move (sPath + &amp;quot;Documents\&amp;quot;)                           to sPath&lt;br /&gt;
        move (&amp;quot;Invoice_&amp;quot; + sInvoice + &amp;quot;.pdf&amp;quot;)                 to sFilename&lt;br /&gt;
        Get_Registry_Root                                     to sOldRegRoot sOldRegBranch&lt;br /&gt;
        move &amp;quot;Dane Prairie Systems&amp;quot;                           to sKey&lt;br /&gt;
        move &amp;quot;Win2PDF&amp;quot;                                        to sSubKey&lt;br /&gt;
        Set_Registry_Root                                     to HKEY_LOCAL_MACHINE &amp;quot;SOFTWARE&amp;quot;&lt;br /&gt;
        Set_Foreign_Profile_String sKey sSubKey &amp;quot;PDFFileName&amp;quot; to (sPath + sFilename)&lt;br /&gt;
        Set_Foreign_Profile_String sKey sSubKey &amp;quot;PDFTitle&amp;quot;    to (&amp;quot;Invoice &amp;quot; + sInvoice)&lt;br /&gt;
        Set_Foreign_Profile_String sKey sSubKey &amp;quot;PDFAuthor&amp;quot;   to &amp;quot;Calendar Invoicing&amp;quot;&lt;br /&gt;
        Set_Foreign_Profile_String sKey sSubKey &amp;quot;PDFSubject&amp;quot;  to (&amp;quot;Calendar Invoice&amp;quot;)&lt;br /&gt;
        Set_Registry_Root                                     to sOldRegRoot sOldRegBranch&lt;br /&gt;
        //Get CheckFileExists sFileName to bExists&lt;br /&gt;
        //If (bExists) Set pbOrgCopyPrinted to TRUE&lt;br /&gt;
    end // if (bEmail) begin&lt;br /&gt;
    //&lt;br /&gt;
    send Run_Report to iRepObj&lt;br /&gt;
    //&lt;br /&gt;
    if (NOT(bEmail)) procedure_return&lt;br /&gt;
    // restore the print device&lt;br /&gt;
    send DFSetDevice of iRepObj sCurrentDevice&lt;br /&gt;
    // gotta have it&lt;br /&gt;
    move oMapiSession to hoMapiSession&lt;br /&gt;
    //showln hoMapiSession&lt;br /&gt;
    if (NOT(hoMapiSession &amp;gt; 0)) begin&lt;br /&gt;
        send Stop_Box &amp;quot;Unable to email invoice.&amp;quot;&lt;br /&gt;
        procedure_return&lt;br /&gt;
    end&lt;br /&gt;
    send DoInit          of hoMapiSession&lt;br /&gt;
    set psMessageSubject of hoMapiSession to (&amp;quot;Daffie Duck Invoice&amp;quot; * sInvoice)&lt;br /&gt;
    set psMessageText    of hoMapiSession to sMessage&lt;br /&gt;
    send DoAddReceiver   of hoMapiSession MAPI_TO (trim(sEmailAddress)) &amp;quot;&amp;quot; &amp;quot;&amp;quot; 0&lt;br /&gt;
    send DoAddAttachment of hoMapiSession (sPath + sFilename) sFilename&lt;br /&gt;
    get Logon            of hoMapiSession &amp;quot;&amp;quot; &amp;quot;&amp;quot; 0 to iRetval&lt;br /&gt;
    //showln iRetval&lt;br /&gt;
    get SendMail         of hoMapiSession (MAPI_NEW_SESSION IOR MAPI_LOGON_UI) TRUE to iRetval&lt;br /&gt;
    //&lt;br /&gt;
    showln (sInvoice * trim(sEmailAddress) * string(iRetval))&lt;br /&gt;
    move (iRetval = 0) to bMailed&lt;br /&gt;
    //&lt;br /&gt;
    get Logoff           of hoMapiSession to iRetval&lt;br /&gt;
    //&lt;br /&gt;
    function_return bMailed&lt;br /&gt;
end_function // JumpStartReport&lt;br /&gt;
&lt;br /&gt;
====External Links====&lt;br /&gt;
[http://www.sture.dk/wasp/threadreport.asp?ThreadId=40911 OT: Print to a File]&lt;/div&gt;</summary>
		<author><name>Danwalsh46</name></author>
	</entry>
</feed>