creating HTML for Print

Ask a Question related to Macromedia Director Lingo, Design and Development.

  1. #1

    Default creating HTML for Print

    Hi guys,

    i was looking for a print solution some time back, and had a suggestion that
    i could create a HTML (that makes the printing look really formatted) and
    then print that file ..

    pls. gimme suggestion / bahaviours that can create a html page, no $$$ xtras
    please..
    Guess i can use the FileXtra {free :-} and create HTML files, like creating
    normal text files ..

    Thanx
    Kart


    Creative Acceleration Guest

  2. Similar Questions and Discussions

    1. Creating a print button on a PDF
      I am trying to map a graphic on my PDF so that when a user clicks on it, the print dialog box opens up and allows them to print the PDF. Is this...
    2. Creating PDFs from Freehand -- print to PDFvs. export vs. print/scan to PDF?
      I've had a lot of compatibility problems with created presentations so have started using Acrobat instead of trying to export my Macromedia Freehand...
    3. Creating a print window
      I am working on creating a print window (TitleWindow) that can be used throughout my application as a "canvas" to drop in visual objects that need...
    4. How to use HTML::Parser to remove HTML tags and print result
      I am trying to use HTML::Parser to parse an HTML file, remove all HTML tags (including comments, etc.), replace all ENTITIES (e.g. &amp), and put...
    5. Creating a logo for print and web
      hello forum! can someone tell me where in this forum or archives there was a posting about using a file for both print and web, specifically...
  3. #2

    Default Re: creating HTML for Print

    You can use the writeString function in the fileIO xtra (free with Director) to
    write the actual html to a file on disk.
    To create the html, you just build it in a string:

    myHtml="<html><head><title>A Title</title></head>"
    myHtml=myHtml & "<body><H1>The Heading</H1>"
    myHtml=myHtml & </body></html>"
    -- get an unused filename in user's temp folder
    tryNextName=true
    repeat while not(tryNextName)
    fName=baGetFolder("temp") & string(the milliseconds) & ".html"
    if not(baFileExists(fName)) then tryNextName=false
    end repeat

    handle=new(xtra "fileIO") -- instantiate xtra
    openFile(handle, fName, 0) -- open for r/w access
    createFile(handle, fName) -- create file
    writeString(handle, myHtml) -- write data
    closeFile(handle) -- done with writing to file
    handle=void -- done with xtra

    baPrintFile(fName)
    baDeleteFile(fName)

    fileXtra4 has equivalent functions to the buddyAPI ones I showed (the ones
    starting "ba").
    You should check the error status for the fileIO and buddyAPI/fileXtra4
    functions after every usage of it them.

    HTH

    Andrew Morton

    Andrew Morton Guest

  4. #3

    Default Re: creating HTML for Print

    In article <bjgvtk$qg3$1@forums.macromedia.com>, "Creative Acceleration"
    <karthkyn@hotmail.com> wrote:
    > i was looking for a print solution some time back, and had a suggestion that
    > i could create a HTML (that makes the printing look really formatted) and
    > then print that file ..
    >
    In addition to Andrew's idea, if you don't have to add any graphics, which
    text members don't support, you can use the html property of a text member
    to make your html for you. Put the text you want in a text member and
    then use member("textMember").html for your output to the file you want to
    print.

    member("textMember").line[1] = "hi there"
    member("textMember").line[1].font = "Arial"

    htmlOutput = member("textMember").html

    inst = new(xtra "fileio")
    inst.openFile("c:\temp\somefile.html",2)
    inst.writeString(htmlOutput)

    Gretchen Macdowall
    [url]http://www.updatestage.com/[/url]
    Gretchen Macdowall Guest

  5. #4

    Default Re: creating HTML for Print

    > ... you can use the html property of a text member

    As long as the browser which will print the html does not mind incorrect html
    markup. Make a word bold and italic in a text member and its html will be
    <B><I>word</B></I>. I don't even want to think about what it might do to <table>
    markup.

    Andrew

    Andrew Morton Guest

  6. #5

    Default Re: creating HTML for Print

    Thanks guys !
    Kart

    "Creative Acceleration" <karthkyn@hotmail.com> wrote in message
    news:bjgvtk$qg3$1@forums.macromedia.com...
    > Hi guys,
    >
    > i was looking for a print solution some time back, and had a suggestion
    that
    > i could create a HTML (that makes the printing look really formatted) and
    > then print that file ..
    >
    > pls. gimme suggestion / bahaviours that can create a html page, no $$$
    xtras
    > please..
    > Guess i can use the FileXtra {free :-} and create HTML files, like
    creating
    > normal text files ..
    >
    > Thanx
    > Kart
    >
    >

    Creative Acceleration Guest

  7. #6

    Default Re: creating HTML for Print

    Just adding to the good suggestions already posted.

    I found it easiest to build the html data from pre-made snippets of html
    code combined with variable data.
    Having the html code visible in field members made it easy to fine tune the
    formatting of the page.

    The field member names will give you an idea of the setup:
    html_start
    table_rule
    img_start
    img_end
    title_start
    title_end
    author_start
    author_end
    group_start
    group_end
    html_end

    This was a program where children voted for their favourite books.
    The result was then sent to an ASP page where the book data populated a
    form.
    The form functioned as a preview where you could change & add further info
    before submittal.
    Nothing fancy here.

    Perhaps you can extract something useful from the script below.
    BuddyAPI is used here, but you can probably use FileXtra instead.
    Watch out for line breaks, as usual.

    ------------------------------<moviescript>----------------------------

    --Last edit: 2002-01-24/02:15 (Berra)

    --Xtras used: BuddyAPI

    global gMoviePrefs

    --========================== PRINTING =======================
    --GenerateHTML-version of the book list
    on generateHTML me

    -- write HTML start:
    htm = member("html_start").text &RETURN

    -- write Rule:
    htm = htm & member("table_rule").text &RETURN

    infoList = getBookData() --list of titles, authors, age group, etc.
    endCount = gMoviePrefs.listed.count

    -- write Table entries:
    repeat with n = 1 to endCount
    theBook = gMoviePrefs.listed[n]
    theImage = theBook & ".jpg"
    theInfo = infoList.getProp(theBook)
    theTitle = theInfo.title
    theAuthor = theInfo.author

    case (theBook.char[1]) of
    "1": theGroup = gMoviePrefs.groupInfo.g1
    "2": theGroup = gMoviePrefs.groupInfo.g2
    "3": theGroup = gMoviePrefs.groupInfo.g3
    "4": theGroup = gMoviePrefs.groupInfo.g4
    end case

    -- write Image:
    htm = htm & member("img_start").text
    htm = htm & theImage & member("img_end").text

    -- write Title:
    htm = htm & member("title_start").text
    htm = htm & theTitle & member("title_end").text

    -- write Author:
    htm = htm & member("author_start").text
    htm = htm & theAuthor & member("author_end").text

    -- write Group:
    htm = htm & member("group_start").text
    htm = htm & theGroup & member("group_end").text &RETURN

    -- write Rule:
    htm = htm & member("table_rule").text &RETURN
    end repeat

    -- write HTML end:
    htm = htm & member("html_end").text &RETURN

    return htm
    end


    --Save the generated HTML document
    on savePrintDoc theText, theFile

    -- create the FileIO instance
    fileObj = new(xtra "FileIO")

    -- set the filter mask to text/html files
    if the platform contains "mac" then
    setFilterMask(fileObj,"TEXT")
    else
    setFilterMask(fileObj,"HTML-dokument,*.htm*,Alla Filer,*.*")
    end if


    -- if no file path was passed - open save dialog box
    if voidP(theFile) then
    theFile = displaySave(fileObj,"","")

    -- check to see if cancel was hit
    if theFile = "" then return FALSE
    end if

    -- delete existing file, if any
    openFile (fileObj,theFile,2)
    delete(fileObj)

    -- create and open the file
    createFile(fileObj,theFile)
    openFile(fileObj,theFile,2)

    -- check to see if file opened ok
    if status(fileObj) <> 0 then
    err = error(fileObj,status(fileObj))
    alert "Error:"&&err
    return FALSE
    end if

    -- write the file
    writeString(fileObj,theText)

    -- set the file type
    if the platform contains "Mac" then
    setFinderInfo(fileObj, "TEXT MSIE")
    end if

    -- close the file
    closeFile(fileObj)

    fileObj = 0

    return TRUE
    end

    --========================== VOTING =======================

    -- <Submit Votes> --------------------------------
    on submitVote (theURL)
    argASP = generateASP()
    NetOK = baOpenURL(theURL & argASP, "normal")
    return NetOK
    end

    on generateASP
    infoList = getBookData() --Internal/2: "CM: Boktips/Bokjuryn - Databas
    200?"
    gMoviePrefs.listed.sort() --Behövs?
    endCount = min(5, gMoviePrefs.listed.count)

    -- Build string of arguments:
    args = "?"

    repeat with n = 1 to endCount
    theBook = gMoviePrefs.listed[n]
    theInfo = infoList.getProp(theBook)
    theTitle = theInfo.title
    theAuthor = theInfo.author
    theNum = string(n)
    args = args & "title" &theNum& "=" & theTitle & "&author" &theNum& "=" &
    theAuthor
    if n < endCount then args = args & "&"
    end repeat
    return args
    end
    -- </Submit Votes> --------------------------------

    --------------------------------------<moviescript/>------------------------
    -------


    Hope this helps,



    --
    Bertil Flink
    Creative Media





    "Creative Acceleration" <karthkyn@hotmail.com> skrev i meddelandet
    news:bjgvtk$qg3$1@forums.macromedia.com...
    > Hi guys,
    >
    > i was looking for a print solution some time back, and had a suggestion
    that
    > i could create a HTML (that makes the printing look really formatted) and
    > then print that file ..
    >
    > pls. gimme suggestion / bahaviours that can create a html page, no $$$
    xtras
    > please..
    > Guess i can use the FileXtra {free :-} and create HTML files, like
    creating
    > normal text files ..
    >
    > Thanx
    > Kart
    >
    >

    Bertil Flink Guest

  8. #7

    Default Re: creating HTML for Print

    In article <bjhurq$dm9$1@forums.macromedia.com>, "Andrew Morton"
    <akm@in-press.co.uk.invalid> wrote:
    > As long as the browser which will print the html does not mind incorrect html
    > markup. Make a word bold and italic in a text member and its html will be
    > <B><I>word</B></I>. I don't even want to think about what it might do to
    <table>
    > markup.
    >
    Certainly has its "quirks" like flawed markup and only supporting HTML
    1.0. FWIW I just tried printing some Director-created HTML in IE that
    included the bold/italic combo and a simple table and it seemed to work
    OK. Guess it would depend on how fancy one wanted to get with the HTML.

    Gretchen Macdowall
    [url]http://www.updatestage.com/[/url]
    Gretchen Macdowall Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139