Normal Topic Needs help with Fontsize with PrintString ( ) (Read 920 times)
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Needs help with Fontsize with PrintString ( )
Mar 22nd, 2012 at 6:05am
Print Post Print Post  
I use Arial font with fontsize = 17 that is equivalent to 11 of MS Word. I also put " Arial" for regular font and "BArial" for Bold.

I have need to printout records that goes into next page quite a few times. If I printout a single record, I have no problem, the fontsize remains 11 and it looks perfect. But if I print out multiple records using ResultSet either with Mass Update or Resultset with command button using loop, frequently the new record start printing with fontsize 12 (larger) and that mess up my changing page at proper location and leads to overflow. If I printout that record as a single record it prints perfectly well with fontsize 11.  No where I have placed vFontsize other than 17.

At first glance, it appears random but it definitely has some pattern!! I have noted that this things frequently but not always happens after printing out second page of the record that places page number at the bottom centered and Date aligned Right, does that have to do anything? The record following the single page printout of a record never mess up. It is only the first page is affected and when it is affected it is the whole page. The second page of the record is always with Fontsize 11 even when the first page is affected.

I have used vFontsize as stat variable in global Area and I re-initialized it frequently to reset to 17 in case something changes it to larger for some unknown reasons, but that is of a little help. Well, may be it is of help because the pages start printing normally again until something throws it off again!!

In the element text property, the fontsize is uniformly 12, could that have to do with printing out size 12. Just trying find some logic !!! Sad

I just can't understand, how it is happening... Any suggestions? 
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Needs help with Fontsize with PrintString ( )
Reply #1 - Mar 22nd, 2012 at 1:23pm
Print Post Print Post  
Hello Bharat,

I would need to see the code on this one to say for sure what is going on. When you get a moment shoot the DSR and DDT files over to support@lantica.com and just let me know what button the code is in and I'll see if I can't find the culprit.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Needs help with Fontsize with PrintString ( )
Reply #2 - Mar 22nd, 2012 at 3:11pm
Print Post Print Post  
Yes, I can certainly send you the files but without massive data, it will be difficult to test. Would it do if I send you the code and printed out pdf files for you to look at? Just wondering.

In the meantime what I have done is,  increased the bottom margin that acts as a buffer for overflow of text in case the fonts becomes bigger.  That way I am ensuring that no data is missed out while printed.  It will look a little different when looking at a record printed out by itself and one which is printed out in a  batch. But that is tolerable. 
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Needs help with Fontsize with PrintString ( )
Reply #3 - Mar 22nd, 2012 at 3:17pm
Print Post Print Post  
Hello Bharat,

All I should need to see is the code. I have a hunch as to what it is but it's difficult to put into words and explain.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Needs help with Fontsize with PrintString ( )
Reply #4 - Mar 22nd, 2012 at 5:17pm
Print Post Print Post  
Hi Ray, I will send the printed pdf files to support. But here is the code:

Code in Global Code:
Code
Select All
//======================== variables for Print Physical in PDF============================

stat vExamDate as String
stat vFont as String = " Arial"
stat vFontsize as Int = 17
stat vSignature as String = @XLookup ("Data\Doctor.db", @UserID, "Doctor!UserID", "Signature") 
stat vPage as Int
stat vPrintIndicator as String
stat vYExtent as Int
stat vStopReset as Int = 0
stat vDoctor as String


//===================================================================================


Function UDF_FormatDate (vDate as String) as String

	var vFormatedDate as String

	vFormatedDate = @Mid (vDate, 6,2) + "/" + @Right (vDate, 2) + "/" + @Left (vDate, 4)
	Return (vFormatedDate)
End Function


//==========================================================================================================================================================================================================================================================================




SubRoutine CompleteTask ( )

PrintString (vDoctor, 550, @PageExtentY ( ) + 10, 0, vFont, vFontSize, 0)
if @GlobalValue ("SignatureOnPhysicalPrintStringHC") = 1 then
			{
				PrintImage (vSignature, 550, @PageExtentY ( ) + 2, -1, -1)
				//PrintImage ("C:\images\bharat_sig.jpg", 550, @PageExtentY ( ) + 2, -1, -1)
			}
If vPage > 1 then
			{
				//WriteLN ("You were in CompleteTask")  //************************************************************************************************************************************************
				PrintString (vExamDate, 0, 1060, 0, vFont, vFontsize, 0, PrintString_Align_Right)
				PrintString ("Page " + @str (vPage), 0, 1060, 0, vFont, vFontsize, 0, PrintString_Align_Center)
				PrintString (First + " " + P_LastName + " - " + RecNumber, 0, 1060, 0, vFont, vFontsize, 0, PrintString_Align_Left )
			}
vStopReset = 1
vFontsize = 17  //To Make sure after align Center
FinishPage ( )
//RestoreDefaultPrinter ( )
//Stop   //stop is replaced with vStopReset

End Subroutine

SubRoutine PageControlMeasure(vString as String )   //This includes PageControl ( )
//If @PageExtentY ( ) > 850 then  //corrected for overflow to work correctly - this can be removed totally as it is controlled in the main programming
		//{

			If vPage > 1 then     // This is in case there is Page 3
			{
				PrintString (vExamDate, 0, 1060, 0, vFont, vFontsize, 0, PrintString_Align_Right) //put on 03/20/2012
				PrintString ("Page " + @str (vPage), 0, 1060, 0, vFont, vFontsize, 0, PrintString_Align_Center)
				PrintString (First + " " + P_LastName + " - " + RecNumber, 600, 1060, 0, vFont, vFontsize, 0)
			}

			FinishPage ( )
			NewPage (850, 1100)
			vFontsize = 17  //To Make sure after align Center
			PageExtentY (0)
			vYExtent = 0

			//WriteLN ("This will go on 2nd Page " + vString)    //*************************************************************************************************************************

			PrintString (vString, 0, vYExtent, 0, vFont, vFontSize, 0)
			VPrintIndicator = "Printed"  //to avoid printing twice
			vPage = vPage + 1

		//}
