Focal Point
[SOLVED] Open in PDF and print

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

October 10, 2008, 01:24 PM
Donald
[SOLVED] Open in PDF and print
I have a report in HTML that I would like to open in PDF for the user to print by clicking a print/pdf button. What am I missing in this cars database example to make that happen.


 -HTMLFORM BEGIN
<html>
<head>
<script>

function changeOutpdf(){
document.form1.WFFMT.value = 'PDF' ;
}
</script>
</head>
<body>
<form name="form1" target="_blank">

<input type=submit name="print" id="print" value="Print/Export PDF" style="background-color:aqua" onclick="javascript:changeOutpdf();">
</form>
</body>
</html>
-HTMLFORM END


TABLE FILE CAR
PRINT
     COUNTRY
     CAR
     MODEL

ON TABLE SET PAGE-NUM OFF
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT HTML
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
     UNITS=IN,
     LEFTMARGIN=0.250000,
     RIGHTMARGIN=0.250000,
     TOPMARGIN=0.250000,
     BOTTOMMARGIN=0.250000,
     SQUEEZE=ON,
     ORIENTATION=PORTRAIT,
$
TYPE=REPORT,
     FONT='ARIAL',
     SIZE=10,
     COLOR='BLACK',
     BACKCOLOR='NONE',
     STYLE=NORMAL,
     RIGHTGAP=0.125000,
$
TYPE=DATA,
     SIZE=8,
     BACKCOLOR=( RGB(234 234 255) 'WHITE' ),
$
TYPE=TITLE,
     BORDER-TOP=LIGHT,
     BORDER-BOTTOM=LIGHT,
     BORDER-LEFT=LIGHT,
     BORDER-RIGHT=LIGHT,
     BORDER-TOP-STYLE=RIDGE,
     BORDER-BOTTOM-STYLE=RIDGE,
     BORDER-LEFT-STYLE=RIDGE,
     BORDER-RIGHT-STYLE=RIDGE,
     BORDER-TOP-COLOR=RGB(51 51 153),
     BORDER-BOTTOM-COLOR=RGB(51 51 153),
     BORDER-LEFT-COLOR=RGB(51 51 153),
     BORDER-RIGHT-COLOR=RGB(51 51 153),
     SIZE=9,
     COLOR='WHITE',
     BACKCOLOR=RGB(147 172 219),
     STYLE=BOLD,
$
TYPE=TABHEADING,
     SIZE=9,
     STYLE=BOLD,
$
TYPE=TABFOOTING,
     SIZE=9,
     STYLE=BOLD,
$
TYPE=HEADING,
     BORDER-TOP=LIGHT,
     BORDER-BOTTOM=LIGHT,
     BORDER-LEFT=LIGHT,
     BORDER-RIGHT=LIGHT,
     BORDER-TOP-STYLE=RIDGE,
     BORDER-BOTTOM-STYLE=RIDGE,
     BORDER-LEFT-STYLE=RIDGE,
     BORDER-RIGHT-STYLE=RIDGE,
     BORDER-TOP-COLOR=RGB(51 51 153),
     BORDER-BOTTOM-COLOR=RGB(51 51 153),
     BORDER-LEFT-COLOR=RGB(51 51 153),
     BORDER-RIGHT-COLOR=RGB(51 51 153),
     SIZE=12,
     COLOR='WHITE',
     BACKCOLOR=RGB(147 172 219),
     STYLE=BOLD,
     JUSTIFY=CENTER,
$
TYPE=HEADING,
     LINE=1,
     SIZE=14,
