NetTalk Central

Author Topic: Saving a PDF file to disk using PDFTools (Revisited)  (Read 4224 times)

terryd

  • Hero Member
  • *****
  • Posts: 759
    • View Profile
    • Davcomm
    • Email
Saving a PDF file to disk using PDFTools (Revisited)
« on: November 25, 2015, 05:05:15 AM »
Attached is the Web14 ReportPrinting with PDFtools
All I have done is created a new menu Item called Print Test which calls the MailboxesReport which is normally called by Report\Options then Download Link.
I have placed a trace p_web._trace('loc:PDFName ' & CLIP(loc:PDFName)) in Prime Report Options when run in Web Mode
When I run Report\Options then Download Link the report is generated and I get a download link. The file nominated in loc:PDFName is in the report folder exactly as in loc:PDFName.
When I run exactly the same report from Print Test The generated PDF is displayed on the screen and even though loc:PDFName has a location and filename pointing to the report folder no file is generated in that folder at any time.

So my first question is:- What makes the MailboxesReport procedure create a $$$$nnnn.pdffile in the web\report folder ready to be downloaded when called from Report\Options then Download, but does not create a file in that folder when the report is called directly from a menu, or I assume , from a source procedure. Alternatively what do I do to the MailboxesReport so that it just creates the file in the report folder and then exits without displaying the pdf.

My reason for the question is that I want to create a source procedure which will loop though a table and for certain values in a field call a report procedure, limited to a unique recordGUID.
I then want to generate a report, take the created pdf in the web\report folder, copy it somewhere with a name allocated from within the report and then use pdftools to attach additional pages to the single page that the report generates.
I don't want to see the report I just need it to be created somewhere where I can access it.

I had this working with SoftVelocity ReportToPDF but I just can't get the file to just be saved.

[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: Saving a PDF file to disk using PDFTools (Revisited)
« Reply #1 on: November 26, 2015, 01:46:59 AM »
>> no file is generated in that folder at any time.

that's inaccurate. The file is written there, then served to the browser, then deleted. The lifetime of the file therefore is very very short.

It only deletes the file because it has the name starting with $$$, which is a special file, which is automatically deleted after saving.
If you want the file to persist change the name.

cheers
Bruce

terryd

  • Hero Member
  • *****
  • Posts: 759
    • View Profile
    • Davcomm
    • Email
Re: Saving a PDF file to disk using PDFTools (Revisited)
« Reply #2 on: November 26, 2015, 03:16:58 AM »
Hi Bruce
I actually had the web\report folder open on my desktop and there wasn't even a flash as it creates and removes the file.
However I added this code, removing the $$$, into Prime report Options when in Web Mode
    loc:URL = '\reports\' & format(random(1,99999),@n05) &'.pdf'
    loc:PDFName = clip(p_web.site.WebFolderPath) & loc:URL   
and a file is created in the folder.
However the report then also displays as a PDF in the Browser screen.
What settings in this report do I need to stop the report from displaying.
All I want to do is call the report get it to create a PDF file (which it is now doing)
and finish without displaying the generated report in the browser.

Should I bring this up in the Webinar tonight?
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: Saving a PDF file to disk using PDFTools (Revisited)
« Reply #3 on: November 27, 2015, 02:43:50 AM »
Hi Terry,

>> there wasn't even a flash as it creates and removes the file.

NetTalk - faster than a speeding Windows File Explorer.
Jokes aside, I wouldn't expect it to even flash. File Explorer doesn't update the window on that sort of time scale.

>> However the report then also displays as a PDF in the Browser screen.

Correct, the link you used specifically asked for it. ie the menu item specifically used the report procedure name.

So if you wanted to just generate the report then you would call it from code somewhere - maybe on a form button or something. You would call the report procedure as

whateverReport(p_web)

If you want it to "not send" the report then you would set ReplyCompleted before the call ie

p_web.ReplyCompleted = true
WhateverReport(p_web)

So ideally you send a response back to the user _before_ this.

If you want to send them a response _after_ this, and you're confident the report will be generated in a short period of time (ie say less than 25 seconds) then you could do

p_web.ReplyCompleted = true
WhateverReport(p_web)
p_web.ReplyCompleted = false


and continue.

cheers
Bruce


terryd

  • Hero Member
  • *****
  • Posts: 759
    • View Profile
    • Davcomm
    • Email
Re: Saving a PDF file to disk using PDFTools (Revisited)
« Reply #4 on: November 27, 2015, 02:58:58 AM »
Thanks Bruce.
I will work through this.
Terry Davidson
Windows 10 64 bit/Windows7 64bit
Clarion 9.1.11529/Clarion10 12567
Nettalk 913
Nettalk 1015
StringTheory267/Winevent515/XFiles298/MessageBox239/Cryptonite186