Focal Point
[Only Mostly Solved] Archive PDF file to disk, then send to browser?

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/1147083076

April 29, 2014, 12:27 PM
John_Edwards
[Only Mostly Solved] Archive PDF file to disk, then send to browser?
I have an existing system that pounds out thousands of letters with unique materials in them, and a new requirement has come to light to create an archive on a drive at the same time it is returned to the user. I'm trying to figure out if there's a good way to retrofit what we have here. More or less this is what I'm trying to do:

TABLE FILE CAR
PRINT *
ON TABLE PCHOLD FORMAT PDF
ON TABLE HOLD FORMAT PDF AS ARCHIVE
END

I have a filedef for ARCHIVE and can get it to write to the drive, and I can get it to return to the client. The problem is that I can't get it to do both. It only does the second one it finds. I don't want to rewrite all of the calls to double-call the base report, so I'm trying to find a creative way to get both.

I'm on a two-tier so the idea of just rerouting the url to a folder where it can be returned the old-fashioned way is a bit harder than it needs to be.

Does anyone know of a sneaky way to get it to route to two destinations?

I've tried dropping the result into the approot and addressing it like this --

/ibi_apps/approot/madap_letters/vpdoc.pdf


. . . but I get this in return: "The requested resource (/ibi_apps/approot/madap_letters/vpdoc.pdf) is not available."

J.

This message has been edited. Last edited by: John_Edwards,



April 29, 2014, 01:37 PM
Francis Mariani
How about using edaget:

-SET &ECHO = 'ALL';

-*-- Set up the file name ----------------------------------
-SET &FILE_NAME = &YYMD || '_' || EDIT(&TOD,'99$99$99') || '_output01.pdf';

FILEDEF OUTPUT01 DISK baseapp/&FILE_NAME
-RUN

-*-- Create the report -------------------------------------
TABLE FILE CAR
SUM SALES
BY COUNTRY
BY CAR
ON TABLE HOLD AS OUTPUT01 FORMAT PDF
END
-RUN

-*-- Display the report ------------------------------------
EX EDAGET PDF,baseapp/&FILE_NAME,B
-RUN



Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
April 29, 2014, 02:38 PM
John_Edwards
Ladies and Gentlemen, it appears I owe Mr. Mariani yet another beer. I believe I'm one shy of a six-pack.

I have never even heard of EDAGET until now. That is one seriously useful program right there.

[SOLVED]



April 29, 2014, 03:35 PM
Francis Mariani
Another Guinness please.




Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
April 30, 2014, 06:21 AM
pradhan_dp
Excellent tip Francis!
Good One


WebFOCUS 7.6.1
Windows, HTML,PDF,EXCEL2000
April 16, 2015, 11:54 AM
John_Edwards
Alright, so this is more or less in, but I'm having a problem with big files, anything exceeding seven pages. My pdf gets cropped on the disk. I tried adding an LRECL to the Filedef but it didn't make a difference.

FILEDEF VPDOC DISK &ARCHPATH&FILE_NAME.pdf (LRECL 100000000

So it appears I'm hitting a hard limit on my size. Does this make any sense?



April 16, 2015, 12:40 PM
Francis Mariani
Uh oh.

The LRECL won't help, it has nothing to do with the file size - it might affect the single record size of a text file.

Unfortunately, WebFOCUS generates unnecessarily large PDF and Excel files.
According to dhagen in this post from 2013, EDAGET is a "high performance" way to move files, so it's surprising it cannot copy a seven page pdf file.

Here is another method of doing this, using meta refresh. This will only work if the reporting server and web server are on the same machine. It will also work if the web server can reference a folder on the reporting server. (I'm not sure what will happen if the file is large).

-SET &ECHO = 'ALL';

-*-- Set up the file name ----------------------------------
-SET &FILE_NAME = &YYMD || '_' || EDIT(&TOD,'99$99$99') || '_output01.pdf';

FILEDEF OUTPUT01 DISK baseapp/&FILE_NAME
-RUN

-*-- Create the report -------------------------------------
TABLE FILE CAR
SUM SALES
BY COUNTRY
BY CAR
ON TABLE HOLD AS OUTPUT01 FORMAT PDF
END
-RUN

-*-- Display the report ------------------------------------
-HTMLFORM BEGIN
<HTML>
<HEAD>
<meta http-equiv="refresh" content="0; url=/approot/baseapp/!IBI.AMP.FILE_NAME;">
</HEAD>
</HTML>
-HTMLFORM END




Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
April 16, 2015, 12:50 PM
John_Edwards
I just confirmed that it is creating the complete file on the disk. And they're not too big -- 500k for some.

So, either EDAGET is not up to the task, or the pdf is not completing its save prior to EDAGET coming to grab it. Need to figure out which.



April 16, 2015, 02:05 PM
John_Edwards
EDAGET can't seem to handle files much above 200K. It truncates what remains.

Wish I had figured that out ahead of time.



April 16, 2015, 02:17 PM
Francis Mariani
No Guinness for me then.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
April 16, 2015, 03:23 PM
Francis Mariani
Using this text fex, I had no problem with EDAGET, it created a pdf with file size of 1,013 KB.

-SET &ECHO = 'ALL';

-*-- Set up the file name ----------------------------------
-SET &FILE_NAME = &YYMD || '_' || EDIT(&TOD,'99$99$99') || '_output01.pdf';

FILEDEF OUTPUT01 DISK baseapp/&FILE_NAME
-RUN

-*-- Create the report -------------------------------------
TABLE FILE CAR
PRINT *
ON TABLE HOLD AS OUTPUT01 FORMAT PDF
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
END
-RUN

-*-- Display the report ------------------------------------
-HTMLFORM BEGIN
<HTML>
<HEAD>
<meta http-equiv="refresh" content="0; url=/approot/baseapp/!IBI.AMP.FILE_NAME;">
</HEAD>
</HTML>
-HTMLFORM END



Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
April 16, 2015, 04:10 PM
John_Edwards
Using EDAGET, or the url redirect? You're showing a url redirect.

My reporting server is behind a firewall.



April 16, 2015, 06:50 PM
Francis Mariani
Sorry about that. This one works. It creates a file of 1,269kb. I tried to use EDAGET with a pre-existing pdf file (I used one of the WebFOCUS documentation files and I get an error: "The file is damaged and could not be repaired".



-SET &ECHO = 'ALL';
 
-*-- Set up the file name ----------------------------------
-SET &FILE_NAME = &YYMD || '_' || EDIT(&TOD,'99$99$99') || '_output01.pdf';
 
FILEDEF OUTPUT01 DISK test/&FILE_NAME
-RUN
 
-*-- Create the report -------------------------------------
TABLE FILE CAR
PRINT *
ON TABLE HOLD AS OUTPUT01 FORMAT PDF
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
END
-RUN
 
-*-- Display the report ------------------------------------
EX EDAGET PDF,test/&FILE_NAME,B
-RUN



Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
April 17, 2015, 09:00 AM
John_Edwards
Not exactly sure how to interpret what you wrote above, but the example you just provided with EDAGET produces the same error I'm seeing here, a partial pdf that throws an error when you get down a few pages. It appears to simply not be a complete pdf file. It appears EDAGET simply can't get a file much bigger than 200k.

That's a shame.

J.



April 17, 2015, 10:36 AM
Francis Mariani
Sorry for the confusing comment. All the code I added to this thread works on my local PC and also on our server. I should have stated that I ALSO tried to use EDAGET with the pre-existing file. Perhaps there's an issue with the web server.

Have you tried running a test on your localhost - the local environment accessible via Developer Studio?


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server