Step 2 (cont.) - Multiple pages
July 10, 2000
If you'd like to split the file into multiple pages, you could do that
here too. Though I won't go into detail, I will list a few guidelines
on how to do so:
1. Create a 'pages table,' tblPages. A table that contains information
about the pages in the document. This table would contain data such as:
Document ID, which would tell you which document in tblFiles this page
belongs to; PageTitle, a title for the individual page, ie Page 2; and
PageNumber, so you can see the order of the pages.
2. Add a field in tblFiles called NumberOfPages and increment that
number everytime you add another page. This way, you'll know how many
pages are in every document without having to see how many actual files
there are.
3. Name the new files something based off of the original file. For
instance, if the original document was test.html, name pages 2 and 3,
test2.html and test3.html
4. Parse the file for a logical separator, ie a paragraph break
<p> You could then split the page according to the number of
paragraphs, or allow the user to select which paragraph to place the
page break in. If you do the latter, you'll have to mark each spot the
user selected somehow. A good way to do this would be to use a form
with numbered checkboxes for each paragraph; ie if the user selects
checkbox 2, there should be a page break at paragraph 2. For each page
break, write the contents in a new file. This is the hardest step. Here
is some logic and pseudo-code on how to do so:
dim CursorFirst, CursorLast
strNextText = file contents
for each paragraph in strNextText
Set CursorFirst to beginning of paragraph (ie at position of <p>)
If there is more than one paragraph in strNextText then
If this paragraph is not marked with a page break, then
Put all the text to the next paragraph in variable strText
Point CursorLast to CursorFirst
Else
Update tblFiles and tblPages with new page info
Write new file with strText
Clear strText
Put all the text to the next paragraph in variable strText
Put all the text after current paragraph in variable strNextText
Point CursorLast to first <p> in strNextText
End if
Else if only one paragraph then
Write strText to a file
End If
You'll probably want to put this functionality on a separate page.
This should get you started on splitting the original document into
multiple pages.
|
NOTE:
If you split the original document in pieces, be sure to keep track
of those pieces as well. They should each receive an entry in
tblPages. If you move/rename/delete one, make sure you do the same
with all the others.
|
Step 2 - Manipulation
Content Management Made Easy with ASP
Step 3 - Layout
|