$
TYPE=FOOTING,
     BORDER-TOP=LIGHT,
     BORDER-BOTTOM=LIGHT,
     BORDER-LEFT=LIGHT,
     BORDER-RIGHT=LIGHT,
     BORDER-TOP-STYLE=RIDGE,
     BORDER-BOTTOM-STYLE=RIDGE,
     BORDER-LEFT-STYLE=RIDGE,
     BORDER-RIGHT-STYLE=RIDGE,
     BORDER-TOP-COLOR=RGB(51 51 153),
     BORDER-BOTTOM-COLOR=RGB(51 51 153),
     BORDER-LEFT-COLOR=RGB(51 51 153),
     BORDER-RIGHT-COLOR=RGB(51 51 153),
     COLOR='WHITE',
     BACKCOLOR=RGB(147 172 219),
     STYLE=BOLD,
$
TYPE=SUBHEAD,
     SIZE=9,
     STYLE=BOLD,
$
TYPE=SUBFOOT,
     BORDER-TOP=LIGHT,
     BORDER-BOTTOM=LIGHT,
     BORDER-LEFT=LIGHT,
     BORDER-RIGHT=LIGHT,
     BORDER-TOP-STYLE=RIDGE,
     BORDER-BOTTOM-STYLE=RIDGE,
     BORDER-LEFT-STYLE=RIDGE,
     BORDER-RIGHT-STYLE=RIDGE,
     BORDER-TOP-COLOR=RGB(51 51 153),
     BORDER-BOTTOM-COLOR=RGB(51 51 153),
     BORDER-LEFT-COLOR=RGB(51 51 153),
     BORDER-RIGHT-COLOR=RGB(51 51 153),
     SIZE=9,
     COLOR='WHITE',
     BACKCOLOR=RGB(147 172 219),
     STYLE=BOLD,
$
TYPE=SUBTOTAL,
     SIZE=8,
     STYLE=BOLD,
$
TYPE=ACROSSVALUE,
     SIZE=8,
     STYLE=BOLD,
$
TYPE=ACROSSTITLE,
     SIZE=8,
     STYLE=BOLD,
$
TYPE=GRANDTOTAL,
     SIZE=9,
     STYLE=BOLD,
$
ENDSTYLE
END
 

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


Prod: WebFocus 7.7.3 Win 2003
Dev: WebFocus 7.7.3 Win 2003
October 10, 2008, 02:17 PM
Doug
Basically, you'd need to use PDF as your output format and do your print there (PDF) once the PDF is created. You could do this via a drilldown on the word "export", which could reside in the HEADING which would, in turn, would pass a value of 'PDF' to your format variable. I did this while at USDA.

PS: Thanks a meg for providing a sample using the CAR file.




   In FOCUS Since 1983 ~ from FOCUS to WebFOCUS.
   Current: WebFOCUS Administrator at FIS Worldpay | 8204, 8206
October 10, 2008, 02:52 PM
Darin Lee
You don't use the WFFMT variable you're modifying anywhere in your fex. You should probably have -DEFAULT &WFFMT='HTML' and then replace ON TABLE PCHOLD FORMAT HTML with ON TABLE PCHOLD FORMAT &WFFMT

Doug's approach of providing a drill link is how I usually provide the option for them to get the report in PDF format.


Regards,

Darin



In FOCUS since 1991
WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex
Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex
WF Client: 77 on Linux w/Tomcat
October 10, 2008, 04:04 PM
Donald
I was hoping that I could use javascript behind the scenes of my pdf button to run the fex and display in pdf format.


Prod: WebFocus 7.7.3 Win 2003
Dev: WebFocus 7.7.3 Win 2003
October 10, 2008, 04:36 PM
Darin Lee
Your PDF button can run your fex and generate in PDF format, but you need to dynamically change the output format using a variable. Your fex says ON TABLE PCHOLD FORMAT HTML so unless you change that to a variable you're never going to get PDF regardless of what your javascript does.

Additionally there are a bunch of other variables that need to be populated in your HTMLFORM that will be passed when your submit action is executed.

Your best solution lies in following what has already been suggested. Another option is to create a launch page that has a drop-down for the user to select the type of output they would like. This still requires the use of a variable in you fex and population of that variable via an HTML form.


Regards,

Darin