End SubRoutine


SubRoutine PageControl( )   //Created just to put at the end otherwise PageControlMeasure ( ) will do
If @PageExtentY ( ) > 1050 then
		{
			If vPage > 1 then
			{
				PrintString (vExamDate, 0, 1060, 0, vFont, vFontsize, 0, PrintString_Align_Right) //put on 03/20/2012
				PrintString ("Page " + @str (vPage), 0, 1060, 0, vFont, vFontsize, 0, PrintString_Align_Center)
				PrintString (First + " " + P_LastName + " - " + RecNumber, 600, 1060, 0, vFont, vFontsize, 0)
			}

			FinishPage ( )
			NewPage (850, 1100)
			vFontsize = 17  //To Make sure after align Center
			PageExtentY (0)
			vPage = vPage + 1
		}
End SubRoutine

SubRoutine Printing_Physical (vSelectedDate as String)
var n as Int
var vRSHandle as Int

var vRSScripts1 as Int
var vRSScripts2 as Int




//==========================================for Print Physical==========================




//var vPrinterA as String                             //= "IBM 4039 LaserPrinter"  //Local Printer
//var vPrinterB as String                             //= "\\Reception\IBMPCL5"  //Network Printer
var vStr1 as String
var vStr2 as String
var vStr3 as String
//var n as Int
var vLoop as Int


var vChart as String
var vBP as String
var vHC as String
var vGrowthBlock as String
var vBreastBlock as String



//var vServer as String
//var vStation as String
//var vPhysicalPrintStringPrinterSelect as Int
//var vServerDefault as String
//var vSignatureOnPhysicalPrintString as Int

//var vPrinterList as String
//var vSelectedPrinter as String
//var vList as String



var vMedicine as String
var vInstruction as String
var vWarn as Int













//Functions below is in Global area

//all variables to code below are defined in the begining of code




vRSHandle = @XResultSetSearch(@FN, "Physical", SEARCH_MODE_AND, SEARCH_SYNTAX_QA, "!Chart="+ Chart, "!Date1=" + vSelectedDate)
	if(vRSHandle > -1)
	{


		vDoctor = @XResultSetValue (vRSHandle, "DN")
		// ????   vExamDate = UDF_FormatDate (@XResultSetValue (vRSHandle, "Date1"))


		vExamDate = @XResultSetValue (vRSHandle, "Date1")
		vChart = Chart   //Now Chart are there in all forms
		vChart = vChart + "-" + @Right (@XResultSetValue (vRSHandle, "Q"), 3)
		If @XResultSetValue (vRSHandle, "BP") <> "" then
			{
				vBP = "BP: " + @XResultSetValue (vRSHandle, "BP")
			}
		If @XResultSetValue (vRSHandle, "HC") <> "" then
			{
				vHC = "Head Circum: " + @XResultSetValue (vRSHandle, "HC")
			}
		VGrowthBlock = Tab (1) + @XResultSetValue (vRSHandle, "W")

		If @XResultSetValue (vRSHandle, "H") <> "" then
			{
			 	vGrowthBlock = vGrowthBlock +  @NL ( ) + Tab (1) + @XResultSetValue (vRSHandle, "H")
			}
		If @XResultSetValue (vRSHandle, "C") <> "" then
			{
			 	vGrowthBlock = vGrowthBlock +  @NL ( ) + Tab (1) + @XResultSetValue (vRSHandle, "C")
			}
		If @XResultSetValue (vRSHandle, "HW") <> "" then
			{
			 	vGrowthBlock =  vGrowthBlock + @NL ( ) + Tab (1) + @XResultSetValue (vRSHandle, "HW")
			}

		//Parameters: Value, xpos, ypos, column Width, Font, FontSize, measureOnly, Alignment

		NewPage (850, 1100)
		PrintPagePaper (28)

		PrintPageMargin (30, 35, 40, 40)
		vFont = " Arial"
		vFontsize = 17

		PrintString ("Name: " + First + " " + P_LastName, 0, 0, 0, vFont, vFontSize, 0)
		PrintString ("Rec#: " + RecNumber, @PageExtentX ( ) + 30, -1, 0, vFont, vFontSize, 0)
		PrintString ("Date: " + UDF_FormatDate (@XResultSetValue (vRSHandle, "Date1")), @PageExtentX ( ) + 30, -1, 0, vFont, vFontSize, 0)
		PrintString ("Chart# " + vChart, @PageExtentX ( ) + 30, -1, 0, vFont, vFontSize, 0)

		PrintString ("VITAL SIGNS", 0, @PageExtentY ( ) + 10, 0, "BArial", vFontSize, 0)
		PrintRGBColor (1, 0, 0)
		PrintBox (Box_Type_Flat_Box, 0, @PageExtentY ( ), @PageExtentX( ), 1)

		PrintString ("Weight: " + @XResultSetValue (vRSHandle, "WT"), 0, @PageExtentY ( ), 200, vFont, vFontSize, 0)
		PrintString ("Height: " + @XResultSetValue (vRSHandle, "HT"), -1, -1, 200, vFont, vFontSize, 0)
		PrintString ("Temp: " + @XResultSetValue (vRSHandle, "T"), -1, -1, 200, vFont, vFontSize, 0)
		PrintString ("BMI: " + @XResultSetValue (vRSHandle, "BMI"), -1, -1, 150, vFont, vFontSize, 0)

		PrintString ("Pulse: " + @XResultSetValue (vRSHandle, "P"), 0, @PageExtentY ( ), 200, vFont, vFontSize, 0)
		PrintString ("Resp: " + @XResultSetValue (vRSHandle, "R"), -1, -1, 200, vFont, vFontSize, 0)
		If vBP <> "" then
			{
				PrintString (vBP, -1, -1, 200, vFont, vFontSize, 0)
			}
			Else
			{
				PrintString (vHC, -1, -1, 200, vFont, vFontSize, 0)
			}

			If  @XResultSetValue (vRSHandle, "LMP") <> ""   then
			   {	    	  
				PrintString ("LMP: " + UDF_FormatDate (@XResultSetValue (vRSHandle, "LMP")), 0, @PageExtentY ( ), 200, vFont, vFontSize, 0)
			   }
			IF @XResultSetValue (vRSHandle, "LDP") <> ""  then
			 {
			   If @XResultSetValue (vRSHandle, "LMP") <> "" then
			   {		   
				PrintString ("LastDepo: " + UDF_FormatDate (@XResultSetValue (vRSHandle, "LDP")), -1, -1, 200, vFont, vFontSize, 0)
			   }
			 Else
			   {
				PrintString ("LastDepo: " + UDF_FormatDate (@XResultSetValue (vRSHandle, "LDP")), 0, @PageExtentY (), 200, vFont, vFontSize, 0)
			   }
			 }
			If @XResultSetValue (vRSHandle, "FP") <> "" then
		         {
		          	  If @XResultSetValue (vRSHandle, "LMP") <> ""  or @XResultSetValue (vRSHandle, "LDP") <> "" then
					{
						PrintString ("FP: " + @XResultSetValue (vRSHandle, "FP"), -1, -1, 0, vFont, vFontSize, 0)
					}
				     Else
					{
						PrintString ("FP: " + @XResultSetValue (vRSHandle, "FP"), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
					}
			}

		PrintString (vGrowthBlock, 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)

		PrintString ("HISTORY OF PRESENT ILLNESS", 0, @PageExtentY ( ) + 5, 0, "BArial", vFontSize, 0)
		PrintRGBColor (1, 0, 0)
		PrintBox (Box_Type_Flat_Box, 0, @PageExtentY ( ), @PageExtentX( ), 1)

		PrintString ("The Patient is " + @XResultSetValue (vRSHandle, "Age") + " old " + @XResultSetValue (vRSHandle, "SEX") + ".", 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
		PrintString (@XResultSetValue (vRSHandle, "HIS1") + " " + @XResultSetValue (vRSHandle, "HIS2") + " "  + @XResultSetValue (vRSHandle, "HIS3"), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)

		PrintString ("PHYSICAL EXAMINATION", 0, @PageExtentY ( ) + 5, 0, "BArial", vFontSize, 0)
		PrintRGBColor (1, 0, 0)
		PrintBox (Box_Type_Flat_Box, 0, @PageExtentY ( ), @PageExtentX( ), 1)

		PrintString (@XResultSetValue (vRSHandle, "GRL"), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
		PrintString (@XResultSetValue (vRSHandle, "HN"), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
		PrintString (@XResultSetValue (vRSHandle, "Eyes"), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
		PrintString (@XResultSetValue (vRSHandle, "Ears"), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
		PrintString (@XResultSetValue (vRSHandle, "Lung"), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
		PrintString (@XResultSetValue (vRSHandle, "CVS"), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
		PrintString (@XResultSetValue (vRSHandle, "Breast"), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
		PrintString (@XResultSetValue (vRSHandle, "ABD"), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
		PrintString (@XResultSetValue (vRSHandle, "Skin"), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
		PrintString (@XResultSetValue (vRSHandle, "Joint"), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
		PrintString (@XResultSetValue (vRSHandle, "Ext"), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
		PrintString (@XResultSetValue (vRSHandle, "Gtal"), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
		PrintString (@XResultSetValue (vRSHandle, "CNS"), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
		PrintString (@XResultSetValue (vRSHandle, "Rtal"), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
		PrintString (@XResultSetValue (vRSHandle, "LymphN"), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)

		PrintString ("PERTINENT LAB, XRAY AND OTHER DIAGNOSIC WORKUP", 0, @PageExtentY ( ) + 5, 0, "BArial", vFontSize, 0)
		PrintRGBColor (1, 0, 0)
		PrintBox (Box_Type_Flat_Box, 0, @PageExtentY ( ), @PageExtentX( ), 1)

		PrintString (@XResultSetValue (vRSHandle, "AB_Lab"), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
		IF @XResultSetValue (vRSHandle, "Lab") <> "" or @XResultSetValue (vRSHandle, "Xray1") <> "" then
			{
				PrintString (@XResultSetValue (vRSHandle, "Lab") + " " + @XResultSetValue (vRSHandle, "Xray1"), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
			}
		If @XResultSetValue (vRSHandle, "HB") <> "" or @XResultSetValue (vRSHandle, "Tine") <> "" or @XResultSetValue (vRSHandle, "Blood_Glucose") <> "" then
			{
				PrintString (@XResultSetValue (vRSHandle, "HB") + " " + @XResultSetValue (vRSHandle, "Tine") + " " + @XResultSetValue (vRSHandle, "Blood_Glucose"), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
			}
		PrintString (@XResultSetValue (vRSHandle, "UD"), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
		PrintString (@XResultSetValue (vRSHandle, "Hearing"), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
		//PrintString (Imm, 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
		PrintString (@XResultSetValue (vRSHandle, "Imm"), 0, @PageExtentY ( ), 0, vFont, 12, 0)

		PrintString ("DIAGNOSIS AND ASSESSMENT", 0, @PageExtentY ( ) + 5, 0, "BArial", vFontSize, 0)
		PrintRGBColor (1, 0, 0)
		PrintBox (Box_Type_Flat_Box, 0, @PageExtentY ( ), @PageExtentX( ), 1)

		PrintString (@Left (@XResultSetValue (vRSHandle, "Cond1"), (@Len(@XResultSetValue (vRSHandle, "Cond1")) -7)), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
		PrintString (@Left (@XResultSetValue (vRSHandle, "Cond2"), (@Len(@XResultSetValue (vRSHandle, "Cond2")) -7)), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
		PrintString (@Left (@XResultSetValue (vRSHandle, "Cond3"), (@Len(@XResultSetValue (vRSHandle, "Cond3")) -7)), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)

		PrintString ("CHRONIC ONGOING PROBLEMS", 0, @PageExtentY ( ) + 5, 0, "BArial", vFontSize, 0)
		PrintRGBColor (1, 0, 0)
		PrintBox (Box_Type_Flat_Box, 0, @PageExtentY ( ), @PageExtentX( ), 1)

		PrintString (@XResultSetValue (vRSHandle, "Chr_Problems"), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)

		PrintString ("TREATMENT PLAN", 0, @PageExtentY ( ) + 5, 0, "BArial", vFontSize, 0)
		PrintRGBColor (1, 0, 0)
		PrintBox (Box_Type_Flat_Box, 0, @PageExtentY ( ), @PageExtentX( ), 1)




vRSScripts1 = @XResultSetSearch(@FN, "Physical!Scripts1", SEARCH_MODE_AND, SEARCH_SYNTAX_QA, "!RecNumber="+ RecNumber, "!Date1=" + vSelectedDate)
	if(vRSScripts1 > -1)
	{

		//WriteLN ("You are here in Scripts1 form")
		//WriteLN ("Total Records = " + @Str (  @XResultSetTotal (vRSScripts1)   ))
		For n = 1 to @XResultSetTotal (vRSScripts1)
			XResultSetCurrentPosition (vRSScripts1, n)
			vMedicine = @XResultSetValue (vRSScripts1, "Medicine")

			//WriteLN (vMedicine)
			vInstruction = @XResultSetValue (vRSScripts1, "Instruction")
			If vMedicine <> "" then
				{
					vStr3 = vMedicine + " " + vInstruction
					//WriteLN ("vStr3 vaule = " + vStr3 )
					vYExtent = @PageExtentY ( )
					//WriteLn ("Value of vYExtent = " + @Str (vYExtent) )
					PrintString (vStr3, 0, @PageExtentY ( ), 0, vFont, vFontSize, 1)
					vPrintIndicator = "Not Printed"  //Avoid double printing, Reset to printed if printed through pagecontrolMeasure ( )
					If vPage = 1 and vYExtent >= 1050 then //Added Later on so Prescriptions do not start printing on 2nd Page too soon
					{
						PageControlMeasure (vStr3)
					}
					If vPage = 1 or (vPage = 2 and vPrintIndicator = "Not Printed") then
						{
							PrintString (vStr3, 0, vYExtent, 0, vFont, vFontSize, 0)
						}

				}
		Next


		XResultSetClose (vRSScripts1)
	}



vRSScripts2 = @XResultSetSearch(@FN, "Physical!Scripts2", SEARCH_MODE_AND, SEARCH_SYNTAX_QA, "!RecNumber="+ RecNumber, "!Date1=" + vSelectedDate)
	if(vRSScripts2 > -1)
	{


		For n = 1 to @XResultSetTotal (vRSScripts2)
			XResultSetCurrentPosition (vRSScripts1, n)
			vMedicine = @XResultSetValue (vRSScripts2, "Medicine")
			vInstruction = @XResultSetValue (vRSScripts2, "Instruction")
			If vMedicine <> "" then
				{
					vStr3 = vMedicine + " " + vInstruction
					vYExtent = @PageExtentY ( )
					PrintString (vStr3, 0, @PageExtentY ( ), 0, vFont, vFontSize, 1)
					vPrintIndicator = "Not Printed"  //Avoid double printing, Reset to printed if printed through pagecontrolMeasure ( )
					If vPage = 1 and vYExtent >= 1050 then //Added Later on so Prescriptions do not start printing on 2nd Page too soon
					{
						PageControlMeasure (vStr3)
					}
					If vPage = 1 or (vPage = 2 and vPrintIndicator = "Not Printed") then
						{
							PrintString (vStr3, 0, vYExtent, 0, vFont, vFontSize, 0)
						}

				}
		Next


		XResultSetClose (vRSScripts2)
	}









		vYExtent = @PageExtentY ( )

		PrintString (@XResultSetValue (vRSHandle, "AD1") + " " + @XResultSetValue (vRSHandle, "AD2") + " " + @XResultSetValue (vRSHandle, "AD3") + " " + @XResultSetValue (vRSHandle, "ADP"), 0, vYExtent, 0, vFont, vFontSize, 1)

		//writeLN ("Step 1 " + @Str (@PageExtentY ( ) )) //*********************************************************************************************************************************************
		If @PageExtentY () <= 1100 then
			{
				PrintString (@XResultSetValue (vRSHandle, "AD1") + " " + @XResultSetValue (vRSHandle, "AD2") + " " + @XResultSetValue (vRSHandle, "AD3") + " " + @XResultSetValue (vRSHandle, "ADP"), 0, vYExtent, 0, vFont, vFontSize, 0)
			}
			Else
			{
				PageExtentY (vYExtent)
				PrintString (@XResultSetValue (vRSHandle, "AD1") + " " + @XResultSetValue (vRSHandle, "AD2") + " " + @XResultSetValue (vRSHandle, "AD3"), 0, vYExtent, 0, vFont, vFontSize, 1)
				//WriteLn (@PageExtentY ( ))
					If @PageExtentY () < 1100 and vPage = 1 and vStopReset = 0 then
						{
							//writeLN ("Step 2 " + @Str (@PageExtentY ( ) )) //*********************************************************************************************************************************************
							PrintString (@XResultSetValue (vRSHandle, "AD1") + " " + @XResultSetValue (vRSHandle, "AD2") + " " + @XResultSetValue (vRSHandle, "AD3"), 0, vYExtent, 0, vFont, vFontSize, 0)
							PageControlMeasure (@XResultSetValue (vRSHandle, "ADP"))
							CompleteTask ( )
						}
		      
				PageExtentY (vYExtent)
				PrintString (@XResultSetValue (vRSHandle, "AD1") + " " + @XResultSetValue (vRSHandle, "AD2"), 0, vYExtent, 0, vFont, vFontSize, 1)
				//WriteLN (@PageExtentY ( ) )
					If @PageExtentY () < 1100 and vPage = 1 and vStopReset = 0 then
						{
							//writeLN ("Step 3 " + @Str (@PageExtentY ( ) )) //*********************************************************************************************************************************************
							PrintString (@XResultSetValue (vRSHandle, "AD1") + " " + @XResultSetValue (vRSHandle, "AD2"), 0, vYExtent, 0, vFont, vFontSize, 0)
							PageControlMeasure (@XResultSetValue (vRSHandle, "AD3") + " " + @XResultSetValue (vRSHandle, "ADP"))
							CompleteTask ( )
						}

				PageExtentY (vYExtent)
				PrintString (@XResultSetValue (vRSHandle, "AD1"), 0, vYExtent, 0, vFont, vFontSize, 1)
				//WriteLN (@PageExtentY ( ) )
					If @PageExtentY () < 1100 and vPage = 1 and vStopReset = 0 then

						{
							//writeLN ("Step 4 " + @Str (@PageExtentY ( ) )) //*********************************************************************************************************************************************
							PrintString (@XResultSetValue (vRSHandle, "AD1"), 0, vYExtent, 0, vFont, vFontSize, 0)
							PageControlMeasure (@XResultSetValue (vRSHandle, "AD2") + " " + @XResultSetValue (vRSHandle, "AD3") + " " + @XResultSetValue (vRSHandle, "ADP"))
							CompleteTask ( )

						}
			}

		//writeLN ("Step 5 " + @Str (@PageExtentY ( ) )) //*********************************************************************************************************************************************



		If vStopReset = 0 and @PageExtentY ( ) <= 1060 then    //This works only for Page#, if more pages then CompleteTask subroutine takes over
			{

				PrintString (@XResultSetValue (vRSHandle, "DN"), 550, @PageExtentY ( ) + 10, 0, vFont, vFontSize, 0)


					if @GlobalValue ("SignatureOnPhysicalPrintStringHC") = 1 then
					{
						//WriteLN ("You are Here")
						PrintImage (vSignature, 550, @PageExtentY ( ) + 2, -1, -1)
						//PrintImage ("C:\images\bharat_sig.jpg", 550, @PageExtentY ( ) + 2, -1, -1)
					}
				FinishPage ( )
				//RestoreDefaultPrinter ( )
			}
			Else if vStopReset = 0 and @PageExtentY () > 1060 then
			{
				PageControlMeasure ("")
				CompleteTask ( )
			}

	     xResultSetClose (vRSHandle)
	}



End SubRoutine


//============================================


 



Code in Command Button (Medical Record)

Code
Select All
var vPrinter1 as String = "DocuCom PDF Driver"
var vPrinter2 as String = @GlobalValue ("ServerDefaultPrinter")
var vPath1 as String = "C:\PDFiles\"
var vPath3 as String = "C:\Sesame2\Records\"
var vPage1 as Int
var vSuccess as Int
var vRS as Int
var vLoop as Int
var vTotalRecords as Int
var vVisitDate as Date
var vName as String = First + " " + P_LastName

var vFiles as String
var vFilesWithPath as String
var vFinalFile as String
var n as Int

var vString1 as String


var vRSHandle as Int
var vDescription as String
var vFilename as String
var vExtFields as String = ""
var vNoOfRecords as Int
var vLastFile as String
var vFile as String


		AlternateDefaultPrinter ("DocuCom PDF Driver")
		vSuccess = @Shell ("Del " + vPath1 + "*.pdf" )




	vRS = @XResultSetSearch(@FN, "Physical", SEARCH_MODE_AND, SEARCH_SYNTAX_QA, "!Chart=" + Chart)    // Since Physical also have Chart element and Chart# never changes
	if(vRS > -1)
	{
		//AlternateDefaultPrinter (vPrinter1)
		vTotalRecords = @XResultSetTotal(vRS)
		xResultsetSort (vRS, "Date1:1")
		for vLoop = 1 to vTotalRecords
			XResultSetCurrentPosition(vRS, vLoop)
			WriteLN ("Processing Visit " + @Str (vLoop) + " of " + @Str (@XResultSetTotal(vRS)) )

			vVisitDate = @XResultSetValue(vRS, "Date1")
			vFontsize = 17
			vFont = " Arial"
			vPage = 1
			vStopReset = 0
			Printing_Physical (vVisitDate)

		next

		XResultSetClose(vRS)
	}
CLS ( )
CloseSlate ( )

vFile  = @LocalListDirectory ("C:\PDFiles\")
vFile = vPath1 + vFile

For n = 1 to 10

		If FileExists (vFile) then
			{
				n = 10
			}
			Else
			{
				Loiter (1000)

			}


Next




If @CountStringArray (vFiles) > 1 then
	{
		//vFiles = @SortStringArray (vFiles, 0)
		For n = @CountStringArray (vFiles) downto 1

				If vFilesWithPath = "" then
					{
						vFilesWithPath = @Chr (34) + vPath1 + @AccessStringArray (vFiles, n) + @chr (34)
					}
					Else
					{
						vFilesWithPath = vFilesWithPath + ";" + @Chr (34) + vPath1 + @AccessStringArray (vFiles, n) + @chr (34)

					}

		Next







		vFilesWithPath = @Replace (vFilesWithPath, ";", " ")
		//WriteLN (vFilesWithPath)
		vFinalFile =  vPath1 +  vName  + " " + @Month(@Date) + "-" + @DOM (@date) + "-" + @Year (@date) +  "-visitnotes" + ".pdf"
		//WriteLN (vFinalFile)
		vSuccess = @Shell ( "PDFill.exe MERGE " + vFilesWithPath + " " + @chr (34) + vFinalFile + @chr (34) )



	}
	Else
	{
		vFilesWithPath = @Chr (34) + vFile + @Chr (34)  // since there is a space in the name

		//vFileName = vPath1 + vName + " " + @Month(@Date) + "-" + @DOM (@date) + "-" + @Year (@date)+ ".pdf"
		//vSuccess = @AsynchShell (@Chr (34) + vPath1 + vFiles + @Chr (34))
	}




//*********** Now Working with Documents File


//========= Following Routine Check the Documents file Exists on not and if does not give you choice to delete that record before merging them in pdf files

			vRSHandle = @XResultSetSearch(@FN, "Index!Documents", SEARCH_MODE_AND, SEARCH_SYNTAX_QA, "!Chart=" + Chart)

		If vRSHandle > -1 then
			{
				xResultSetSort (vRSHandle, "DateAdded:1")
					n = @XResultSetTotal (vRSHandle)

					While n >= 1
						{
							xResultSetCurrentPosition (vRSHandle, n)
							vDescription = @xResultSetValue (vRSHandle, "Description" )
							//WriteLN (vDescription)
							vFileName = @xResultSetValue (vRSHandle, "FileName" )  //Checking it again to make certain that no good record is deleted)
							//WriteLN (vFileName)
							If Not Fileexists (vFileName)
								{
									If @AskUser (vDescription + " file does not exist, Do you Want to Delet the Record?", "", "") then
										{
											xResultSetDeleteRecord (vRSHandle)
										}
						 		}
							//WriteLN (@str (n))
							n = n - 1
						}



				xResultSetClose (vRSHandle)

			}


//******************************Convert RTF and PDF File *****************************************************************************************

vFinalFile =  vPath3 +  vName  + " " + @Month (@date) + "-" + @DOM (@date) + "-" + @Year (@date)+".pdf"




vSuccess = @Shell ( "RUNDLL32 PRINTUI.DLL,PrintUIEntry /y /n " +  @Chr (34) + vPrinter1 + @chr (34) )

vRSHandle = @XResultSetSearch(@FN, "Index!Documents", SEARCH_MODE_AND, SEARCH_SYNTAX_QA, "!Chart=" + Chart, "!Print=<>NO")
if(vRSHandle > -1)
	{
		vNoOfRecords = @XResultSetTotal(vRSHandle)


			for vLoop = 1 to vNoOfRecords
			XResultSetCurrentPosition(vRSHandle, vLoop)
			vFileName = @XResultSetValue(vRSHandle, "FileName")
			if @Right (vFileName, 3) = "rtf" then
				{

					MergeFilePrint(vFileName, "rtf", "", "", vExtFields, "", 0)
					For n = 1 to 10

					If FileExists ("c:\PDFiles\temporary.pdf") then
						{
							n = 10
						}
						Else
						{
							Loiter (1000)

						}


					Next

					vSuccess = @Shell ("Ren " + vPath1 + "Temporary.pdf" + " " + "Temporary" + @Str (vLoop) + ".pdf" )



						If @CountStringArray (vFiles) >= 1 then
							{
								For n = 1 to @CountStringArray (vFiles)
									If vFilesWithPath = "" then
										{
											vFilesWithPath = vPath1 + @AccessStringArray (vFiles, n)
										}
										Else
										{
											vFilesWithPath = vFilesWithPath + ";" + vPath1 + @AccessStringArray (vFiles, n)


										}
								Next

							}
				}


			Else if @Right (vFileName, 3) = "pdf" then
					{
						vFilesWithPath = vFilesWithPath + ";" + vFileName
						//vSuccess = @Shell ("Copy " + @Chr (34) + vFileName + @Chr (34) + " " +  @Chr (34) + vPath1 + "Document" + @str (vLoop) + ".pdf" + @Chr (34) )


					}

			next
			//WriteLn (vFilesWithPath)
			XResultSetClose(vRSHandle)
	}



vFiles = @LocalListDirectory ("C:\PDFiles\")


		vLastFile = @AccessStringArray (vFilesWithPath, @CountStringArray (vFilesWithPath) )

	If @CountStringArray (vFilesWithPath) > 1 then
		{


			vFilesWithPath = @Replace (vFilesWithPath, ";", " ")

			vSuccess = @Shell ( "PDFill.exe MERGE " + vFilesWithPath + " " + @chr (34) + vFinalFile + @chr (34) )


		}
		Else
		{


			vSuccess = @Shell ("Copy " + vFilesWithPath + " " + @chr (34) + vFinalFile + @chr (34) )

		}




For n = 1 to 10

		If FileExists (vLastFile)
			{
				n = 10
			}
			Else
			{
				Loiter (1000)

			}


Next

vSuccess = @AsynchShell (@Chr (34) + vFinalFile + @Chr (34))  //This is only if you want to open one page


vSuccess = @Shell ( "RUNDLL32 PRINTUI.DLL,PrintUIEntry /y /n " +  @Chr (34) + vPrinter2 + @chr (34) )// Default Printer in place again


 



  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Needs help with Fontsize with PrintString ( )
Reply #5 - Mar 22nd, 2012 at 7:23pm
Print Post Print Post  
Hello Bharat,

Your problem is in the section
Code
Select All
		PrintString (@XResultSetValue (vRSHandle, "AD1") + " " + @XResultSetValue (vRSHandle, "AD2") + " " + @XResultSetValue (vRSHandle, "AD3") + " " + @XResultSetValue (vRSHandle, "ADP"), 0, vYExtent, 0, vFont, vFontSize, 1)

		//writeLN ("Step 1 " + @Str (@PageExtentY ( ) )) //*********************************************************************************************************************************************
		If @PageExtentY () <= 1100 then
			{
				PrintString (@XResultSetValue (vRSHandle, "AD1") + " " + @XResultSetValue (vRSHandle, "AD2") + " " + @XResultSetValue (vRSHandle, "AD3") + " " + @XResultSetValue (vRSHandle, "ADP"), 0, vYExtent, 0, vFont, vFontSize, 0)
			}
			Else
			{
				PageExtentY (vYExtent)
				PrintString (@XResultSetValue (vRSHandle, "AD1") + " " + @XResultSetValue (vRSHandle, "AD2") + " " + @XResultSetValue (vRSHandle, "AD3"), 0, vYExtent, 0, vFont, vFontSize, 1)
				//WriteLn (@PageExtentY ( ))
					If @PageExtentY () < 1100 and vPage = 1 and vStopReset = 0 then
						{
							//writeLN ("Step 2 " + @Str (@PageExtentY ( ) )) //*********************************************************************************************************************************************
							PrintString (@XResultSetValue (vRSHandle, "AD1") + " " + @XResultSetValue (vRSHandle, "AD2") + " " + @XResultSetValue (vRSHandle, "AD3"), 0, vYExtent, 0, vFont, vFontSize, 0)
							PageControlMeasure (@XResultSetValue (vRSHandle, "ADP"))
							CompleteTask ( )
						}
		      
				PageExtentY (vYExtent)
				PrintString (@XResultSetValue (vRSHandle, "AD1") + " " + @XResultSetValue (vRSHandle, "AD2"), 0, vYExtent, 0, vFont, vFontSize, 1)
				//WriteLN (@PageExtentY ( ) )
					If @PageExtentY () < 1100 and vPage = 1 and vStopReset = 0 then
						{
							//writeLN ("Step 3 " + @Str (@PageExtentY ( ) )) //*********************************************************************************************************************************************
							PrintString (@XResultSetValue (vRSHandle, "AD1") + " " + @XResultSetValue (vRSHandle, "AD2"), 0, vYExtent, 0, vFont, vFontSize, 0)
							PageControlMeasure (@XResultSetValue (vRSHandle, "AD3") + " " + @XResultSetValue (vRSHandle, "ADP"))
							CompleteTask ( )
						}

				PageExtentY (vYExtent)
				PrintString (@XResultSetValue (vRSHandle, "AD1"), 0, vYExtent, 0, vFont, vFontSize, 1)
				//WriteLN (@PageExtentY ( ) )
					If @PageExtentY () < 1100 and vPage = 1 and vStopReset = 0 then

						{
							//writeLN ("Step 4 " + @Str (@PageExtentY ( ) )) //*********************************************************************************************************************************************
							PrintString (@XResultSetValue (vRSHandle, "AD1"), 0, vYExtent, 0, vFont, vFontSize, 0)
							PageControlMeasure (@XResultSetValue (vRSHandle, "AD2") + " " + @XResultSetValue (vRSHandle, "AD3") + " " + @XResultSetValue (vRSHandle, "ADP"))
							CompleteTask ( )

						}
			} 



You are potentially calling PrintString(), For measuring purposes only in your case, after FinishPage() has been called but before a NewPage() has been called. When PrintString, PrintBox, or PrintImage are called and NewPage() has not been called, Sesame automatically creates one but it is specified as a 750 by 1000 grid where as your code is written for a 850 by 1100 grid. This is why everything is bigger. To fix this change your code to

Code
Select All
		PrintString (@XResultSetValue (vRSHandle, "AD1") + " " + @XResultSetValue (vRSHandle, "AD2") + " " + @XResultSetValue (vRSHandle, "AD3") + " " + @XResultSetValue (vRSHandle, "ADP"), 0, vYExtent, 0, vFont, vFontSize, 1)

		//writeLN ("Step 1 " + @Str (@PageExtentY ( ) )) //*********************************************************************************************************************************************
		If @PageExtentY () <= 1100 then
		{
			PrintString (@XResultSetValue (vRSHandle, "AD1") + " " + @XResultSetValue (vRSHandle, "AD2") + " " + @XResultSetValue (vRSHandle, "AD3") + " " + @XResultSetValue (vRSHandle, "ADP"), 0, vYExtent, 0, vFont, vFontSize, 0)
		}
		Else
		{
			PageExtentY (vYExtent)
			PrintString (@XResultSetValue (vRSHandle, "AD1") + " " + @XResultSetValue (vRSHandle, "AD2") + " " + @XResultSetValue (vRSHandle, "AD3"), 0, vYExtent, 0, vFont, vFontSize, 1)
			//WriteLn (@PageExtentY ( ))
			If @PageExtentY () < 1100 and vPage = 1 and vStopReset = 0 then
			{
				//writeLN ("Step 2 " + @Str (@PageExtentY ( ) )) //*********************************************************************************************************************************************
				PrintString (@XResultSetValue (vRSHandle, "AD1") + " " + @XResultSetValue (vRSHandle, "AD2") + " " + @XResultSetValue (vRSHandle, "AD3"), 0, vYExtent, 0, vFont, vFontSize, 0)
				PageControlMeasure (@XResultSetValue (vRSHandle, "ADP"))
				CompleteTask ( )
			}
			If vStopReset = 0 Then
			{
				PageExtentY (vYExtent)
				PrintString (@XResultSetValue (vRSHandle, "AD1") + " " + @XResultSetValue (vRSHandle, "AD2"), 0, vYExtent, 0, vFont, vFontSize, 1)
				//WriteLN (@PageExtentY ( ) )
				If @PageExtentY () < 1100 and vPage = 1 and vStopReset = 0 then
				{
					//writeLN ("Step 3 " + @Str (@PageExtentY ( ) )) //*********************************************************************************************************************************************
					PrintString (@XResultSetValue (vRSHandle, "AD1") + " " + @XResultSetValue (vRSHandle, "AD2"), 0, vYExtent, 0, vFont, vFontSize, 0)
					PageControlMeasure (@XResultSetValue (vRSHandle, "AD3") + " " + @XResultSetValue (vRSHandle, "ADP"))
					CompleteTask ( )
				}
			}

			If vStopReset = 0 Then
			{
				PageExtentY (vYExtent)
				PrintString (@XResultSetValue (vRSHandle, "AD1"), 0, vYExtent, 0, vFont, vFontSize, 1)
				//WriteLN (@PageExtentY ( ) )
				If @PageExtentY () < 1100 and vPage = 1 and vStopReset = 0 then
				{
					//writeLN ("Step 4 " + @Str (@PageExtentY ( ) )) //*********************************************************************************************************************************************
					PrintString (@XResultSetValue (vRSHandle, "AD1"), 0, vYExtent, 0, vFont, vFontSize, 0)
					PageControlMeasure (@XResultSetValue (vRSHandle, "AD2") + " " + @XResultSetValue (vRSHandle, "AD3") + " " + @XResultSetValue (vRSHandle, "ADP"))
					CompleteTask ( )
				}
			}
		} 



-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Needs help with Fontsize with PrintString ( )
Reply #6 - Mar 22nd, 2012 at 10:47pm
Print Post Print Post  
What a relief!!! I know now that no data is omitted. I am still trying to understand the logic of why the font size changes but that is more academic question.

There is still a minor issue with the second page having the page#, RecNumber and Date, so as to make certain who does the page belongs to. It appears on some second pages while missing from the other. However, this is not critical. Moreover, this has nothing to do with the batch processing.

Ray, I don't know what would we be doing without you? Thanks.
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Needs help with Fontsize with PrintString ( )
Reply #7 - Mar 22nd, 2012 at 11:38pm
Print Post Print Post  
Bharat_Naik wrote on Mar 22nd, 2012 at 10:47pm:
I am still trying to understand the logic of why the font size changes but that is more academic question.


The page size scales the page. If, for example you set the page size to 100x100 and print 1 pixel, that pixel would be 1/100th of the total page in size. Basically, you could only draw 100 pixels across the page before you ran out of page. But, if you set the page size to 1000x1000, each pixel would be 1/1000th of the total size of the page. You could draw 1000 pixels across the page before running out of page.

The reason for scaling is pretty simple: printers can range widely in how many pixels per inch they can produce. A cheap laser can print around 300 pixels per inch. A good one can put 1200 pixels in an inch. To scale 1/1, you would set the page size to the number of inches times the number of pixels per inch your printer is able to produce. Scaled 1/1, a typical Sesame form prints smaller than a postage stamp on a 1200 DPI printer.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Needs help with Fontsize with PrintString ( )
Reply #8 - Mar 23rd, 2012 at 4:04pm
Print Post Print Post  
Bharat_Naik wrote on Mar 22nd, 2012 at 10:47pm:
There is still a minor issue with the second page having the page#, RecNumber and Date, so as to make certain who does the page belongs to. It appears on some second pages while missing from the other. However, this is not critical. Moreover, this has nothing to do with the batch processing.



Best advice I can give you is find a record that does it every time, and a record that does not. Then place some debug in PageControlMeasure() and CompleteTask ( ) to uniquely identify them and to write out the variable vPage. Then run the routine on the record that does it and the record that doesn't and compare the debug. It could be that under a certain circumstance vPage is still 1 on the second page so it doesn't print the footer.

Bharat_Naik wrote on Mar 22nd, 2012 at 10:47pm:
Ray, I don't know what would we be doing without you?


Hmm probably sitting at your desk with an empty bottle of ibuprofen and an ice pack on your head from beating it on the keyboard so much.  Grin

Bharat_Naik wrote on Mar 22nd, 2012 at 10:47pm:
Thanks.


You are welcome.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged