Focal Point
HTML Output to PDF

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

June 27, 2013, 03:39 PM
Todd Jones
HTML Output to PDF
I'm trying to take my output of looped html and convert into pdf. Please note the line above "HTMLFORM BEGIN" in the code below.


Code:
-*
-SET &MAX_RUN = 3;
-SET &NUMRECS = 0;
-*
-SET &I = 0;
-*
-STARTLOOP
-*
-SET &I = &I + 1;
-*
-IF &I EQ &MAX_RUN GOTO ENDLOOP;
-*
-TYPE &I.A17.
-*
-*-IF &I LT &NUMRECS GOTO STARTLOOP;
-*
-ENDLOOP
-*
-******************************************************************
-******************************************************************
-******************************************************************
-*
-SKP_LOOPING
-*
-* START CODE HERE
DEFINE FILE HIERARCHY
FNAME/A5 = IF &I EQ 1 THEN 'TODD' ELSE IF &I EQ 2 THEN 'MIKE' ELSE 'JOHN';
LNAME/A5 = IF &I EQ 1 THEN 'JONES' ELSE IF &I EQ 2 THEN 'SMITH' ELSE 'DOE';
END
TABLE FILE HIERARCHY
PRINT
FNAME
LNAME
BY DIVISION NOPRINT
WHERE RECORDLIMIT EQ 1;
ON TABLE HOLD AS NAME FORMAT ALPHA
END
-RUN
-READ NAME &FNAME.A5. &LNAME.A5.
-TYPE &FNAME &LNAME
-*
-HTMLFORM BEGIN
-*
-* THIS IS TEST HTML THE REAL CODE IS ABOUT 250 LINES OF HTML CODE
-*
<table border="1">
 <tr>
 <td>!IBI.AMP.LNAME;, !IBI.AMP.FNAME;</td>
 </tr>
 </table> 

-*
-HTMLFORM END
-*
-******************************************************************
-******************************************************************
-******************************************************************
-*
-IF &I LT &MAX_RUN GOTO STARTLOOP;
-*
-*
-ENDLOOP
-TYPE Total Runs: &I
-*
-*
-* Convert to PDF code here!


7.6.8
UNIX
FOCUS,HTML,PDF,EXCEL.
July 03, 2013, 12:20 AM
Ram Prasad E
Hi,

Need more clarity on problem/issue in your post.

Thanks,
Ram


WebFOCUS 8.1.05
Windows
http://ibiwebfocus.wordpress.com
https://www.facebook.com/groups/ibi.webfocus/
July 08, 2013, 10:58 AM
JL
I don't think that there is a way to convert your HTML output into PDF easily unless you are looking at using a third party converter program something like CutePDF to print the HTML page into a PDF document. I usually would not use the HTMLFORM technique to generate the report if output formats besides HTML are required. Is there any special reason why this technique is used?

It looks like your program is looping through a program at most 3 times to pull and display data line by line. Could you please describe what your program does in more detail? What do you have in the 250 lines of your html code besides the display of the data? Do you have headers/subheaders or are they styling code?

Basically if you could condense your 250 lines of html code into using a TABLE FILE ... END, then you could say something like:
-SET &TBL_OUTPUT_FORMAT = IF &WFFMT EQ HTML THEN 'ON TABLE HOLD AS NAME FORMAT ALPHA' ELSE IF &WFFMT EQ PDF THEN (IF &I EQ 1 THEN 'ON TABLE PCHOLD FORMAT PDF OPEN NOBREAK' ELSE IF &I EQ &MAX_RUN THEN 'ON TABLE PCHOLD FORMAT PDF CLOSE' ELSE 'ON TABLE PCHOLD FORMAT PDF NOBREAK');

TABLE FILE HIERARCHY
...
&TBL_OUTPUT_FORMAT
END



Sorry for the many questions without any solution but the extra details could help generate more suggestions.


Year(s) of experience in WebFOCUS: 5+. Using WebFOCUS 7.7.03 on Windows platform with Oracle/SQL Server.