Normal Topic Print multiple pages (Read 1419 times)
Renato Piacenti
Member
*
Offline


No personal text

Posts: 48
Location: Manaus - Amazonas - Brazil
Joined: Jun 20th, 2005
Print multiple pages
Jun 28th, 2009 at 2:16am
Print Post Print Post  
Hi All
I'm having difficulty programming a command button to print more than one page of a report that the search of a Subform infomrações and assembles the report.
The assembly of the report is not the problem.
How to do that, the printer still print multiple pages if necessary?. Undecided

Code
Select All
Var vDescription as string
Var vDescription1 as string
Var vPos as int
Var vSub as int
Var vSubTotal as int
Var vPriceTotal as double
Var vYCor as int
Var vYCor1 as int
Var vYCor2 as int
Var vPrice as double
var vSPrice as string
Var vInvDate as String
Var vData as String
Var vLineX as Int
Var vLineXMax as Int
Var vLineX1 as Int
Var vLineXMax1 as Int
Var vLineX2 as Int
Var vLineXMax2 as Int

NewDocument(1)
NewPage(1600, 600)

vLineXMax = 1500
vLineX = 120

vLineXMax1 = 1500
vLineX1 = 120

vLineXMax2 = 1500
vLineX2 = 120

		PrintString("xxxxxxxx" + ":" + Contr, 120, 65, 0, "BArial", 18, 0)
		PrintString("xxxxxxxxxxxxxx ", 430, 65, 0, "BArial", 20, 0)
		PrintString("xxxxxxxx" + ":" + Mes, 120, 85, 0, "BArial", 18, 0)
		PrintString("xxxxxxxxxx", 1250, 85, 0, "BArial", 20, 0)
		PrintString("xxxxxxxxxxxxxxxx", 480, 105, 0, "BArial", 20, 0)
		PrintString("( xxxxxxxxxxxxxxxxx )", 520, 127, 0, "Arial", 16, 0)

	While vLineX <= vLineXMax
	{
		PrintString("=", vLineX, 147, 0, "BArial", 20, 0)
		vLineX += 5
	}

		PrintString(" ", 50, 155, 0, "BArial", 18, 0)

vDescription = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
PrintString(vDescription, 120, @PageExtentY() + 10, 1350, "Arial", 20, 0)

vDescription = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx."
PrintString(vDescription, 120, @PageExtentY() + 10, 1350, "Arial", 20, 0)

vDescription = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx."
PrintString(vDescription, 120, @PageExtentY() + 10, 1350, "Arial", 20, 0)

vDescription = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx."
PrintString(vDescription, 120, @PageExtentY() + 10, 1350, "Arial", 20, 0)

vDescription = "Ass."
PrintString(vDescription, 400, @PageExtentY() + 30, 1350, "Arial", 20, 0)

vDescription = "____________________________________________________________"
PrintString(vDescription, 420, @PageExtentY() + 3, 1350, "Arial", 18, 0)

vDescription = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
PrintString(vDescription, 500, @PageExtentY() + 5, 1350, "Arial", 18, 0)

	While vLineX1 <= vLineXMax1
	{
		PrintString("=", vLineX1, 450, 0, "BArial", 20, 0)
		vLineX1 += 5
	}

PrintString("Tipo", 120, 480, 0, "BArial", 18, 0)
PrintString("Numero", 180, 480, 0, "BArial", 18, 0)
PrintString("Emissão", 300, 480, 0, "BArial", 18, 0)
PrintString("CPF/CNPJ", 420, 480, 0, "BArial", 18, 0)
PrintString("Beneficiário", 600, 480, 0, "BArial", 18, 0)
PrintString("Verba", 1000, 480, 0, "BArial", 18, 0)
PrintString("Valor", 1115, 480, 0, "BArial", 18, 0)

	vYCor2 = @PageExtentY() + 5
	vDescription1 = "====================================================================================================================================="
	PrintString(vDescription1, 120, vYCor2, 1350, "Arial", 18, 0)