In FOCUS since 1991
WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex
Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex
WF Client: 77 on Linux w/Tomcat
October 10, 2008, 04:42 PM
Donald
Thanks Darin, I will use the suggestions from Doug..Just as I told you at Summit.."your a life saver"


Prod: WebFocus 7.7.3 Win 2003
Dev: WebFocus 7.7.3 Win 2003
October 10, 2008, 04:56 PM
Donald
If anyone would like to give an example using the cars database it would be highly appreciated.


Prod: WebFocus 7.7.3 Win 2003
Dev: WebFocus 7.7.3 Win 2003
October 13, 2008, 10:00 AM
Donald
When I click on export, my drill down output is still HTML

 -DEFAULT &WFFMT = HTML
TABLE FILE CAR
PRINT
     COUNTRY
     CAR
     MODEL
     BODYTYPE
HEADING
"EXPORT"
FOOTING
""
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT &WFFMT
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
     UNITS=IN,
     PAGESIZE='Letter',
     LEFTMARGIN=0.250000,
     RIGHTMARGIN=0.250000,
     TOPMARGIN=0.250000,
     BOTTOMMARGIN=0.250000,
     SQUEEZE=ON,
     ORIENTATION=PORTRAIT,
$
TYPE=REPORT,
     FONT='ARIAL',
     SIZE=10,
     COLOR='BLACK',
     BACKCOLOR='NONE',
     STYLE=NORMAL,
     RIGHTGAP=0.125000,
$
TYPE=DATA,
     SIZE=8,
     BACKCOLOR=( RGB(234 234 255) 'WHITE' ),
$
TYPE=TITLE,
     BORDER-TOP=LIGHT,
     BORDER-BOTTOM=LIGHT,
     BORDER-LEFT=LIGHT,
     BORDER-RIGHT=LIGHT,
     BORDER-TOP-STYLE=RIDGE,
     BORDER-BOTTOM-STYLE=RIDGE,
     BORDER-LEFT-STYLE=RIDGE,
     BORDER-RIGHT-STYLE=RIDGE,
     BORDER-TOP-COLOR=RGB(51 51 153),
     BORDER-BOTTOM-COLOR=RGB(51 51 153),
     BORDER-LEFT-COLOR=RGB(51 51 153),
     BORDER-RIGHT-COLOR=RGB(51 51 153),
     SIZE=9,
     COLOR='WHITE',
     BACKCOLOR=RGB(147 172 219),
     STYLE=BOLD,
$
TYPE=TABHEADING,
     SIZE=9,
     STYLE=BOLD,
$
TYPE=TABFOOTING,
     SIZE=9,
     STYLE=BOLD,
$
TYPE=HEADING,
     BORDER-TOP=LIGHT,
     BORDER-BOTTOM=LIGHT,
     BORDER-LEFT=LIGHT,
     BORDER-RIGHT=LIGHT,
     BORDER-TOP-STYLE=RIDGE,
     BORDER-BOTTOM-STYLE=RIDGE,
     BORDER-LEFT-STYLE=RIDGE,
     BORDER-RIGHT-STYLE=RIDGE,
     BORDER-TOP-COLOR=RGB(51 51 153),
     BORDER-BOTTOM-COLOR=RGB(51 51 153),
     BORDER-LEFT-COLOR=RGB(51 51 153),
     BORDER-RIGHT-COLOR=RGB(51 51 153),
     SIZE=12,
     COLOR='WHITE',
     BACKCOLOR=RGB(147 172 219),
     STYLE=BOLD,
     JUSTIFY=CENTER,
$
TYPE=HEADING,
     LINE=1,
     SIZE=14,
$
TYPE=HEADING,
     LINE=1,
     OBJECT=TEXT,
     ITEM=1,
     TARGET='_blank',
     FOCEXEC=newfex(WFFMT='PDF'),
