I am using HTMLWorker.parseToList(new StringReader(HospNote),styles)
I am trying to get the spacing between the lines to look nicer. In my html
string that I am pulling in I have an image.
If I comment out the line styles.loadTagStyle("td","leading", "7,0"); the
image appears where I would expect it to in the note, however the spacing
between the lines is too far apart and difficult to read.
I've attached two pdfs. One with the setLeading and one without.
Can anyone tell me if I am using the setLeading correctly or if I should be
using something else when I have an image in my html string
How does the 2nd and 3rd parameter come into play with setLeading
http://old.nabble.com/file/p27540307/ReportWithLeading.pdf
ReportWithLeading.pdf
http://old.nabble.com/file/p27540307/ReportWithoutLeading.pdf
ReportWithoutLeading.pdf
http://old.nabble.com/file/p27540307/blob.jpg blob.jpg
Below is my code - I've tried to simplify it as much as possible so I can
clearly demonstrate the issue at hand.
package itextexamples;
import GLMC.LogMap;
import com.lowagie.text.Chunk;
import com.lowagie.text.Document;
import com.lowagie.text.Element;
import com.lowagie.text.ExceptionConverter;
import com.lowagie.text.Font;
import com.lowagie.text.FontFactory;
import com.lowagie.text.HeaderFooter;
import com.lowagie.text.Phrase;
import com.lowagie.text.Rectangle;
import com.lowagie.text.html.simpleparser.HTMLWorker;
import com.lowagie.text.html.simpleparser.StyleSheet;
import com.lowagie.text.pdf.BaseFont;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfPCell;
import com.lowagie.text.pdf.PdfPTable;
import com.lowagie.text.pdf.PdfPageEventHelper;
import com.lowagie.text.pdf.PdfTemplate;
import com.lowagie.text.pdf.PdfWriter;
import java.io.ByteArrayOutputStream;
import java.io.FileOutputStream;
import java.io.StringReader;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
/* 6/09/2009 dmholte
* This class is used to build a pdf from an html note
* it extends the PdfPageEvent Helper in order to buid the page numbers
* */
public class NoteImage4 extends PdfPageEventHelper { //need to extend
PdfPageEventHelper in order to build build the footer page events objects
PdfTemplate tpl; //A template that will hold the total number of pages
BaseFont helv; //The font used for the footer page number
String outPutPath = "C:\\PDFReports\\";
String outPutFile="";
String reportTitle="The Title At Top"; //this is added in onStartPage
public NoteImage4(){
//contructor
}
public static void main(String[] args) {
NoteImage4 build = new NoteImage4();
build.makePDF();
} //end public void main
public void makePDF(){
Date jDate = new Date();
long lngDate =jDate.getTime();
try{
String HospNote = "<html>" +
"<table width='100%'> "+
"<tr><td>Mickey Mouse</td> <td>123456-2</td> "+
"<td width='50%'>Therapy Note - Initial Evaluation</td></tr> "+
"<tr><td colspan='3'><br/></td></tr> "+
"<tr><td colspan='3'>Physical Therapy</td></tr> "+
"<tr><td colspan='3'>September 29, 2009
LA CROSSE INITIAL
EVALUATION</td></tr> "+
"<tr><td colspan='3'>REPORT TITLE:</td></tr> "+
"<tr><td colspan='3'>INITIAL EVALUATION</td></tr> "+
"<tr><td colspan='3'> </td></tr> "+
"<tr><td colspan='3'>IDENTIFYING DATA:</td></tr> "+
"<tr><td colspan='3'>Age: 23 years</td></tr> "+
"<tr><td colspan='3'>Gender: Female</td></tr> "+
"<tr><td colspan='3'> </td></tr> "+
"<tr><td colspan='3'>REFERRING PROVIDER:</td></tr> "+
"<tr><td colspan='3'>Donald P Duck, MD, FACP</td></tr> "+
"<tr><td colspan='3'> </td></tr> "+
"</table> "+
"<table width='100%'><tr><td>DIAGNOSIS:</td></tr> "+
"<tr><td>Medical Diagnosis: R shoulder pain with probable
tendonitis. </td></tr> "+
"<tr><td>Return Referring Provider appointment scheduled:
Yes</td></tr> "+
"<tr><td>Onset Date of Current Episode: February/March
</td></tr> "+
"<tr><td> </td></tr> "+
"<tr><td>HISTORY OF PRESENT ILLNESS:</td></tr> "+
"<tr><td>Chief Complaint: R shoulder pain. </td></tr> "+
"<tr><td>Prior Level of Function: Able to pull and reach across
the body. Patient was able to lift and carry without increased pain.
</td></tr> "+
"<tr><td>Mechanism of Injury/History of Present Illness: Pt had
a gradual onset of right shoulder pain without any specific incident.
</td></tr> "+
"<tr><td> </td></tr> "+
"<tr><td>EMPLOYER INFORMATION:</td></tr> "+
"<tr><td>Employer: Gundersen Lutheran</td></tr> "+
"<tr><td>Occupation: pshychometrist</td></tr> "+
"<tr><td>Department: NeuroScience. </td></tr> "+
"<tr><td>Occupational Demands/Stresses: Carrying, reaching,
assisting patients. </td></tr> "+
"<tr><td> </td></tr> "+
"<tr><td>CURRENT WORK STATUS:</td></tr> "+
"<tr><td>Current Work Status: Regular
Duty<tr><td> </td></tr> "+
"<tr><td>MEDICAL HISTORY:</td></tr> "+
"<tr><td>General Health: Good</td></tr> "+
"<tr><td>Diagnostic Tests Completed: No</td></tr> "+
"<tr><td>Regular Exercise: No</td></tr> "+
"<tr><td>Relevant Medical History:
Patient Reports: Heart</td></tr> "+
"<tr><td>Relevant/Recent Surgeries: No</td></tr> "+
"<tr><td>Any unexplained weight loss: No</td></tr> "+
"<tr><td>History of falls: No</td></tr> "+
"<tr><td>At Risk for Falls: No</td></tr> "+
"<tr><td>Abuse/Safety screen completed: Yes</td></tr> "+
"<tr><td>Action Taken: No action required</td></tr> "+
"<tr><td> </td></tr> "+
"<tr><td>CERVICAL SPINE PAIN:</td></tr> "+
"<tr><td>Pain location: Cervical Spine</td></tr> "+
"<tr><td>Pain scale: 0</td></tr> "+
"<tr><td> </td></tr> "+
"<tr><td>UPPER EXTREMITY PAIN SYMPTOMS Upper Extremity Pain
Symptoms Upper Extemity Pain Symptons:</td></tr> "+
"<tr><td>Current Symptoms: Intermittent, dull, aching R anterior
and posterior shoulder pain this is making the line a little longer .
</td></tr> "+
"<tr><td>Symptoms at Onset: As above. </td></tr> "+
"<tr><td>Have you had these symptoms in the past? No</td></tr>
"+
"<tr><td> </td></tr> "+
"<tr><td>UPPER EXTREMITY PAIN:</td></tr> "+
"<tr><td>Pain location: Upper Extremity</td></tr> "+
"<tr><td>Pain diagram: (Red: Point of worst pain, Black: Pain
outline) The image should appear just
below this text the image is a blob</td></tr>" +
"<tr rowspan=5><td> C:\\PDFReports\\image\\blob.jpg </td></tr>
"+
"<tr><td>Quality:</td></tr> "+
"<tr><td> Sharp,
Intermittent</td></tr> "+
"<tr><td> Dull,
Intermittent</td></tr> "+
"<tr><td> Other: aching</td></tr>
"+
"<tr><td>Status since onset of symptoms is: Unchanging</td></tr>
"+
"<tr><td>Pain scale: 1</td></tr> "+
"<tr><td>No Previous Treatment</td></tr> "+
"<tr><td>Comments: Pain is rated at 1-5/10. </td></tr> "+
"<tr><td> </td></tr> "+
"<tr><td>UPPER EXTREMITY QUESTIONS:</td></tr> "+
"<tr><td>Handedness: Right</td></tr> "+
"</table> "+ //added this - dawn
//"<tr><td> "+ //commented this dawn
"<table class='TableWithBorders' ><tr><td class='CellBorderOn'
style='font-weight:bold' colspan='2' >Shoulder</td></tr><tr> "+
"<td class='CellBorderOn' style='font-weight:bold' colspan='1'
>Action</td><td class='CellBorderOn' style='font-weight:bold' colspan='1'
>Symptoms</td></tr> "+
"<tr><td class='CellBorderOnLeft' >Reaching Overhead </td><td
class='CellBorderOn' >No Effect</td></tr> "+
"<tr><td class='CellBorderOnLeft' >Reaching behind Back </td><td
class='CellBorderOn' >Worse</td></tr> "+
"<tr><td class='CellBorderOnLeft' >Hooking Bra </td><td
class='CellBorderOn' >No Effect</td></tr> "+
"<tr><td class='CellBorderOnLeft' >Toileting </td><td
class='CellBorderOn' >Worse</td></tr> "+
"</table></html> ";
//The html from the database uses a stylesheet to format the note
when viewed in the browser.
//iText cannot access this stylesheet, so we need to define the
necessary styles here.
StyleSheet styles = new StyleSheet();
//styles.loadTagStyle("td","leading", "7,0"); //leading adjusts the
space between the lines in this case it makes the image hide part of the
note
styles.loadTagStyle("td", "size", "12pt");
styles.loadTagStyle("td", "face", "arial");
styles.loadStyle("TableWithBorders", "style","outset");
styles.loadStyle("TableWithBorders","border","1");
styles.loadStyle("CellBorderOnLeft","border","1");
styles.loadStyle("CellBorderOnLeft","style","solid");
styles.loadStyle("CellBorderOnLeft","valign","top");
styles.loadStyle("CellBorderOnLeft","align","left");
styles.loadStyle("CellBorderOn","width","1");
styles.loadStyle("CellBorderOn","valign","top");
styles.loadStyle("CellBorderOn","align","center");
Document document = new Document(); //Step 1 create the document
object
outPutFile = outPutPath + lngDate+ "_Report.pdf";
FileOutputStream fo = new FileOutputStream(outPutFile);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PdfWriter writer = PdfWriter.getInstance(document,fo); //step 2
create a writer
writer.setPageEvent(new NoteImage4());
//writer.setStrictImageSequence(true); //thought this would keep
image below the text
document.setMargins(25, 25, 30, 30); //left,right,top,bottom
document.open();
ArrayList p = HTMLWorker.parseToList(new
StringReader(HospNote),styles);
Element e;
for (int k=0;k<p.size(); ++k){
e = (Element)p.get(k);
if (e instanceof PdfPTable) {
((PdfPTable)e).setSplitLate(false);
}
document.add(e); //step 4 adding content- the
note
}
//iText method onOpen is called here
document.close();
}//end try
catch(Exception e){
System.err.println("Viewing error in NoteImage4.java makePdf()"
+ e);
e.printStackTrace();
}
} //end makePDF
} //end class
--
View this message in context:
http://old.nabble.com/parseToList-html-and-setLeading-with-image-in-html-code-tp27540307p27540307.html
Sent from the iText - General mailing list archive at Nabble.com.
------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions:
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/