need a good method to Page break and add Header - itext

I am using itextsharp library.I design an HTML page and convert to PDF .in that case some table are not split perfectly and row also not split correctly.
I tried to put a comment in the HTML code writing based on the font how many rows the page can contains, then after reaching the limit i just add another page,
this works but doesnt seems a professional way to fix this.
After a search i found many discussions using this code
<style type="text/css">
table { page-break-inside:auto }
tr { page-break-inside:avoid; page-break-after:auto }
thead { display:table-header-group }
tfoot { display:table-footer-group }
</style>
But, what if i need to add a header on each page?
thanks

If you don't want to use events, a tricky method is to use this css style:
table.hrepeat {
repeat-header: yes;
}
and wrap all your content inside an html table adding header to repeat as head of the table.
Example:
<!DOCTYPE html>
<head>
<style type="text/css">
table.hrepeat {repeat-header: yes;}
</style>
</head>
<body>
<table class="hrepeat">
<thead>
<tr>
<th>Header on each page</th>
</tr>
</thead>
<tbody>
....
</tbody>
</table>
</body>

Related

How to Escape Double Quotes on Prolog Web Server

I used the following Prolog code to display an HTML form with info_server(8000). but it doesn't work when a form item contains double-quotes. How can I escape the double quotes?
:- use_module(library(http/thread_httpd)).
:- use_module(library(http/http_dispatch)).
:- use_module(library(http/http_error)).
:- use_module(library(http/html_write)).
:- use_module(library(http/http_client)).
:- http_handler('/', info_web_form, []).
info_server(Port) :-
http_server(http_dispatch, [port(Port)]).
/*
browse http://localhost:8000/
*/
info_web_form(_Request) :-
format('Content-type: text/html~n~n', []),
data(Header,Footer),
Loads the header and footer of the web page, which it reuses on different pages
format(Header,[]),
Displays the header
middle_form,
Displays the form
format(Footer,[]).
Displays the footer
% When the form is submitted, it displays the landing page.
:- http_handler('/landing', landing_pad, []).
landing_pad(Request) :-
member(method(post), Request), !,
http_read_data(Request, Data, []),
format('Content-type: text/html~n~n', []),
Data=[input=Input1, info=Hidden1, submit=_],
format(Input1,[]),
format(Hidden1,[]),
Displays the hidden data from the form, which is cut off because it contains double-quotes.
data(Header,Footer),
format(Header,[]),
middle_form,
format(Footer,[]).
data(Header,Footer) :-
Header='<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<title>Title</title>
<style type="text/css">
<!--
A:link {text-decoration: none;}
A:visited {text-decoration: none;}
A:hover {text-decoration: underline;}
img {
height: auto;
max-width: 100%;
object-fit: contain;
}
table {table-layout: fixed; width: 100%;}
td {word-wrap: break-word;}
-->
</style>
<!-- Displays text at readable size on both desktops and mobiles -->
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<!-- salmon coloured -->
<body style="background-color: rgb(255, 239, 227);">
<div style="text-align: center;">
<table width="80%">
<tbody>
<tr>
<td>
<p>',
Footer='</p>
</td>
</tr>
</tbody>
</table>
<br>
<br>
</body>
</html>'.
middle_form :-
Below is the hidden data, which is cut off with the double quote.
Hidden=[[a],"A",'a'],
term_to_atom(Hidden,Hidden1),
Hidden1=Hidden2,
concat_list(["
<form action=\"/landing\" method=\"POST\">
<label for=info></label>
<input type=text id=input name=input value=''><br><br>
<input type=hidden id=info name=info value=\"",Hidden2,"\"><br><br>
<input type=submit name=submit value='Submit'>
</form>
"],Form_text1),
The call to atom_string below displays the form as an atom.
atom_string(Form_text,Form_text1),
format(Form_text,[]).
The replace_new predicate replaces strings with strings in a string, for example
replace_new('0ab0','a','c',A).
A = "0cb0".
replace_new(A1,Find,Replace,F) :-
string_length(Replace,Replace_l),
string_concat("%",A1,A2),
string_concat(A2,"%",A), split_string(A,Find,Find,B),findall([C,Replace],(member(C,B)),D),maplist(append,[D],[E]),concat_list(E,F1),string_concat(F2,G,F1),string_length(G,Replace_l),
string_concat("%",F3,F2),
string_concat(F,"%",F3),!.
concat_list concatenates a list of strings to a string, for example:
concat_list(["a","b","c"],D).
D="abc"
concat_list([],""):- !.
concat_list(A1,B):-
concat_list("",A1,B),!.
concat_list(A,List,B) :-
concat_list1(A,List,B).
concat_list1(A,[],A):- !.
concat_list1(A,List,B) :-
List=[Item|Items],
string_concat(A,Item,C),
concat_list1(C,Items,B).
When I view the web page at http://localhost:8000/, the hidden info value is partially lost when displayed on the landing page.
I worked out how to escape the double quotes, and it involved changing the code above from:
Hidden1=Hidden2,
to:
replace_new(Hidden1,"\"",""",Hidden2),
Making these changes replaces double quotes with " and preserves the form data.
Note: This also assumes that the programmer uses double quotes around form data in <input type=hidden id=info name=info value=\"",Hidden2,"\">, eliminating single quotes in the data causing an error.

Perl - geturls with WWW::Mechanize

I am trying to submit a form on http://bioinfo.noble.org/TrSSP/ and want to extract the result.
My query data looks like this
>ATCG00270
MTIALGKFTKDEKDLFDIMDDWLRRDRFVFVGWSGLLLFPCAYFALGGWFTGTTFVTSWYTHGLASSYLEGCNFLTAA VSTPANSLAHSLLLLWGPEAQGDFTRWCQLGGLWAFVALHGAFALIGFMLRQFELARSVQLRPYNAIAFSGPIAVFVSVFLIYPLGQSGWFFAPSFGVAAIFRFILFFQGFHNWTLNPFHMMGVAGVLGAALLCAIHGATVENTLFEDGDGANTFRAFNPTQAEETYSMVTANRFWSQIFGVAFSNKRWLHFFMLFVPVTGLWMSALGVVGLALNLRAYDFVSQEIRAAEDPEFETFYTKNILLNEGIRAWMAAQDQPHENLIFPEEVLPRGNAL
My script looks like this
use strict;
use warnings;
use File::Slurp;
use WWW::Mechanize;
my $mech = WWW::Mechanize->new;
my $sequence = $ARGV[0];
$mech->get( 'http://bioinfo.noble.org/TrSSP' );
$mech->submit_form( fields => { 'query_file' => $sequence, }, );
print $mech->content;
#sleep (10);
open( OUT, ">out.txt" );
my #a = $mech->find_all_links();
print OUT "\n", $a[$_]->url for ( 0 .. $#a );
print $mech->content gives a result like this
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>The job is running, please wait...</title>
<meta http-equiv="refresh" content="4;url=/TrSSP/?sessionid=1492435151653763">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="interface/style.css" type="text/css">
</head>
<body>
<table width="90%" align="center" border="0" cellpadding="0" cellspacing="0" class="table1">
<tr align="center">
<td width="50"> </td>
<td></td>
<td> </td>
</tr>
<tr align="left" height="30" valign="middle">
<td width="30"> </td>
<td bgColor="#CCCCFF"> Your sequences have been submitted to backend pipeline, please wait for result:</td>
<td width="30"> </td>
</tr>
<tr align="left">
<td> </td>
<td>
<br><br><font color="#0000FF"><strong>
</strong></font>
<BR><BR><BR><BR><BR><BR><br><br><BR><br><br><hr>
If you don't want to wait online, please copy and keep the following link to retrieve your result later:<br>
<strong>http://bioinfo.noble.org/TrSSP/?sessionid=1492435151653763</strong>
<script language="JavaScript" type="text/JavaScript">
function doit()
{
window.location.href="/TrSSP/?sessionid=1492435151653763";
}
setTimeout("doit()",9000);
</script>
</td>
<td> </td>
</tr>
</table>
</body>
</html>
I want to extract this link
http://bioinfo.noble.org/TrSSP/?sessionid=1492435151653763
and download the result when the job is completed. But find_all_links() is recognizing /TrSSP/?sessionid=1492434554474809 as a link.
We don't know how long this is backend process there is going to take. If it's minutes, you could have your program wait. Even if it's hours, waiting is reasonable.
In a browser, the page is going to refresh on its own. There are two auto-refresh mechanisms implemented in the response you are showing.
<script language="JavaScript" type="text/JavaScript">
function doit()
{
window.location.href="/TrSSP/?sessionid=1492435151653763";
}
setTimeout("doit()",9000);
</script>
The javascript setTimeout takes an argument in milliseconds, so this will be done after 9 seconds.
There is also a meta tag that tells the browser to auto-refresh:
<meta http-equiv="refresh" content="4;url=/TrSSP/?sessionid=1492435151653763">
Here, the 4 in the content means 4 seconds. So this would be done earlier.
Of course we also don't know how long they keep the session around. It might be a safe approach to reload that page every ten seconds (or more often, if you want).
You can do that by building a simple while loop and checking if the refresh is still in the response.
# do the initial submit here
...
# assign this by grabbing it from the page
$mech->content =~ m{<strong>(\Qhttp://bioinfo.noble.org/TrSSP/?sessionid=\E\d+)</strong>};
my $url = $1; # in this case, regex on HTML is fine
print "Waiting for $url\n";
while (1) {
$mech->get($url);
last unless $mech->content =~ m/refresh/;
sleep 10; # or whatever number of seconds
}
# process the final response ...
We first submit the data. We then extract the URL that you're supposed to call until they are done processing. Since this is a pretty straight-forward document, we can safely use a pattern match. The URL is always the same, and it's clearly marked with the <strong> tag. In general it's not a good idea to use regex to parse HTML, but we're not really parsing, we are just screenscraping a single value. The \Q and \E are the same as quotemeta and make sure that we don't have to escape the . and ?, which is then easier to read than having a buch of backslashes \ in the pattern.
The script will sleep for ten seconds after every attempt before trying again. Once it matches, it breaks out of the endless loop, so you can put the processing of the actual response that has the data you wanted behind that loop.
It might make sense to add some output into the loop so you can see that it's still running.
Note that this needs to really keep running until it's done. Don't stop the process.

Codemirror display code from codemirror textarea

I'm getting plain text while displaying the code from the codemirror textarea and I want to that in the form of code highlighted format. Any plz help me.
I want to print highlighted code which was highlighted in the codemirror editor I'm getting that code from codemirror editor by using editor.getValue();:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Demo_Format</title>
<link rel="stylesheet" href="lib/codemirror.css">
<script src="lib/codemirror.js"></script>
<script src="lib/util/formatting.js"></script>
<script src="lib/css.js"></script>
<script src="lib/xml.js"></script>
<script src="lib/javascript.js"></script>
<script src="lib/htmlmixed.js"></script>
<link rel="stylesheet" href="lib/docs.css">
<style type="text/css">
.CodeMirror {
border: 1px solid #eee;
}
td {
padding-right: 20px;
}
</style>
</head>
<body>
<h1></h1>
<form>
<textarea id="code" name="code">
package org;import java.io.IOException;import javax.servlet.http.*;#SuppressWarnings("serial")
public class BasicChatServlet extends HttpServlet{public void doGet(HttpServletRequest req,HttpServletResponse resp)
throws IOException{resp.setContentType("text/plain");resp.getWriter().println("Hello, world");}}
</textarea>
</form>
<table>
<tr>
<td>
<a href="javascript:autoFormatSelection()">
<button> Format </button>
</a>
<button id="copy_button">copy</button>
<button id="show">show</button>
</td>
<div id="code_show">
</div>
</tr>
</table>
</p>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script>
$("#copy_button").click(function(){
$("textarea").select();
document.execCommand('copy');
});
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
lineNumbers: false,
indentUnit: 4
});
CodeMirror.commands["selectAll"](editor);
function getSelectedRange() {
return { from: editor.getCursor(true), to: editor.getCursor(false) };
}
function autoFormatSelection() {
var range = getSelectedRange();
var x=editor.autoFormatRange(range.from, range.to);
}
$("#show").click(function(){
var program=editor.getValue();
$("#code_show").text(program);
});
</script>
</body>
</html>
(Not sure if this answers your question because it's not very clear -- it would be helpful if you only provided the necessary code for the question)
Each mode (which styles your CodeMirror instance) lives in a subdirectory of the mode/ directory, and typically defines a single JavaScript file that implements the mode. Loading such file will make the language available to CodeMirror through the mode option, which you declare while creating your CodeMirror instance:
CodeMirror.fromTextArea(document.getElementById("code"), {
lineNumbers: false,
indentUnit: 4,
mode: 'text/css'
});
You'll need to ensure your different mode files are added to a mode folder in your library. In your case the css.js, xml.js, javascript.js and htmlmixed.js files need to be in a new folder called lib/mode (so css.js has a filepath of lib/mode/css.js for example).
You can inspect each mode's demo to see what string you must pass to the mode: option in order for it to be called. Here's the css demo for example
You can go one step further and change the mode on the fly for editing multiple text file-types: Multiple modes Codemirror

How to Show or Hide the date using asp classic

Im using a form to give the user the option to show or hide the date on a webpage, either yes or no.
I am using cookies to store the option but i can find or figure out how to display or not display the date on the page.
I have been trying to process the yes or no option using an IF statement that will then be used as a css stylesheet for the webpage.
Maybe im going about it all wrong.
Regards
Trev
EDIT STARTS HERE
My code so far (not working, dont even know if im on the right track)
Code in the css/asp processing style sheet called styleCookieProcess.asp
<%
date= Response.Cookies("usedate")
If(date= "yes") then
Response.Cookies("wantdate") = "date()"
ElseIf(date= "no") then
Response.Cookies("wantdate") = "None"
End If
%>
And this is the code in my Webpage:
<html>
<head>
<link rel="stylesheet" type="text/css" href="styleCookieProcess.asp">
<title>About Us</title>
</head>
<body>
<p>Current Date <%
Response.Write(Response.Cookies("wantdate"))
%></p>
<P ALIGN = "CENTER">
<IMG SRC = "Images\About_Us.png" HEIGHT = "250" WIDTH = "715">
</P>
<TABLE ALIGN = "CENTER">
<tr>
<th>
<DIV ALIGN = "CENTER">
<P>
We have been around the block and back and have the t-shirt to prove it!
The Glad Rag Team
</P>
</DIV>
</th>
</tr>
</TABLE>
</body>
</html>
Regards, Bubs
try this
<%
date= Response.Cookies("usedate")
If(date= "yes") then
Response.Cookies("wantdate") = "date()"
Else
Response.Cookies("wantdate") = "None"
End If
%>

In Dashcode, with iPhone webkit, how to add a new page?

I'm working on a website for iphone using dashcode. But i don't know how to add a new html page to the 'site'. I could use stackLayout but it takes so much time to load the 'index.html' since it has all the stackLayout's views in it.
enlightenment needed :)
rather than adding a new html page you could split the existing index.html into "pages" with each page in a and then use the javascript to manipulate the visibility of the divs.
so the javascript looks like this
function hide_me(el) {
if(document.getElementById(el)) {
if(document.getElementById(el).style.display != "none")
document.getElementById(el).style.display = "none";
}
}
function show_me(el) {
if(document.getElementById(el)) {
if(document.getElementById(el).style.display == "none")
document.getElementById(el).style.display = "block";
}
}
then in the html
<ul>
<li><a href="javascript:
show_me('one');
hide_me('two');
hide_me('three');
etc......
</li>
</ul>
and further down the index.html
<div class="mainContent" id="one">
<!-- generated html -->
<table>
<tbody>
<tr class="head">
<td class="item" colspan="2">
CHMOD
</td>
</tr>
etc .....
</table>
</div>
This way the load is all taken when the widget is fired up and therafter you just display the divs as opposed to having to load them
Click:
FILE > NEW > FILE
Then, rename the file to "whatever.html"
You're welcome!
My site was made with Dashcode!