$
TYPE=FOOTING,
     BORDER-TOP=LIGHT,
     BORDER-BOTTOM=LIGHT,
     BORDER-LEFT=LIGHT,
     BORDER-RIGHT=LIGHT,
     BORDER-TOP-STYLE=RIDGE,
     BORDER-BOTTOM-STYLE=RIDGE,
     BORDER-LEFT-STYLE=RIDGE,
     BORDER-RIGHT-STYLE=RIDGE,
     BORDER-TOP-COLOR=RGB(51 51 153),
     BORDER-BOTTOM-COLOR=RGB(51 51 153),
     BORDER-LEFT-COLOR=RGB(51 51 153),
     BORDER-RIGHT-COLOR=RGB(51 51 153),
     COLOR='WHITE',
     BACKCOLOR=RGB(147 172 219),
     STYLE=BOLD,
$
TYPE=SUBHEAD,
     SIZE=9,
     STYLE=BOLD,
$
TYPE=SUBFOOT,
     BORDER-TOP=LIGHT,
     BORDER-BOTTOM=LIGHT,
     BORDER-LEFT=LIGHT,
     BORDER-RIGHT=LIGHT,
     BORDER-TOP-STYLE=RIDGE,
     BORDER-BOTTOM-STYLE=RIDGE,
     BORDER-LEFT-STYLE=RIDGE,
     BORDER-RIGHT-STYLE=RIDGE,
     BORDER-TOP-COLOR=RGB(51 51 153),
     BORDER-BOTTOM-COLOR=RGB(51 51 153),
     BORDER-LEFT-COLOR=RGB(51 51 153),
     BORDER-RIGHT-COLOR=RGB(51 51 153),
     SIZE=9,
     COLOR='WHITE',
     BACKCOLOR=RGB(147 172 219),
     STYLE=BOLD,
$
TYPE=SUBTOTAL,
     SIZE=8,
     STYLE=BOLD,
$
TYPE=ACROSSVALUE,
     SIZE=8,
     STYLE=BOLD,
$
TYPE=ACROSSTITLE,
     SIZE=8,
     STYLE=BOLD,
$
TYPE=GRANDTOTAL,
     SIZE=9,
     STYLE=BOLD,
$
ENDSTYLE
END
 



Prod: WebFocus 7.7.3 Win 2003
Dev: WebFocus 7.7.3 Win 2003
October 14, 2008, 12:10 PM
GinnyJakes
ON TABLE PCHOLD FORMAT &WFFMT.(<HTML,HTML>,<PDF,PDF).Select type of display output.


Try this instead.


Ginny
---------------------------------
Prod: WF 7.7.01 Dev: WF 7.6.9-11
Admin, MRE,self-service; adapters: Teradata, DB2, Oracle, SQL Server, Essbase, ESRI, FlexEnable, Google
October 14, 2008, 12:24 PM
<JG>
quote:
FOCEXEC=newfex(WFFMT='PDF'),

Is newfex the name of the focexec that contains your code?

Works perfectly for me.
October 15, 2008, 02:22 PM
Donald
you are right JG,it works for me also now.

Thanks


Prod: WebFocus 7.7.3 Win 2003
Dev: WebFocus 7.7.3 Win 2003
October 16, 2008, 10:45 AM
Donald
OK,now I am concerned because the drill down to PDF seems to work when it wants to. If I run the cars database (displayed above) and click export it will open in PDF format. An hour or so later, if I run the same report and click export it will open itself in HTML format.Why the inconsistency?


Prod: WebFocus 7.7.3 Win 2003
Dev: WebFocus 7.7.3 Win 2003
October 20, 2008, 03:27 PM
Mighty Max
I tried it and it worked just like JG said.

Are you making the fex drill onto itself?
If so try having a seperate fex to drilldown on.

Here the syntax for for a drilldown you might want to play with type and subtype.
TYPE=type, [subtype], FOCEXEC=fex[(parameters ...)], [TARGET=frame,] $


WebFOCUS 8.1.05M Unix Self-Service/MRE/Report Caster - Outputs Excel, PDF, HTML, Flat Files