vSubTotal = @FormResultSetTotal("PEDIDO")
vSub = 1

While vSub <= vSubTotal
{
	VDescription = @FormFieldValue("PEDIDO", "Tipo", vSub)
	vYCor = @PageExtentY() + 10				  

	FormResultSetCurrentPosition("PEDIDO", vSub)

	PrintString(@FormFieldValue("PEDIDO", "Tipo", vSub), 123, vYCor, 0, "Arial", 18, 0)

	PrintString(@FormFieldValue("PEDIDO", "Num", vSub), 180, vYCor, 0, "Arial", 18, 0)

	vData = @FormFieldValue("PEDIDO", "Emis", vSub)
	vInvDate = @Right("00" + @Str(@DOM(vData)), 2) + "/" + @Str(@Month(vData)) + "/" +  @Str(@Year(vData))
	PrintString(vInvDate, 300, vYCor, 0, "Arial", 18, 0)

	PrintString(@FormFieldValue("PEDIDO", "CPF_CNPJ", vSub), 420, vYCor, 0, "Arial", 18, 0)

	PrintString(@FormFieldValue("PEDIDO", "Benef", vSub), 605, vYCor, 0, "Arial", 18, 0)

	PrintString(@FormFieldValue("PEDIDO", "Verba", vSub), 1015, vYCor, 0, "Arial", 18, 0)

	vSPrice = @FormFieldValue("PEDIDO", "Val_Liq", vSub)
	vPrice = @ToMoney(vSPrice)
	vsPrice = @Decimals(vSPrice, 2)
	PrintString(@Text((9 - @len(vSPrice)) * 2, " ") + "R$" + " " + vSPrice , 1085, vYCor, 0, "Arial", 18, 0)

	vPriceTotal += vPrice  
	vSub = vSub + 1
}
	FormResultSetCurrentPosition("PEDIDO", 1)
	vYCor1 = @PageExtentY() + 5
	vDescription1 = "==============================================================================================================================="
	PrintString(vDescription1, 120, vYCor1, 1300, "Arial", 18, 0)
	PrintString("Total das Despesas: R$" + " " + @Decimals(VPriceTotal,2), 890, @PageExtentY() + 20, 0, "BArial", 20, 0)

FinishPage()
FinishDocument()



 

« Last Edit: Jun 29th, 2009 at 1:40am by Renato Piacenti »  

Renato Piacenti&&Manaus Amazonas Brazil&&Aqui a Floresta esta sendo preservada.&&Preserve a sua tamb�m.
Back to top
 
IP Logged
 
lksseven
Full Member
***
Offline



Posts: 416
Location: Southwest
Joined: Jan 26th, 2009
Re: Print multiple pages
Reply #1 - Jun 28th, 2009 at 2:05pm
Print Post Print Post  
Hi Renato,

It looks to me like you need to encapsulate your printing code inside a loop.  I am enclosing the code I use to print multiple pages.  My loop key is a variable, but could of course be made a hard coded quantity.

vRS2 = @XResultSetSearch(@FN, "Inventory", SEARCH_MODE_AND, SEARCH_SYNTAX_QA, "!ItemNum=" + vItemNum)
   
If @XresultSetTotal(vRS2) = 1                        // if there is exactly one matching record in Inventory, pull data from Inventory into label
   {
                                                         // Get and then plug ItemNum, ItemDesc, PONum
    vItemNum = @XResultSetValue(vRS2, "ItemNum")
    vItemDesc = @XResultSetValue(vRS2, "ItemDesc")
    vPONum = @XResultSetValue(vRS2, "CurrentPONum")
     
     vAnswer2 = @PromptForUserInput("How many labels would you like to print?", "")      // enter the qty of labels you want to print
     vQty = vAnswer2
    
        AlternateDefaultPrinter("wcLabel1")
         vLoop = 1
         NewDocument(1)
             [color=#cc0000]While vLoop <= vQty[/color]
              {
                NewPage(840, 240)
                  PrintPageOrientation(2)
                  PrintString(vItemNum, 6, 6, 0, " ARIAL", 11, 0)
                PrintString(vItemDesc, 6, @PageExtentY(), 200, " ARIAL", 8, 0)
                PrintString("---------------", 160, 48, 0, " ARIAL", 9, 0)
                  PrintString("MyCompany 123-555-8888", 15, 54, 0, " ARIAL", 9, 0)
                PrintString("PO#" + " " + vPONum, 160, 54, 0, " ARIAL", 9, 0)
                  PrintString("www.MyCompany.com", 15, 63, 0, " Arial", 8, 0)
              FinishPage()
                [color=#cc0000]vLoop = vLoop + 1[/color]
              }
           FinishDocument()
        RestoreDefaultPrinter()
    }
  

Larry
Back to top
IP Logged
 
Renato Piacenti
Member
*
Offline


No personal text

Posts: 48
Location: Manaus - Amazonas - Brazil
Joined: Jun 20th, 2005
Re: Print multiple pages
Reply #2 - Jun 28th, 2009 at 5:31pm
Print Post Print Post  
Iksseven Thanks for the help.
But the document is composed of 2 or more pages, only page 1 is being assembled for printing, but the sequence of the document, on page 2, is not being mounted to continue printing.
I think that missing a code  to create a second page for printing.
Some sugetão?  Undecided
  

Renato Piacenti&&Manaus Amazonas Brazil&&Aqui a Floresta esta sendo preservada.&&Preserve a sua tamb�m.
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: Print multiple pages
Reply #3 - Jun 29th, 2009 at 2:11pm
Print Post Print Post  
To determine whether there is overflow to page2, you have to use MeasureOnly part of PrintString ( ) command. I was confronted with the same problem and if you so wish, I will post my code to handle this situation.  Iksseven code works when you know when the page is going to change, like you know as to how many labels needs to be printed and loop them through.

  
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: Print multiple pages
Reply #4 - Jun 29th, 2009 at 2:24pm
Print Post Print Post  
In the following link, Ray has given his solution to your problem.

http://www.lantica.com/Forum3/cgi-bin/yabb2/YaBB.pl?num=1211389584/3#3


Bharat Naik
  
Back to top
 
IP Logged
 
Renato Piacenti
Member
*
Offline


No personal text

Posts: 48
Location: Manaus - Amazonas - Brazil
Joined: Jun 20th, 2005
Re: Print multiple pages
Reply #5 - Jun 29th, 2009 at 5:50pm
Print Post Print Post  
Edited:
I was confronted with the same problem and if you so wish, I will post my code to handle this situation.


Yes, Bharat Naik, I would like to check your code.
I am sure that will be of great help.
  

Renato Piacenti&&Manaus Amazonas Brazil&&Aqui a Floresta esta sendo preservada.&&Preserve a sua tamb�m.
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: Print multiple pages
Reply #6 - Jun 29th, 2009 at 10:14pm
Print Post Print Post  
Please note that Scripts1 and Scripts2 are the subforms.  It checks vYExtent (PageExtentY) by measureonly parameter before printing it.

Ignore RemoveRunEntryOnEvent ( ) is added as I started this command from mainmenu with RunEntryOnEvent() and that has to be broken.

In the begining for about half of a first page, I did not check the overflow as I know it would not overflow at that level.  This code works and it is being used to printout 60 to 70 entry everyday and seem to work flawlessly.


Code
Select All
var vFont as String = " Arial"
var vFontSize as Int = 17
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 vPage as Int
var vYExtent as Int

var vChart as String
var vBP as String
var vHC as String
var vGrowthBlock as String
var vBreastBlock as String
var vStopReset as Int = 0


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 vPrintIndicator as String

var vMedicine as String
var vInstruction as String








SubRoutine CompleteTask ( )
PrintString (DN, 550, @PageExtentY ( ) + 10, 0, vFont, vFontSize, 0)
If vPage > 1 then
			{
				PrintString (UDF_FormatDate (Date1), 0, 1060, 0, vFont, vFontsize, 0, PrintString_Align_Right)
				PrintString ("Page " + @str (vPage), 0, 1060, 0, vFont, vFontsize, 0, PrintString_Align_Center)
				PrintString (LN + " - " + RecNumber, 0, 1060, 0, vFont, vFontsize, 0, PrintString_Align_Left )
			}
vStopReset = 1
FinishPage ( )
//RestoreDefaultPrinter ( )
//Stop   //stop is replaced with vStopReset

End Subroutine

SubRoutine PageControlMeasure(vString as String )   //This includes PageControl ( )
If @PageExtentY ( ) > 1050 then
		{

			If vPage > 1 then
			{
				PrintString ("Page " + @str (vPage), 0, 1060, 0, vFont, vFontsize, 0, PrintString_Align_Center)
				PrintString (LN + " - " + RecNumber, 600, 1060, 0, vFont, vFontsize, 0)
			}

			FinishPage ( )
			NewPage (850, 1100)
			PageExtentY (0)
			vYExtent = 0

			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 ("Page " + @str (vPage), 0, 1060, 0, vFont, vFontsize, 0, PrintString_Align_Center)
				PrintString (LN + " - " + RecNumber, 600, 1060, 0, vFont, vFontsize, 0)
			}

			FinishPage ( )
			NewPage (850, 1100)
			PageExtentY (0)
			vPage = vPage + 1
		}
End SubRoutine

SubRoutine Printing_Physical ( )
var n as Int


//Functions below is in Global area

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








vChart = @xLookup (@FN, RecNumber, "Index!RecNumber", "Chart")
vChart = vChart + "-" + @Right (Q, 3)
If BP <> "" then
	{
		vBP = "BP: " + BP
	}
If HC <> "" then
	{
		vHC = "Head Circum: " + HC
	}
VGrowthBlock = Tab (1) + W

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

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

NewPage (850, 1100)
PrintPagePaper (28)

PrintPageMargin (30, 45, 40, 30)

PrintString ("Name: " + LN, 0, 0, 0, vFont, vFontSize, 0)
PrintString ("Rec#: " + RecNumber, @PageExtentX ( ) + 30, -1, 0, vFont, vFontSize, 0)
PrintString ("Date: " + UDF_FormatDate (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: " + WT, 0, @PageExtentY ( ), 200, vFont, vFontSize, 0)
PrintString ("Height: " + HT, -1, -1, 200, vFont, vFontSize, 0)
PrintString ("Temp: " + T, -1, -1, 200, vFont, vFontSize, 0)
PrintString ("BMI: " + BMI, -1, -1, 150, vFont, vFontSize, 0)

PrintString ("Pulse: " + P, 0, @PageExtentY ( ), 200, vFont, vFontSize, 0)
PrintString ("Resp: " + 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  LMP <> ""   then
	   {
		PrintString ("LMP: " + UDF_FormatDate (LMP), 0, @PageExtentY ( ), 200, vFont, vFontSize, 0)
	   }
	IF LDP <> ""  then
	 {
	   If LMP <> "" then
	   {
		PrintString ("LastDepo: " + UDF_FormatDate (LDP), -1, -1, 200, vFont, vFontSize, 0)
	   }
	 Else
	   {
		PrintString ("LastDepo: " + UDF_FormatDate (LDP), 0, @PageExtentY (), 200, vFont, vFontSize, 0)
	   }
	 }
	If FP <> "" then
	   {
			If LMP <> ""  or LDP <> "" then
			{
				PrintString ("FP: " + FP, -1, -1, 0, vFont, vFontSize, 0)
			}
		     Else
			{
				PrintString ("FP: " + 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 " + Age + " old " + Sex + ".", 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
PrintString (His1 + " " + His2 + " "  + 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 (GRL, 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
PrintString (HN, 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
PrintString (Eyes, 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
PrintString (Ears, 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
PrintString (Lung, 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
PrintString (CVS, 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
PrintString (Breast, 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
PrintString (ABD, 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
PrintString (Skin, 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
PrintString (Joint, 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
PrintString (Ext, 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
PrintString (Gtal, 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
PrintString (CNS, 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
PrintString (Rtal, 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
PrintString (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 (AB_Lab, 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
IF Lab <> "" or Xray1 <> "" then
	{
		PrintString (Lab + " " + Xray1, 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
	}
If HB <> "" or Tine <> "" or Blood_Glucose <> "" then
	{
		PrintString (HB + " " + TINE + " " + Blood_Glucose, 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
	}
PrintString (UD, 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
PrintString (Hearing, 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
PrintString (Imm, 0, @PageExtentY ( ), 0, vFont, vFontSize, 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 (Cond1, (@Len(cond1) -7)), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
PrintString (@Left (Cond2, (@Len(cond2) -7)), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
PrintString (@Left (Cond3, (@Len(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 (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)


For n = 1 to @FormResultSetTotal ("Scripts1")
	vMedicine = @FormFieldValue ("Scripts1", "Medicine", n)
	vInstruction = @FormFieldValue ("Scripts1", "Medicine", n)
	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 ( )
			PageControlMeasure (vStr3)
			If vPage = 1 or (vPage = 2 and vPrintIndicator = "Not Printed") then
				{
					PrintString (vStr3, 0, vYExtent, 0, vFont, vFontSize, 0)
				}

		}
Next



For n = 1 to @FormResultSetTotal ("Scripts2")
	vMedicine = @FormFieldValue ("Scripts2", "Medicine", n)
	vInstruction = @FormFieldValue ("Scripts2", "Medicine", n)
	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 ( )
			PageControlMeasure (vStr3)
			If vPage = 1 or (vPage = 2 and vPrintIndicator = "Not Printed") then
				{
					PrintString (vStr3, 0, vYExtent, 0, vFont, vFontSize, 0)
				}

		}
Next

vYExtent = @PageExtentY ( )

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

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

		PageExtentY (vYExtent)
		PrintString (AD1 + " " + AD2, 0, vYExtent, 0, vFont, vFontSize, 1)
		//WriteLN (@PageExtentY ( ) )
			If @PageExtentY () < 1100 and vPage = 1 and vStopReset = 0 then
				{
					PrintString (AD1 + " " + AD2, 0, vYExtent, 0, vFont, vFontSize, 0)
					PageControlMeasure (AD3 + " " + ADP)
					CompleteTask ( )
				}

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

				{
					PrintString (AD1, 0, vYExtent, 0, vFont, vFontSize, 0)
					PageControlMeasure (AD2 + " " + AD3 + " " + ADP)
					CompleteTask ( )

				}
	}



PrintString (DN, 550, @PageExtentY ( ) + 10, 0, vFont, vFontSize, 0)
if @GlobalValue (vSignatureOnPhysicalPrintString) = "1" then
	{
		PrintImage ("C:\images\bharat_sig.jpg", 550, @PageExtentY ( ) + 10, -1, -1)
	}
If vPage > 1 then
			{
				PrintString (UDF_FormatDate (Date1), 0, 1060, 0, vFont, vFontsize, 0, PrintString_Align_Right)
				PrintString ("Page " + @str (vPage), 0, 1060, 0, vFont, vFontsize, 0, PrintString_Align_Center)
				PrintString (LN + " - " + RecNumber, 0, 1060, 0, vFont, vFontsize, 0, PrintString_Align_Left )
			}
FinishPage ( )
//RestoreDefaultPrinter ( )

End SubRoutine

vPrinterA = @GlobalValue ("PrinterA")
vPrinterB = @GlobalValue ("PrinterB")
vServerDefault = @GlobalValue ("ServerDefaultPrinter")
vPrinterList = udfGetPrinterList ( )


If @AskUser("Do you want to PRINT PHYSICALS for all " + @Str(@ResultSetTotal()) + " records in the result set?", "", "") then
	{


		If @UserParameter (1) =  @GlobalValue ("ServerComp") and @GlobalValue ("PhysicalPrintStringPrinterSelect") <> "1" then    //User Param entered in Sesame.ini file of Main_Server
			{
				    AlternateDefaultPrinter (vPrinterB)
			}
			Else if @UserParameter (1) =  @GlobalValue ("ServerComp") and @GlobalValue ("PhysicalPrintStringPrinterSelect") = "1" then
			{
				PopupSelectPosition(4, @Xpos(ThisElement), @Ypos(ThisElement))
				vSelectedPrinter = @PopupChoiceList(vPrinterList, "Select A Printer")
				AlternateDefaultPrinter (VSelectedPrinter)
			}
			Else if @UserParameter (1) = @GlobalValue ("FrontComp") then  //User Param entered in Sesame.ini file of Reception
			{
				AlternateDefaultPrinter (vPrinterA)
			}
			Else if @Globalvalue ("PhysicalPrintStringPrinterSelect") = "1" then
			{
				PopupSelectPosition(4, @Xpos(ThisElement), @Ypos(ThisElement))
				vSelectedPrinter = @PopupChoiceList(vPrinterList, "Select A Printer")
				AlternateDefaultPrinter (VSelectedPrinter)
			}
			Else
			{
				RestoreDefaultPrinter ( )
			}



		For vLoop = 1 to @ResultSetTotal( )
			vPage = 1
			vStopReset = 0
			ResultSetCurrentPosition (vLoop)
			Printing_Physical ( )
		next
	    RestoreDefaultPrinter ( )
		RemoveRunEntryOnEvent()
	}
	Else
	{
		RemoveRunEntryOnEvent()
		ClientLocalValue ("PrintFromMenu", "0")  //Reset value
		@save	//come out of form
		@exit

	}


RemoveRunEntryOnEvent()

If @ClientLocalValue ("PrintFromMenu") = "1" and @UserParameter (1) = vStation then
	{
		RemoveRunEntryOnEvent()
		ClientLocalValue ("PrintFromMenu",  "0")  //Reset value
		@Save
		@Exit   //come out of form


	}
 

  
Back to top
 
IP Logged
 
Renato Piacenti
Member
*
Offline


No personal text

Posts: 48
Location: Manaus - Amazonas - Brazil
Joined: Jun 20th, 2005
Re: Print multiple pages
Reply #7 - Jun 29th, 2009 at 11:33pm
Print Post Print Post  
Thank you Bharat Naik, I will start working on the code now.
You're giving me a great help in this problem.
  

Renato Piacenti&&Manaus Amazonas Brazil&&Aqui a Floresta esta sendo preservada.&&Preserve a sua tamb�m.
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: Print multiple pages
Reply #8 - Jul 2nd, 2009 at 7:22am
Print Post Print Post  
Hi Renato, I am wondering if you are making progress with multipage printing with PrintString ( ) command.  The other option is MergeFilePrint ( ) command using rtf with Word. It will automatically overflow and make next page as needed. This method obviously has pros and cons. Pros being, you can preview and edit before printing or saving. Cons being it is a little slower if you have to print multiple records as Word has to open and close for every record and it is dependent on external program such as MS Word.
  
Back to top
 
IP Logged
 
Renato Piacenti
Member
*
Offline


No personal text

Posts: 48
Location: Manaus - Amazonas - Brazil
Joined: Jun 20th, 2005
Re: Print multiple pages
Reply #9 - Jul 2nd, 2009 at 2:25pm
Print Post Print Post  
Hi Bharat, I am studying the code still is not easy to implement this function in my code.
Do not quit yet. Smiley
Thank you.
  

Renato Piacenti&&Manaus Amazonas Brazil&&Aqui a Floresta esta sendo preservada.&&Preserve a sua tamb�m.
Back to top
 
IP Logged