Board Logo
« Example of making a ugly pdf file »

Welcome Guest. Please Login or Register.
Nov 24th, 2017, 6:18pm


Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ

Please use the forums Search feature before asking.
Please post code using the code box described in Format Your Messages.
This will keep indentation, separate it better form the message and prevent gibberish.
If the code is too long for one post or additional files are needed, upload a ZIP archive to the Just BASIC Files Archive Site.

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Example of making a ugly pdf file  (Read 862 times)
code
Member in Training
ImageImage


member is offline

Avatar




Homepage PM


Posts: 22
xx Example of making a ugly pdf file
« Thread started on: Dec 17th, 2015, 3:48pm »

Hi,
Below a code to write a pdf file ,with 4 lines.. remark that each line extra needs to be placed with '-10' in the code.
Hope someone like/needs this.

Regards,

Frederik Pot
frederikpot@hotmail.com

Code:




    WindowWidth=280
    WindowHeight=200
    nomainwin

    button #scr, "   Show  pdf file in browser...", [b1], UL, 5, 40

    open "Make ugly pdf file..." for graphics_nsb as #scr
    print #scr, "trapclose [exit]"
    print #scr, "fill darkred"
    print #scr, "flush"


    wait

    [b1]





    open "text.pdf" for output as #tf

    print #tf, "%PDF-1.1"
    print #tf, "%"

    print #tf, "1 0 obj"
    print #tf, "  << /Type /Catalog"
    print #tf, "     /Pages 2 0 R"
    print #tf, "  >>"
    print #tf, "endobj"
    print #tf, " "
    print #tf, "2 0 obj"
    print #tf, "  << /Type /Pages"
    print #tf, "     /Kids [3 0 R]"
    print #tf, "     /Count 1"
    print #tf, "     /MediaBox [0 0 300 620]"
    print #tf, " "
    print #tf, "  >>"
    print #tf, "endobj"
    print #tf, " "
    print #tf, "3 0 obj"
    print #tf, "  <<  /Type /Page"
    print #tf, "      /Parent 2 0 R"
    print #tf, "      /Resources"
    print #tf, "     << /Font"
    print #tf, "           << /F2"
    print #tf, "               << /Type /Font"
    print #tf, "                  /Subtype /Type1"
    print #tf, "                  /BaseFont /Arial"
    print #tf, "               >>"
    print #tf, "           >>"
    print #tf, "       >>"
    print #tf, "      /Contents 4 0 R"
    print #tf, " >>"
    print #tf, "endobj"
    print #tf, " "
    print #tf, "4 0 obj"
    print #tf, "  << /Length 55 >>"
    print #tf, " "
    print #tf, " "
    print #tf, "stream"
    print #tf," "
    print #tf,"BT"
    print #tf,"    /F2 10 Tf"
    print #tf,"    10 600 Td"
    print #tf,"    (     JustBasic ) Tj"
    print #tf," "
    print #tf," "
    print #tf," "
    print #tf,"  ET"
    print #tf," "

    print #tf," "
    print #tf,"BT"
    print #tf,"    /F2 10 Tf"
    print #tf,"    10 590 Td"
    print #tf,"    (      Example line 2) Tj"
    print #tf," "
    print #tf," "
    print #tf," "
    print #tf,"  ET"
    print #tf," "

    print #tf," "
    print #tf,"BT"
    print #tf,"    /F2 10 Tf"
    print #tf,"    10 580 Td"
    print #tf,"    (            Example line 3) Tj"
    print #tf," "
    print #tf," "
    print #tf," "
    print #tf,"  ET"
    print #tf," "

    print #tf," "
    print #tf,"BT"
    print #tf,"    /F2 10 Tf"
    print #tf,"    10 570 Td"
    print #tf,"    (            ) Tj"
    print #tf," "
    print #tf," "
    print #tf," "
    print #tf,"  ET"
    print #tf," "

   print #tf," "
    print #tf,"BT"
    print #tf,"    /F2 10 Tf"
    print #tf,"    10 560 Td"
    print #tf,"    (  Greetings, from Frederik Pot) Tj"
    print #tf," "
    print #tf," "
    print #tf," "
    print #tf,"  ET"
    print #tf," "

    print #tf,"endstream"
    print #tf,"endobj"
    print #tf," "
    print #tf," "
    print #tf," "
    print #tf,"xref"
    print #tf,"0 5"
    print #tf,"0000000000 65535 f "
    print #tf,"0000000018 00000 n "
    print #tf,"0000000077 00000 n "
    print #tf,"0000000178 00000 n "
    print #tf,"0000000457 00000 n "
    print #tf,"trailer"
    print #tf,"  <<  /Root 1 0 R"
    print #tf,"      /Size 5"
    print #tf,"  >>"
    print #tf,"startxref"
    print #tf,"565"
    print #tf,"%%EOF"

    close #tf













    run "explorer.exe text.pdf"

    wait
    [exit]
       close #scr






 
User IP Logged

Facundo
Board Moderator


member is offline

Avatar




PM

Gender: Male
Posts: 1301
xx Re: Example of making a ugly pdf file
« Reply #1 on: Dec 18th, 2015, 4:10pm »

Hey, it works! thanks for sharing. I played with your code a little.
Code:

    WindowWidth=320 : WindowHeight=200
    nomainwin

    button #scr.b1, " Show  pdf file in browser...", [b1], UL, 1, 1

    open "Make ugly pdf file..." for graphics_nsb as #scr
    #scr.b1 "!font tahoma 10"
    #scr "trapclose [exit]"
    #scr "fill DARKGRAY"
    #scr "flush"

    pdfThis$(1) = "JustBASIC - Ugly PDF"
    pdfThis$(2) = "Example line 2"
    pdfThis$(3) = "Example line 3"
    pdfThis$(4) = "--------------"
    pdfThis$(5) = "Greetings, from Frederik Pot"

    wait

    [b1]

    open "text.pdf" for output as #tf

    print #tf, "%PDF-1.1"
    print #tf, "%"

    print #tf, "1 0 obj"
    print #tf, "  << /Type /Catalog"
    print #tf, "     /Pages 2 0 R"
    print #tf, "  >>"
    print #tf, "endobj"
    print #tf, " "
    print #tf, "2 0 obj"
    print #tf, "  << /Type /Pages"
    print #tf, "     /Kids [3 0 R]"
    print #tf, "     /Count 1"
    print #tf, "     /MediaBox [0 0 300 620]"
    print #tf, " "
    print #tf, "  >>"
    print #tf, "endobj"
    print #tf, " "
    print #tf, "3 0 obj"
    print #tf, "  <<  /Type /Page"
    print #tf, "      /Parent 2 0 R"
    print #tf, "      /Resources"
    print #tf, "     << /Font"
    print #tf, "           << /F2"
    print #tf, "               << /Type /Font"
    print #tf, "                  /Subtype /Type1"
    print #tf, "                  /BaseFont /Arial"
    print #tf, "               >>"
    print #tf, "           >>"
    print #tf, "       >>"
    print #tf, "      /Contents 4 0 R"
    print #tf, " >>"
    print #tf, "endobj"
    print #tf, " "
    print #tf, "4 0 obj"
    print #tf, "  << /Length 55 >>"
    print #tf, " "
    print #tf, " "
    print #tf, "stream"

    startAt = 610

    for i = 1 to 5
        print #tf," "
        print #tf,"BT"
        print #tf,"    /F2 10 Tf"
        startAt = startAt - 10
        print #tf,"    10 ";startAt;" Td"
        print #tf,"    ("; pdfThis$(i) ;") Tj"
        print #tf," "
        print #tf," "
        print #tf," "
        print #tf,"  ET"
        print #tf," "
    next

    print #tf,"endstream"
    print #tf,"endobj"
    print #tf," "
    print #tf," "
    print #tf," "
    print #tf,"xref"
    print #tf,"0 5"
    print #tf,"0000000000 65535 f "
    print #tf,"0000000018 00000 n "
    print #tf,"0000000077 00000 n "
    print #tf,"0000000178 00000 n "
    print #tf,"0000000457 00000 n "
    print #tf,"trailer"
    print #tf,"  <<  /Root 1 0 R"
    print #tf,"      /Size 5"
    print #tf,"  >>"
    print #tf,"startxref"
    print #tf,"565"
    print #tf,"%%EOF"

    close #tf

    f$ = "text.pdf"
    RUN "rundll32.exe url.dll,FileProtocolHandler ";f$


    wait
    [exit]
       close #scr
        END
 
User IP Logged

cundo aka MSlayer
code
Member in Training
ImageImage


member is offline

Avatar




Homepage PM


Posts: 22
xx Re: Example of making a ugly pdf file
« Reply #2 on: Dec 18th, 2015, 7:49pm »

Thx, for your reply..
I saw your code.. and i think you understand the '-10' comment... so to speak. Well done.
It always cost some time to understand the code..
angry
But thx again.

Greetings,

Frederik Pot
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls