NetTalk Central

Author Topic: How to create and Save a PDF file in a nominated location using PDFTools  (Read 6292 times)

terryd

  • Hero Member
  • *****
  • Posts: 759
    • View Profile
    • Davcomm
    • Email
I have moved one of my webapps from SoftVelocity PDF to PDFTools.
All my reports work except one where I want to nominate the location and name of the PDF file and save it there without printing or displaying it.
In the SVPDF system I had this line in Init Open Files
PDFReportName = 'PolicyWelcome\' & CLIP(POL:PolicyNo) & '\' & CLIP(POL:PolicyNo) & '_1.pdf'
and the pdf would be created and written to that folder without being displayed.
Looking at Web14 it seems that MailBoxReportDownloadForm is the closest to what I need since the file appears to be created in the Report Folder and is there until the download takes place.
But I cannot find anywhere where the program is told that this is where the file must be created and what its name should be. It is created as e.g. web\Reports\$$$12345.pdf
I also cannot see how the Calling form knows which file to download.
In the make source examples I have seen the called source normally returns the file name like this

p_web.SetProgress(loc:ProgressName,100,GLO:CSVExport)   ! complete the progress bar, and make the file available for download.

but I cannot find how it is updated within the report program in Web14.

To layout what I want to achieve:
1. Have a form with various options called from a menu- got this
2. Call a Make file that selects the records that I want to process - got this
3. Loop through the selected records and inside the loop I call the Welcome Print for each record.- got this
4. WelcomePrint (In this file I nominate location and name of the pdf file I want to generate based on a field name)
5.The letter is generated and saved in the nominated location.

Currently what happens is that my default printer is called (cutepdf) after each record is processed and it asks me to save the file.

Terry Davidson
Windows 10 64 bit/Windows7 64bit
Clarion 9.1.11529/Clarion10 12567
Nettalk 913
Nettalk 1015
StringTheory267/Winevent515/XFiles298/MessageBox239/Cryptonite186

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: How to create and Save a PDF file in a nominated location using PDFTools
« Reply #1 on: November 16, 2015, 11:10:06 PM »
Hi Terry,

Usually the Report extension is set to use
!loc:PDFname
(in the report itself.)

You can see where it is set in the report procedure source, and there's an embed immediately after that so you can set it to something else there if you like. Perhaps using p_web.GetValue to use a field from the form.

Cheers
Bruce

terryd

  • Hero Member
  • *****
  • Posts: 759
    • View Profile
    • Davcomm
    • Email
Re: How to create and Save a PDF file in a nominated location using PDFTools
« Reply #2 on: November 17, 2015, 02:03:26 AM »
Thanks Bruce

Previously with SVPDF I used this code just after open files (the double rem is the variable I used for SVPDF single rem for PDFTools)
  ! Open Files
  Relate:Policy.Open                                       ! File Policy used by this procedure, so make sure it's RelationManager is open
  SELF.FilesOpened = True
  ! [Priority 7501]
  ReportHeader = 'CLIENT INFORMATION'
 
  ! [Priority 7501]
  !!  PDFReportName = 'PolicyWelcome\' & CLIP(POL:PolicyNo) & '\' & CLIP(POL:PolicyNo) & '_1.pdf'
  !!  IF EXISTS(PDFReportName)
  !!      REMOVE(PDFReportName)
  !!  END
  !  loc:PDFName = 'PolicyWelcome\' & CLIP(POL:PolicyNo) & '\' & CLIP(POL:PolicyNo) & '_1.pdf'
  !  IF EXISTS(loc:PDFName)
  !      REMOVE(loc:PDFName)
  !  END
   
  ! Open the window
  SELF.Open(ProgressWindow)
Following your advice I found this code which it appears would run after the above code so I understand why my variable assignment would be overwritten
If Not p_Web &= NULL
    ProgressWindow{prop:hide} = 1
    loc:ProgressName = p_web.GetValue('_ProgressName_')
    p_web.SetProgress(loc:ProgressName,1,'') ! report has started
    loc:URL = '\reports\$$$' & format(random(1,99999),@n05) &'.pdf'
    loc:PDFName = clip(p_web.site.WebFolderPath) & loc:URL
    ! Start of "Prime Report Options when run in Web mode"
    ! [Priority 5000]

So in priority 5000 I embedded
        POL:PolicyID = p_web.GSV('POL:PolicyID')
        loc:URL = '\reports\' & CLIP(POL:PolicyID) & '_1.pdf'
        loc:PDFName = clip(p_web.site.WebFolderPath) & loc:URL
        p_web._trace('loc:PDFName ' & CLIP(loc:PdfName))
        IF EXISTS(loc:PDFName) !so if the report was generated before I can substitute with the later file
            REMOVE(loc:PDFName)
        END

When I run the report I see the progress flash on the screen and then because I have cutepdf as my default printer I get the save file screen from cutePDF.
No file is saved in the report folder. I monitored the report folder and no file was created then deleted.
The trace I placed in the above code does not display in DebugView++
I have (<NetWebServerWorker p_web>) as my prototype

Thoughts?
Terry Davidson
Windows 10 64 bit/Windows7 64bit
Clarion 9.1.11529/Clarion10 12567
Nettalk 913
Nettalk 1015
StringTheory267/Winevent515/XFiles298/MessageBox239/Cryptonite186

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: How to create and Save a PDF file in a nominated location using PDFTools
« Reply #3 on: November 18, 2015, 12:24:43 AM »
>> Thoughts?

I think you need to check the settings for the report to see why it is always being sent to the printer.
I don't think that's related to the PDF name.

Cheers
Bruce


terryd

  • Hero Member
  • *****
  • Posts: 759
    • View Profile
    • Davcomm
    • Email
Re: How to create and Save a PDF file in a nominated location using PDFTools
« Reply #4 on: November 18, 2015, 10:59:30 PM »
Shouldn't there be a Report Target Tag here.
Is there some setting that makes it appear.
I think this is where the problem is.

[attachment deleted by admin]
Terry Davidson
Windows 10 64 bit/Windows7 64bit
Clarion 9.1.11529/Clarion10 12567
Nettalk 913
Nettalk 1015
StringTheory267/Winevent515/XFiles298/MessageBox239/Cryptonite186

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: How to create and Save a PDF file in a nominated location using PDFTools
« Reply #5 on: November 19, 2015, 12:19:12 AM »
>> Shouldn't there be a Report Target Tag here?

no, I don't think so. At least in Example 14 there's no difference to this.
The output target is set in the Extensions of the Report procedure, - two extensions in this case, the PDF-Tools Report Procedure Extension and hanging off that the NetTalk Extension to report procedure with PDF-XChange Generator 41.

On the PDF-Tools extension the File name is set as !loc:PDFname
On the "Previewer" tab there I have
Generate PDF: Yes Always
Show Gen PDF: No Never
Run Print Previewer : No Never
Print HardCopy : No Never

Cheers
Bruce