- this plugin provides some PDF functions. (preview, generate, export, convert from HTML)
Remark: I didn't use the minified version of this plugin because there's a conflict when SpiderBasic is in debug mode.
Code: Select all
Procedure CloseWindowEvent()
CloseWindow(EventWindow())
EndProcedure
Procedure ScriptLoaded()
DisableGadget(1,#False)
EndProcedure
Procedure LoadScript(script$, *func)
!$.getScript(v_script$,p_func);
EndProcedure
Procedure GadgetEvents()
Select EventGadget()
Case 1
;save PDF
Protected txt$=GetGadgetText(20)
!var doc = new jsPDF();
!doc.text(20, 20, v_txt$); //write text
!doc.setDrawColor(0);
!doc.setFillColor(255, 0, 0);
!doc.rect(100, 140, 10, 110, 'F'); // filled red square
!doc.setLineWidth(2);
!doc.line(20, 240, 60, 230); // line
!doc.addPage(); //add new page
!doc.setFontSize(24);
!doc.setFontType("italic");
!doc.setTextColor(0,255,0);
!doc.text(20, 20, 'jsPDF plugin');
!doc.save('Test.pdf');
Case 2
;convert HTML to PDF
EndSelect
EndProcedure
If OpenWindow(0, 100, 100, 300, 200, "PDF Generator powered by jsPDF")
EditorGadget(20, 5, 5, 280, 150)
SetGadgetText(20,"jsPDF"+#CRLF$+"Generate PDF files in client-side JavaScript.")
ButtonGadget(1, 5, 160, 190, 32, "Export")
DisableGadget(1,#True)
BindEvent(#PB_Event_Gadget, @GadgetEvents())
BindEvent(#PB_Event_CloseWindow, @CloseWindowEvent())
CompilerIf #PB_Compiler_OS <> #PB_OS_Web
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
CompilerEndIf
EndIf
LoadScript("https://rawgit.com/MrRio/jsPDF/master/dist/jspdf.debug.js",@ScriptLoaded()) ;loading plugin asynchronously...