code
Member in Training
Posts: 74
|
Post by code on Oct 14, 2021 6:17:30 GMT
Hi, The program makes the directory : C:\ugly_pdf_test\ The file test.pdf is written in that directory It can be byggy .... take a look: (code is free to use/modify/spread)
nomainwin
WindowWidth=800
WindowHeight=600
button #scr, "Make ugly pdf and run... ", [b1], UL, 550, 500
button #scr, "Down...", [bleft], UL, 100, 10
button #scr, "Up...", [bu], UL, 200, 10
button #scr, "Add page...", [badd], UL, 550, 100
TEXTBOX #scr.tb, 610, 20, 160, 50
TEXTBOX #scr.tp, 450, 20, 160, 50
texteditor #scr.te, 10, 40, 600, 450
pn=1
total=1
dim ct$(9000)
ct$(1)="Page1"
result = mkdir( "C:\ugly_pdf_test")
open "Ugly pdf..." for graphics_nsb as #scr
print #scr.te, "";ct$(1);
print #scr.tb ,"Total pages : ";total;
print #scr.tp ,"Page : ";pn;
ct$(total)="Page";total;"@x@"
print #scr, "fill darkred"
print #scr, "flush"
wait
[badd]
emp$=""
rd$=""
print #scr.te, "!lines cl" ;
for i = 1 to cl step 1
print #scr.te, "!line ";i;" linete$" ;
rd$=rd$;linete$;"@x@"
''notice rd$
next i
ct$(pn)=rd$
print #scr.te, "!contents emp$";
total=total+1
ct$(total)="Page";total;"@x@"
print #scr.te, "Page";total;
print #scr.tp ,"Page : ";total;
pn=total
print #scr.tb ,"Total pages : ";pn;
wait
[bleft]
emp$=""
rd$=""
print #scr.te, "!lines cl" ;
for i = 1 to cl step 1
print #scr.te, "!line ";i;" linete$" ;
rd$=rd$;linete$;"@x@"
''notice rd$
next i
ct$(pn)=rd$
if pn <= total and pn >1 then
print #scr.te, "!contents emp$";
pn=pn-1
print #scr.tp ,"Page : ";pn;
ls=len(ct$(pn))
lp=0
''notice ls
for i = 1 to ls step 1
one$=""
''notice instr(ct$(pn), "@qx")
one$=mid$(ct$(pn), i, 1)
two$=mid$(ct$(pn), i+1, 1)
three$=mid$(ct$(pn), i+2, 1)
if one$="@" and two$="x" and three$="@" then
''notice "yep";mid$(ct$(pn), lp, i-lp)
print #scr.te, "";mid$(ct$(pn), lp, i-lp)
lp=i+3
end if
next i
end if
''print #scr.te, "!contents? ct$(pn)";
''notice ct$(pn)
wait
[bu]
emp$=""
rd$=""
print #scr.te, "!lines cl" ;
for i = 1 to cl step 1
print #scr.te, "!line ";i;" linete$" ;
rd$=rd$;linete$;"@x@"
''notice rd$
next i
ct$(pn)=rd$
if pn < total and total > 1 then
print #scr.te, "!contents emp$";
''notice ""
pn=pn+1
''print #scr.tp ,"Page : ";pn;
print #scr.tp ,"Page : ";pn;
ls=len(ct$(pn))
lp=0
''notice ls
for i = 1 to ls step 1
one$=""
''notice instr(ct$(pn), "@qx")
one$=mid$(ct$(pn), i, 1)
two$=mid$(ct$(pn), i+1, 1)
three$=mid$(ct$(pn), i+2, 1)
if one$="@" and two$="x" and three$="@" then
''notice "yep";mid$(ct$(pn), lp, i-lp)
print #scr.te, "";mid$(ct$(pn), lp, i-lp)
lp=i+3
end if
next i
end if
''print #scr.te, "!contents? ct$(pn)";
''notice ct$(pn)
wait
[b1]
emp$=""
rd$=""
print #scr.te, "!lines cl" ;
for i = 1 to cl step 1
print #scr.te, "!line ";i;" linete$" ;
rd$=rd$;linete$;"@x@"
''notice rd$
next i
ct$(pn)=rd$
open "c:\ugly_pdf_test\test.pdf" for output as #tf
print #tf,"%PDF-1.3"
print #tf,"%âãÏÓ"
print #tf,""
print #tf,"1 0 obj"
print #tf,"<<"
print #tf,"/Type /Catalog"
print #tf,"/Outlines 2 0 R"
print #tf,"/Pages 3 0 R"
print #tf,">>"
print #tf,"endobj"
print #tf,""
print #tf,"2 0 obj"
print #tf,"<<"
print #tf,"/Type /Outlines"
print #tf,"/Count 0"
print #tf,">>"
print #tf,"endobj"
print #tf,""
print #tf,"3 0 obj"
print #tf,"<<"
print #tf,"/Type /Pages"
print #tf,"/Count ";total;""
st$=""
for a=1 to total step 1
i=a*10
st$=st$;i;" 0 R "
next
print #tf,"/Kids [ ";st$;" ]"
print #tf,">>"
print #tf,"endobj"
print #tf,""
for a3=1 to total step 1
i2=a3*10
print #tf,"";i2;" 0 obj"
print #tf,"<<"
print #tf,"/Type /Page"
print #tf,"/Parent 3 0 R"
print #tf,"/Resources <<"
print #tf,"/Font <<"
print #tf,"/F1 9 0 R "
print #tf,">>"
print #tf,"/ProcSet 8 0 R"
print #tf,">>"
print #tf,"/MediaBox [0 0 600 700]"
print #tf,"/Contents ";i2+1;" 0 R"
print #tf,">>"
print #tf,"endobj"
print #tf,"";i2+1;" 0 obj"
print #tf,"<</Length 1000>>"
print #tf,"stream"
print #tf,"2j "
print #tf,"BT"
print #tf,"0 0 0 rg"
print #tf,"/F1 0020 Tf"
print #tf,"50 560 Td"
print #tf,"40 TL"
print #tf,"() Tj T*"
ls=len(ct$(a3))
lp=0
for i = 1 to ls step 1
one$=""
one$=mid$(ct$(a3), i, 1)
two$=mid$(ct$(a3), i+1, 1)
three$=mid$(ct$(a3), i+2, 1)
if one$="@" and two$="x" and three$="@" then
print #tf,"2 Tr"
print #tf,"(";mid$(ct$(a3), lp, i-lp);") Tj T*"
lp=i+3
end if
next i
print #tf,"endstream"
print #tf,"endobj"
print #tf,""
next
print #tf,""
print #tf,"8 0 obj"
print #tf,"[/PDF /Text]"
print #tf,"endobj"
print #tf,""
print #tf,"9 0 obj"
print #tf,"<<"
print #tf,"/Type /Font"
print #tf,"/Subtype /Type1"
print #tf,"/Name /F1"
print #tf,"/BaseFont /Arial"
print #tf,"/Encoding /WinAnsiEncoding"
print #tf,">>"
print #tf,"endobj"
print #tf,""
print #tf,"trailer"
print #tf,"<<"
print #tf,"/Size 80"
print #tf,"/Root 1 0 R"
print #tf,">>"
print #tf,""
print #tf,"startxref"
print #tf,"4000"
print #tf,"%%EOF"
close #tf
b$ = "C:\ugly_pdf_test\test.pdf"
RUN "rundll32.exe url.dll,FileProtocolHandler ";b$
wait
|
|
|
Post by Rod on Oct 14, 2021 8:33:30 GMT
I had a go at formatting the code to make it a little easier to understand. I see there have been changes or edits so Code will need to check if this code runs ok. I have not tried the code, I am on a new PC and want to keep things really clean right now.
nomainwin WindowWidth=800 WindowHeight=600 button #scr, "Make ugly pdf and run... ", [b1], UL, 550, 500 button #scr, "Down...", [bleft], UL, 100, 10 button #scr, "Up...", [bu], UL, 200, 10 button #scr, "Add page...", [badd], UL, 550, 100 TEXTBOX #scr.tb, 610, 20, 160, 50 TEXTBOX #scr.tp, 450, 20, 160, 50 texteditor #scr.te, 10, 40, 600, 450
pn=1 total=1 dim ct$(9000) ct$(1)="Page1" result = mkdir( "C:\ugly_pdf_test") open "Ugly pdf..." for graphics_nsb as #scr
#scr.te "";ct$(1); #scr.tb "Total pages : ";total; #scr.tp "Page : ";pn; ct$(total)="Page";total;"@x@" #scr "fill darkred" #scr "flush" wait
[badd] emp$="" rd$="" #scr.te "!lines cl" ; for i = 1 to cl step 1 #scr.te "!line ";i;" linete$" ; rd$=rd$;linete$;"@x@" ''notice rd$ next i ct$(pn)=rd$ #scr.te "!contents emp$"; total=total+1 ct$(total)="Page";total;"@x@" #scr.te "Page";total; #scr.tp "Page : ";total; pn=total #scr.tb "Total pages : ";pn; wait
[bleft] emp$="" rd$="" #scr.te "!lines cl" ; for i = 1 to cl step 1 #scr.te "!line ";i;" linete$" ; rd$=rd$;linete$;"@x@" ''notice rd$ next i ct$(pn)=rd$
if pn <= total and pn >1 then #scr.te "!contents emp$"; pn=pn-1 #scr.tp "Page : ";pn; ls=len(ct$(pn)) lp=0 ''notice ls for i = 1 to ls step 1 one$="" ''notice instr(ct$(pn), "@qx") one$=mid$(ct$(pn), i, 1) two$=mid$(ct$(pn), i+1, 1) three$=mid$(ct$(pn), i+2, 1) if one$="@" and two$="x" and three$="@" then ''notice "yep";mid$(ct$(pn), lp, i-lp) #scr.te "";mid$(ct$(pn), lp, i-lp) lp=i+3 end if next i end if
''print #scr.te, "!contents? ct$(pn)"; ''notice ct$(pn) wait
[bu] emp$="" rd$="" #scr.te "!lines cl" ; for i = 1 to cl step 1 #scr.te "!line ";i;" linete$" ; rd$=rd$;linete$;"@x@" ''notice rd$ next i ct$(pn)=rd$ if pn < total and total > 1 then #scr.te "!contents emp$"; ''notice "" pn=pn+1 ''print #scr.tp ,"Page : ";pn; #scr.tp "Page : ";pn; ls=len(ct$(pn)) lp=0 ''notice ls for i = 1 to ls step 1 one$="" ''notice instr(ct$(pn), "@qx") one$=mid$(ct$(pn), i, 1) two$=mid$(ct$(pn), i+1, 1) three$=mid$(ct$(pn), i+2, 1) if one$="@" and two$="x" and three$="@" then ''notice "yep";mid$(ct$(pn), lp, i-lp) #scr.te "";mid$(ct$(pn), lp, i-lp) lp=i+3 end if next i end if ''print #scr.te, "!contents? ct$(pn)"; ''notice ct$(pn) wait
[b1] emp$="" rd$="" #scr.te "!lines cl" ; for i = 1 to cl step 1 #scr.te "!line ";i;" linete$" ; rd$=rd$;linete$;"@x@" ''notice rd$ next i ct$(pn)=rd$ open "c:\ugly_pdf_test\test.pdf" for output as #tf #tf"%PDF-1.3" #tf "%âãÏÓ" #tf "" #tf "1 0 obj" #tf "<<" #tf "/Type /Catalog" #tf "/Outlines 2 0 R" #tf "/Pages 3 0 R" #tf ">>" #tf "endobj" #tf "" #tf "2 0 obj" #tf "<<" #tf "/Type /Outlines" #tf "/Count 0" #tf ">>" #tf "endobj" #tf "" #tf "3 0 obj" #tf "<<" #tf "/Type /Pages" #tf "/Count ";total;"" st$="" for a=1 to total step 1 i=a*10 st$=st$;i;" 0 R " next #tf "/Kids [ ";st$;" ]" #tf ">>" #tf "endobj" #tf "" for a3=1 to total step 1 i2=a3*10 #tf "";i2;" 0 obj" #tf "<<" #tf "/Type /Page" #tf "/Parent 3 0 R" #tf "/Resources <<" #tf "/Font <<" #tf "/F1 9 0 R " #tf ">>" #tf "/ProcSet 8 0 R" #tf ">>" #tf "/MediaBox [0 0 600 700]" #tf "/Contents ";i2+1;" 0 R" #tf ">>" #tf "endobj" #tf "";i2+1;" 0 obj" #tf "<</Length 1000>>" #tf "stream" #tf "2j " #tf "BT" #tf "0 0 0 rg" #tf "/F1 0020 Tf" #tf "50 560 Td" #tf "40 TL" #tf "() Tj T*" ls=len(ct$(a3)) lp=0 for i = 1 to ls step 1 one$="" one$=mid$(ct$(a3), i, 1) two$=mid$(ct$(a3), i+1, 1) three$=mid$(ct$(a3), i+2, 1) if one$="@" and two$="x" and three$="@" then #tf "2 Tr" #tf "(";mid$(ct$(a3), lp, i-lp);") Tj T*" lp=i+3 end if next i #tf "endstream" #tf "endobj" #tf "" next
#tf "" #tf "8 0 obj" #tf "[/PDF /Text]" #tf "endobj" #tf "" #tf "9 0 obj" #tf "<<" #tf "/Type /Font" #tf "/Subtype /Type1" #tf "/Name /F1" #tf "/BaseFont /Arial" #tf "/Encoding /WinAnsiEncoding" #tf ">>" #tf "endobj" #tf "" #tf "trailer" #tf "<<" #tf "/Size 80" #tf "/Root 1 0 R" #tf ">>" #tf "" #tf "startxref" #tf "4000" #tf "%%EOF" close #tf b$ = "C:\ugly_pdf_test\test.pdf" RUN "rundll32.exe url.dll,FileProtocolHandler ";b$ wait
|
|
|
Post by tenochtitlanuk on Oct 14, 2021 9:02:57 GMT
It's interesting to create pdf output line by line but easier to do it direct. Set your printer DEFAULT choice to print to pdf and any program drawing in a graphic window 'graphicWindow" of width 'x' can be turned into a pdf with a line..
'#graphicWindow, x' This creates a pdf file where the original graphic window fills the paper horizontally. Using '#graphicWindow, 2000' would scale it down as the paper width is then 2000. Just one line to add to ANY program in JB/LB that outputs to a graphic window. I work under Linux, but also W10. Works fine in both. No extras to install.
Try the code below... just one line added to code from my original LB website 15 years ago! Look a few lines up from the end.
's.graph8.bas
nomainwin
WindowWidth = 600 WindowHeight = 600 UpperLeftX = int((DisplayWidth - WindowWidth) /2) UpperLeftY = int((DisplayHeight - WindowHeight)/2)
button #graph.b1, "Exit", [exit], LR, 35, 20 button #graph.b2, "Log", [type], LR, 85, 20 button #graph.b3, "Start", [do.it], LR, 300, 20 button #graph.b3, "Store Image", [save.image], LR, 205, 20
open "Spiral" for graphics as #graph
#graph "trapclose [exit]" #graph "horizscrollbar off;vertscrollbar off" #graph "down" #graph "home" #graph "posxy CenterX CenterY" #graph "place "; CenterX; " "; CenterY / 2
t =1
wait
[do.it] r =1 i =0 t =0
spur.number =1 +int( 5 *rnd(1))
pi =3.14159265 incr =rnd( 1) /3 mult =1 +rnd( 1) /3000 theta.inc =rnd( 1) /100 k =1 +5 *rnd(1)
#graph "cls ; fill "; int( 255 *rnd( 1)); " "; int(255 *rnd( 1)); " "; int( 255 *rnd( 1))
while r <300*2^0.5 i =i +1 scan #graph, "size "; int( 2 +r/ k)' growth of 'blob'
if t =0 then r =r +incr else r =r *mult end if
r0 =min( r, 255) theta =theta +theta.inc
select case spur.number case 1 #graph "color 255 "; int( r0); " "; int( r0) x1 =CenterX +r *cos( theta) y1 =CenterY +r *sin( theta) #graph "set "; x1; " "; y1 case 2 #graph "color "; int( r0); " "; int( r0); " 255" x1 =CenterX +r *cos( theta) y1 =CenterY +r *sin( theta) #graph "set "; x1; " "; y1 x1 =CenterX +r *cos( theta +pi *2 /2) y1 =CenterY +r *sin( theta +pi *2 /2) #graph "set "; x1; " "; y1 case 3 #graph "color "; int( r0); " 255 "; int( r0) x1 =CenterX +r *cos( theta) y1 =CenterY +r *sin( theta) #graph "set "; x1; " "; y1 x1 =CenterX +r *cos( theta +pi *2 /3) y1 =CenterY +r *sin( theta +pi *2 /3) #graph "set "; x1; " "; y1 x1 =CenterX +r *cos( theta +2 *pi *2 /3) y1 =CenterY +r *sin( theta +2 *pi *2 /3) #graph "set "; x1; " "; y1 case 4 #graph "color "; int( r0); " "; int( r0); " "; int( r0) x1 =CenterX +r *cos( theta) y1 =CenterY +r *sin( theta) #graph " set "; x1; " "; y1 x1 =CenterX +r *cos( theta +pi *2 /4) y1 =CenterY +r *sin( theta +pi *2 /4) #graph " set "; x1; " "; y1 x1 =CenterX +r *cos( theta +2 *pi *2 /4) y1 =CenterY +r *sin( theta +2 *pi *2 /4) #graph " set "; x1; " "; y1 x1 =CenterX +r *cos( theta +3 *pi *2 /4) y1 =CenterY +r *sin( theta +3 *pi *2 /4) #graph " set "; x1; " "; y1 case 5 #graph "color "; int( r0); " 0 "; int( r0) x1 =CenterX +r *cos( theta) y1 =CenterY +r *sin( theta) #graph "set "; x1; " "; y1 x1 =CenterX +r *cos( theta +1 *pi *2 /5) y1 =CenterY +r *sin( theta +1 *pi *2 /5) #graph " set "; x1; " "; y1 x1 =CenterX +r *cos( theta +2 *pi *2 /5) y1 =CenterY +r *sin( theta +2 *pi *2 /5) #graph "set "; x1; " "; y1 x1 =CenterX +r *cos( theta +3 *pi *2 /5) y1 =CenterY +r *sin( theta +3 *pi *2 /5) #graph "set "; x1; " "; y1 x1 =CenterX +r *cos( theta +4 *pi *2 /5) y1 =CenterY +r *sin( theta +4 *pi *2 /5) #graph "set "; x1; " "; y1 end select
wend
wait
[type] if t =0 then t =1 #graph.b2, "Log" else t =0 #graph.b2, "Lin" end if wait
[exit] close #graph end
[save.image] #graph "flush"
#graph "print 1000"
#graph, "getbmp drawing 1 1 500 500" bmpsave "drawing", "spiral" +str$( int( 100000 *rnd( 1))) +".bmp" wait
|
|
|
Post by Rod on Oct 14, 2021 12:55:29 GMT
I have been using the same technique to save help files as .pdf They can then be opened with the default browser to create a neat help system.
|
|
|
Post by xxgeek on Oct 14, 2021 15:23:50 GMT
Nice work code.
Thanks for sharing. I took them liberty of using your original code and fixed up the window to fit my 1360x768 screen.
Any tips on how to make an "html viewer", that can also have pictures displayed?
'written by code at the jb forums nomainwin WindowWidth=800 WindowHeight=700 button #scr, "Make ugly pdf and run", [b1], UL, 290, 580, 180, 40 button #scr, "Down", [bleft], UL, 195, 20, 70, 40 button #scr, "Up", [bu], UL, 110, 20, 70, 40 button #scr, "Add page", [badd], UL, 675, 170, 90, 50 TEXTBOX #scr.tb, 460, 20, 140, 40 TEXTBOX #scr.tp, 320, 20, 110, 40 texteditor #scr.te, 80, 70, 580, 490 pn=1 total=1 dim ct$(9000) ct$(1)="Page1" result = mkdir( "C:\ugly_pdf_test") open "Ugly pdf..." for graphics_nsb as #scr #scr, "backcolor blue" #scr.te "";ct$(1); #scr.tb "Total pages : ";total; #scr.tp "Page : ";pn; ct$(total)="Page";total;"@x@" #scr "fill darkred" #scr "flush" wait [badd] emp$="" rd$="" #scr.te "!lines cl" ; for i = 1 to cl step 1 #scr.te "!line ";i;" linete$" ; rd$=rd$;linete$;"@x@" ''notice rd$ next i ct$(pn)=rd$ #scr.te "!contents emp$"; total=total+1 ct$(total)="Page";total;"@x@" #scr.te "Page";total; #scr.tp "Page : ";total; pn=total #scr.tb "Total pages : ";pn; wait [bleft] emp$="" rd$="" #scr.te "!lines cl" ; for i = 1 to cl step 1 #scr.te "!line ";i;" linete$" ; rd$=rd$;linete$;"@x@" ''notice rd$ next i ct$(pn)=rd$ if pn <= total and pn >1 then #scr.te "!contents emp$"; pn=pn-1 #scr.tp "Page : ";pn; ls=len(ct$(pn)) lp=0 ''notice ls for i = 1 to ls step 1 one$="" ''notice instr(ct$(pn), "@qx") one$=mid$(ct$(pn), i, 1) two$=mid$(ct$(pn), i+1, 1) three$=mid$(ct$(pn), i+2, 1) if one$="@" and two$="x" and three$="@" then ''notice "yep";mid$(ct$(pn), lp, i-lp) #scr.te "";mid$(ct$(pn), lp, i-lp) lp=i+3 end if next i end if ''print #scr.te, "!contents? ct$(pn)"; ''notice ct$(pn) wait [bu] emp$="" rd$="" #scr.te "!lines cl" ; for i = 1 to cl step 1 #scr.te "!line ";i;" linete$" ; rd$=rd$;linete$;"@x@" ''notice rd$ next i ct$(pn)=rd$ if pn < total and total > 1 then #scr.te "!contents emp$"; ''notice "" pn=pn+1 ''print #scr.tp ,"Page : ";pn; #scr.tp "Page : ";pn; ls=len(ct$(pn)) lp=0 ''notice ls for i = 1 to ls step 1 one$="" ''notice instr(ct$(pn), "@qx") one$=mid$(ct$(pn), i, 1) two$=mid$(ct$(pn), i+1, 1) three$=mid$(ct$(pn), i+2, 1) if one$="@" and two$="x" and three$="@" then ''notice "yep";mid$(ct$(pn), lp, i-lp) #scr.te "";mid$(ct$(pn), lp, i-lp) lp=i+3 end if next i end if ''print #scr.te, "!contents? ct$(pn)"; ''notice ct$(pn) wait
[b1] emp$="" rd$="" #scr.te "!lines cl" ; for i = 1 to cl step 1 #scr.te "!line ";i;" linete$" ; rd$=rd$;linete$;"@x@" ''notice rd$ next i ct$(pn)=rd$ open "c:\ugly_pdf_test\test.pdf" for output as #tf #tf "%PDF-1.3" #tf "%âãÏÓ" #tf "" #tf "1 0 obj" #tf "<<" #tf "/Type /Catalog" #tf "/Outlines 2 0 R" #tf "/Pages 3 0 R" #tf ">>" #tf "endobj" #tf "" #tf "2 0 obj" #tf "<<" #tf "/Type /Outlines" #tf "/Count 0" #tf ">>" #tf "endobj" #tf "" #tf "3 0 obj" #tf "<<" #tf "/Type /Pages" #tf "/Count ";total;"" st$="" for a=1 to total step 1 i=a*10 st$=st$;i;" 0 R " next #tf "/Kids [ ";st$;" ]" #tf ">>" #tf "endobj" #tf "" for a3=1 to total step 1 i2=a3*10 #tf "";i2;" 0 obj" #tf "<<" #tf "/Type /Page" #tf "/Parent 3 0 R" #tf "/Resources <<" #tf "/Font <<" #tf "/F1 9 0 R " #tf ">>" #tf "/ProcSet 8 0 R" #tf ">>" #tf "/MediaBox [0 0 600 700]" #tf "/Contents ";i2+1;" 0 R" #tf ">>" #tf "endobj" #tf "";i2+1;" 0 obj" #tf "<</Length 1000>>" #tf "stream" #tf "2j " #tf "BT" #tf "0 0 0 rg" #tf "/F1 0020 Tf" #tf "50 560 Td" #tf "40 TL" #tf "() Tj T*" ls=len(ct$(a3)) lp=0 for i = 1 to ls step 1 one$="" one$=mid$(ct$(a3), i, 1) two$=mid$(ct$(a3), i+1, 1) three$=mid$(ct$(a3), i+2, 1) if one$="@" and two$="x" and three$="@" then #tf "2 Tr" #tf "(";mid$(ct$(a3), lp, i-lp);") Tj T*" lp=i+3 end if next i #tf "endstream" #tf "endobj" #tf "" next
#tf "" #tf "8 0 obj" #tf "[/PDF /Text]" #tf "endobj" #tf "" #tf "9 0 obj" #tf "<<" #tf "/Type /Font" #tf "/Subtype /Type1" #tf "/Name /F1" #tf "/BaseFont /Arial" #tf "/Encoding /WinAnsiEncoding" #tf ">>" #tf "endobj" #tf "" #tf "trailer" #tf "<<" #tf "/Size 80" #tf "/Root 1 0 R" #tf ">>" #tf "" #tf "startxref" #tf "4000" #tf "%%EOF" close #tf b$ = "C:\ugly_pdf_test\test.pdf" RUN "rundll32.exe url.dll,FileProtocolHandler ";b$ wait
|
|
code
Member in Training
Posts: 74
|
Post by code on Oct 15, 2021 16:07:52 GMT
|
|
|
Post by tenochtitlanuk on Oct 15, 2021 18:47:52 GMT
How about creating/displaying as an html file? PDF is not plain-text, and would be very difficult to write. Of course I do not know what you are keen on achieving! This version of my earlier code creates a graphic, then writes an html file to display the image and text and a hyperlink, and calls it. Click start as often as you like 'til you like the pattern. The 'log' button switches to log spirals. The 'Store' button saves the bmp and writes/displays in a web browser. 's.graph8.bas
nomainwin
WindowWidth = 600 WindowHeight = 600 UpperLeftX = int((DisplayWidth - WindowWidth) /2) UpperLeftY = int((DisplayHeight - WindowHeight)/2)
button #graph.b1, "Exit", [exit], LR, 35, 20 button #graph.b2, "Log", [type], LR, 85, 20 button #graph.b3, "Start", [do.it], LR, 300, 20 button #graph.b3, "Store Image", [save.image], LR, 205, 20
open "Spiral" for graphics as #graph
#graph "trapclose [exit]" #graph "horizscrollbar off;vertscrollbar off" #graph "down" #graph "home" #graph "posxy CenterX CenterY" #graph "place "; CenterX; " "; CenterY / 2
t =1
wait
[do.it] r =1 i =0 t =0
spur.number =1 +int( 5 *rnd(1))
pi =3.14159265 incr =rnd( 1) /3 mult =1 +rnd( 1) /3000 theta.inc =rnd( 1) /100 k =1 +5 *rnd(1)
#graph "cls ; fill "; int( 255 *rnd( 1)); " "; int(255 *rnd( 1)); " "; int( 255 *rnd( 1))
while r <300*2^0.5 i =i +1 scan #graph, "size "; int( 2 +r/ k)' growth of 'blob'
if t =0 then r =r +incr else r =r *mult end if
r0 =min( r, 255) theta =theta +theta.inc
select case spur.number case 1 #graph "color 255 "; int( r0); " "; int( r0) x1 =CenterX +r *cos( theta) y1 =CenterY +r *sin( theta) #graph "set "; x1; " "; y1 case 2 #graph "color "; int( r0); " "; int( r0); " 255" x1 =CenterX +r *cos( theta) y1 =CenterY +r *sin( theta) #graph "set "; x1; " "; y1 x1 =CenterX +r *cos( theta +pi *2 /2) y1 =CenterY +r *sin( theta +pi *2 /2) #graph "set "; x1; " "; y1 case 3 #graph "color "; int( r0); " 255 "; int( r0) x1 =CenterX +r *cos( theta) y1 =CenterY +r *sin( theta) #graph "set "; x1; " "; y1 x1 =CenterX +r *cos( theta +pi *2 /3) y1 =CenterY +r *sin( theta +pi *2 /3) #graph "set "; x1; " "; y1 x1 =CenterX +r *cos( theta +2 *pi *2 /3) y1 =CenterY +r *sin( theta +2 *pi *2 /3) #graph "set "; x1; " "; y1 case 4 #graph "color "; int( r0); " "; int( r0); " "; int( r0) x1 =CenterX +r *cos( theta) y1 =CenterY +r *sin( theta) #graph " set "; x1; " "; y1 x1 =CenterX +r *cos( theta +pi *2 /4) y1 =CenterY +r *sin( theta +pi *2 /4) #graph " set "; x1; " "; y1 x1 =CenterX +r *cos( theta +2 *pi *2 /4) y1 =CenterY +r *sin( theta +2 *pi *2 /4) #graph " set "; x1; " "; y1 x1 =CenterX +r *cos( theta +3 *pi *2 /4) y1 =CenterY +r *sin( theta +3 *pi *2 /4) #graph " set "; x1; " "; y1 case 5 #graph "color "; int( r0); " 0 "; int( r0) x1 =CenterX +r *cos( theta) y1 =CenterY +r *sin( theta) #graph "set "; x1; " "; y1 x1 =CenterX +r *cos( theta +1 *pi *2 /5) y1 =CenterY +r *sin( theta +1 *pi *2 /5) #graph " set "; x1; " "; y1 x1 =CenterX +r *cos( theta +2 *pi *2 /5) y1 =CenterY +r *sin( theta +2 *pi *2 /5) #graph "set "; x1; " "; y1 x1 =CenterX +r *cos( theta +3 *pi *2 /5) y1 =CenterY +r *sin( theta +3 *pi *2 /5) #graph "set "; x1; " "; y1 x1 =CenterX +r *cos( theta +4 *pi *2 /5) y1 =CenterY +r *sin( theta +4 *pi *2 /5) #graph "set "; x1; " "; y1 end select
wend
wait
[type] if t =0 then t =1 #graph.b2, "Log" else t =0 #graph.b2, "Lin" end if wait
[exit] close #graph end
[save.image] ' save drawn page as bmp and html- display the latter #graph "up ; goto 40 20 ; down" #graph "color cyan ; backcolor darkblue" #graph "font Courier 12 bold" #graph "\Made and saved by LB/JB code." #graph "flush" #graph "print 1000" #graph, "getbmp drawing 1 1 500 500" bmpsave "drawing", "spiral.bmp"
open "demoHtml.html" for output as #fOut #fOut "<html>" #fOut "<head>" #fOut "</head>" #fOut "<body bgcolor='#c0c080'>" #fOut "<center>" #fOut "<h1>" #fOut "Created Page from JB/LB." #fOut "</h1>" #fOut "This is a page that was created and displayed in LB/JB." #fOut "The graphic was first created and saved, then referenced in the html code." #fOut "<p>" #fOut "<img src='spiral.bmp'>" #fOut "<p>" #fOut "<a href='https://www.diga.me.uk'>Diga Me</a> website." #fOut "</body>" #fOut "</html>" close #fOut
run "explorer.exe "; "demoHtml.html"
wait
|
|
code
Member in Training
Posts: 74
|
Post by code on Oct 15, 2021 19:05:14 GMT
Hi, Thanx for your reaction. First of all that are really nice pictures!. Yep, there is no need for pdf (just html) I tought that a lot of times.
Thx for sharing...
Regards,
code
|
|
|
Post by xxgeek on Oct 16, 2021 3:53:28 GMT
I need to create an offline html file viewer capable of viewing the JB help files, and some have gif files on their page. I have an old freeware version that works great, but that means adding a support file. Trying to keep the entire thing to one bas file for the first version. Second version will be in a zip file with a few support files. I'd rather have a light weight viewer, with no online capability, instead of having my default browser opening the files, they open instantly in the freeware "offlinehtmlviewer.exe v1.02" It's been around for years. Simple and fast. I'm curious code, were the buttons on your window all over the place at your end? They were here. Just wondering if that was just unfinished code or a graphic issue with JB I need to be aware of. I have no idea if the code I post works elsewhere like it does for me here on Win 10 Pro, and Linux using WINE.
|
|
code
Member in Training
Posts: 74
|
Post by code on Oct 16, 2021 4:30:36 GMT
The version you made.. i runned it. Looked very good the buttons on my screen. Html viewer...codeproject.com? Often verry difficult. Regards, code
|
|
|
Post by xxgeek on Oct 16, 2021 18:54:44 GMT
The version you made.. i runned it. Looked very good the buttons on my screen. Html viewer...codeproject.com? Often verry difficult. Regards, code Thanks for the comeback code, mush appreciated. I've heard of codesource, but never visited before. Time for a visit. BTW - FYI - For anyone reading this as well. In Linux running WINE there is a built in simple Internet Explorer I can use, so now I'm looking thru win 10 to see if MS left an older simple Internet Explorer around I can use, if not I'll attempt writing one. One more thing code. Everything you post is interesting and new to me, thanks for posting here. I sure wish you would take out all the unnecessary empty lines though. Makes your code hard to read, but I have a solution so no worries if you don't. Keep posting your stuff no matter.
|
|