How to convert period of tickdata? - quote

How to convert nTime to TimeSpan?
uint nTime = 9012245; // 9 = Hour 01 = Minutes 22 = Seconds 45 = Milliseconds
tickdata[0] = {9010145,Price,Volume}
tickdata[1] = {9010253,Price,Volume}
tickdata[2] = {9010253,Price,Volume}
tickdata[3~7] = {....}
tickdata[8] = {9015945,Price,Volume}
tickdata[9] = {9020045,Price,Volume}
tickdata[100] = {9030145,Price,Volume}
// [0~8] = 90100 ~ 90159 1min
I want quick count every 1min(or 5min or 10min...) tickdata's OHLC, and write to tickOf1min like below :
tickOf1min[0] = {90100,Open,HighL,Close}
tickOf1min[1] = {90200,Open,HighL,Close}
tickOf1min[2] = {90300,Open,HighL,Close}

Related

Error with the message "Cannot cast (inet::physicallayer::Ieee80211DimensionalTransmission*) to type 'const inet::physicallayer::IScalarSignal *'"

I use Omnet++ and Inet 4.4, I want to simulate a scenario to investigate the effect of interference, which is as follows:
In a network consisting of two pairs of nodes including a node called source and a node called destination, in which node source sends packets to node destination and is tuned in channel 2 of Ieee802.11b/g, let's examine the second pair consisting of node Node1 and node Node2, which node Node1 sends packets to node Node 4 and is tuned in channel 4.
But recently a problem appear very often and the simulations are stopped, the error is this:
check_and_cast(): Cannot cast (inet::physicallayer::Ieee80211DimensionalTransmission*) to type 'const inet::physicallayer::IScalarSignal *' -- in module (inet::physicallayer::Ieee80211Radio) AnalogModelShowcaseDistanceNetworkRM.source.wlan[1].radio (id=200), at t=0.001s, event #24
My omnetpp.ini is as:
[Config Distance]
network = AnalogModelShowcaseDistanceNetworkRM
sim-time-limit = 5s
# Maryam **.radio.packetErrorRate.result-recording-modes = +vector
# Maryam **.radio.bitErrorRate.result-recording-modes = +vector
# application parameters
*.source.numApps = 1
*.source.app[0].typename = "UdpBasicApp"
*.source.app[*].destAddresses = "destination"
*.source.app[*].destPort = 1000
*.source.app[*].messageLength = 1000byte
*.source.app[*].sendInterval = 1ms
*.destination.numApps = 1
*.destination.app[0].typename = "UdpSink"
*.destination.app[*].localPort = 1000
*.Node1.numApps = 1
*.Node1.app[0].typename = "UdpBasicApp"
*.Node1.app[*].destAddresses = "Node2"
*.Node1.app[*].destPort = 1001
*.Node1.app[*].messageLength = 1000byte
*.Node1.app[*].sendInterval = 1ms
*.Node2.numApps = 1
*.Node2.app[0].typename = "UdpSink"
*.Node2.app[*].localPort = 1001
*.source.numWlanInterfaces = 2
*.destination.numWlanInterfaces = 2
*.Node1.numWlanInterfaces = 2
*.Node2.numWlanInterfaces = 2
*.source.wlan[*].radio.typename = "Ieee80211DimensionalRadio"
*.destination.wlan[*].radio.typename = "Ieee80211DimensionalRadio"
*.Node*.wlan[*].radio.typename = "Ieee80211DimensionalRadio"
*.source.wlan[*].radio.centerFrequency = 2.412GHz
*.source.wlan[*].radio.bandwidth = 2MHz
*.source.wlan[*].radio.transmitter.power = 2mW
*.source.wlan[*].radio.transmitter.bitrate = 2Mbps
*.source.wlan[*].radio.transmitter.preambleDuration = 0s
*.source.wlan[*].radio.transmitter.headerLength = 96b
*.source.wlan[*].radio.transmitter.modulation = "BPSK"
*.source.wlan[*].radio.receiver.sensitivity = -85dBm
*.source.wlan[*].radio.receiver.energyDetection = -85dBm
*.source.wlan[*].radio.receiver.snirThreshold = 4dB
*.destination.wlan[*].radio.centerFrequency = 2.412GHz
*.destination.wlan[*].radio.bandwidth = 2MHz
*.destination.wlan[*].radio.transmitter.power = 2mW
*.destination.wlan[*].radio.transmitter.bitrate = 2Mbps
*.destination.wlan[*].radio.transmitter.preambleDuration = 0s
*.destination.wlan[*].radio.transmitter.headerLength = 96b
*.destination.wlan[*].radio.transmitter.modulation = "BPSK"
*.destination.wlan[*].radio.receiver.sensitivity = -85dBm
*.destination.wlan[*].radio.receiver.energyDetection = -85dBm
*.destination.wlan[*].radio.receiver.snirThreshold = 4dB
*.Node*.wlan[*].radio.centerFrequency = 2.412GHz
*.Node*.wlan[*].radio.bandwidth = 2MHz
*.Node*.wlan[*].radio.transmitter.power = 2mW
*.Node*.wlan[*].radio.transmitter.bitrate = 2Mbps
*.Node*.wlan[*].radio.transmitter.preambleDuration = 0s
*.Node*.wlan[*].radio.transmitter.headerLength = 96b
*.Node*.wlan[*].radio.transmitter.modulation = "BPSK"
*.Node*.wlan[*].radio.receiver.sensitivity = -85dBm
*.Node*.wlan[*].radio.receiver.energyDetection = -85dBm
*.Node*.wlan[*].radio.receiver.snirThreshold = 4dB
*.source.wlan[0].radio.channelNumber = 2
*.destination.wlan[0].radio.channelNumber = 2
*.Node1.wlan[0].radio.channelNumber = 4
*.Node2.wlan[0].radio.channelNumber = 4
# mobility parameters
*.destination.mobility.typename = "LinearMobility"
*.destination.mobility.initialMovementHeading = 0deg
*.destination.mobility.speed = 200mps
*.destination.mobility.constraintAreaMinX = 500m
*.destination.mobility.constraintAreaMaxX = 1200m
# wlan
*.source.**.transmitter.power = 12mW
*.source.**.displayCommunicationRange = true
**.backgroundNoise.power = -105dBm
**.wlan*.mac.*.rateSelection.dataFrameBitrate = 54Mbps
**.wlan*.mac.dcf.channelAccess.pendingQueue.packetCapacity = 14
# visualizer parameters
*.visualizer.*.numStatisticVisualizers = 2
*.visualizer.*.statisticVisualizer[0].signalName = "packetSentToUpper"
*.visualizer.*.statisticVisualizer[0].statisticExpression = "packetErrorRate"
*.visualizer.*.statisticVisualizer[0].sourceFilter = "*.destination.wlan[*].radio"
*.visualizer.*.statisticVisualizer[0].format = "packetErrorRate(Maryam): %v"
*.visualizer.*.statisticVisualizer[1].signalName = "packetSentToUpper"
*.visualizer.*.statisticVisualizer[1].statisticExpression = "minimumSnir"
*.visualizer.*.statisticVisualizer[1].sourceFilter = "*.destination.wlan[*].radio"
*.visualizer.*.statisticVisualizer[1].format = "SNIR(Maryam): %v"
*.visualizer.*.statisticVisualizer[1].placementHint = "topLeft"
*.visualizer.*.dataLinkVisualizer[0].displayLinks = true
*.visualizer.*.packetDropVisualizer[0].displayPacketDrops = true
*.visualizer.*.packetDropVisualizer[0].nodeFilter = "destination"
*.visualizer.*.packetDropVisualizer[0].labelFormat = "(Maryam) %r"
*.visualizer.*.infoVisualizer[0].displayInfos = true
*.visualizer.*.infoVisualizer[0].modules = "*.destination.app[0]"
How do I solve this?
You need to set the radioMedium type to dimensional as well
radioMedium: Ieee80211DimensionalRadioMedium {
parameters:
#display("p=62.247997,287.14398");
}
In the NED file.

converting UTF-8 string to ASCII in pure LUA

I have a question about sending and receiving data with special chars. (German Umlauts)
When I send the string "Café Zeezicht" with the code below, then on the server-side the string is oke.
But how can I receive and decode the receiving data that containing the same chars? Now it look likes "Caf? Zeezicht"
I am searching for a pure LUA function, because I have no ability to load libraries.
------------------------------------------------------------
-- Function voor converting ASCII naar UTF8
------------------------------------------------------------
-- return char as utf8 string
local function CodeToUTF8 (Unicode)
if (Unicode == nil) then
return ""
end
if (Unicode < 0x20) then return ' '; end;
if (Unicode <= 0x7F) then return string.char(Unicode); end;
if (Unicode <= 0x7FF) then
local Byte0 = 0xC0 + math.floor(Unicode / 0x40);
local Byte1 = 0x80 + (Unicode % 0x40);
return string.char(Byte0, Byte1);
end;
if (Unicode <= 0xFFFF) then
local Byte0 = 0xE0 + math.floor(Unicode / 0x1000);
local Byte1 = 0x80 + (math.floor(Unicode / 0x40) % 0x40);
local Byte2 = 0x80 + (Unicode % 0x40);
return string.char(Byte0, Byte1, Byte2);
end;
return ""; -- ignore UTF-32 for the moment
end;
-- convert ascii string to utf8 string
function AsciiToUTF8(str)
result = ""
for i = 1, #str do
result = result .. CodeToUTF8(string.byte(str, i, i+1))
end
return result
end
------------------------------------------------------------
-- Einde Function voor converting ASCII naar UTF8
------------------------------------------------------------
local char, byte, pairs, floor = string.char, string.byte, pairs, math.floor
local table_insert, table_concat = table.insert, table.concat
local unpack = table.unpack or unpack
local function unicode_to_utf8(code)
-- converts numeric UTF code (U+code) to UTF-8 string
local t, h = {}, 128
while code >= h do
t[#t+1] = 128 + code%64
code = floor(code/64)
h = h > 32 and 32 or h/2
end
t[#t+1] = 256 - 2*h + code
return char(unpack(t)):reverse()
end
local function utf8_to_unicode(utf8str, pos)
-- pos = starting byte position inside input string (default 1)
pos = pos or 1
local code, size = utf8str:byte(pos), 1
if code >= 0xC0 and code < 0xFE then
local mask = 64
code = code - 128
repeat
local next_byte = utf8str:byte(pos + size) or 0
if next_byte >= 0x80 and next_byte < 0xC0 then
code, size = (code - mask - 2) * 64 + next_byte, size + 1
else
code, size = utf8str:byte(pos), 1
end
mask = mask * 32
until code < mask
end
-- returns code, number of bytes in this utf8 char
return code, size
end
local map_1252_to_unicode = {
[0x80] = 0x20AC,
[0x81] = 0x81,
[0x82] = 0x201A,
[0x83] = 0x0192,
[0x84] = 0x201E,
[0x85] = 0x2026,
[0x86] = 0x2020,
[0x87] = 0x2021,
[0x88] = 0x02C6,
[0x89] = 0x2030,
[0x8A] = 0x0160,
[0x8B] = 0x2039,
[0x8C] = 0x0152,
[0x8D] = 0x8D,
[0x8E] = 0x017D,
[0x8F] = 0x8F,
[0x90] = 0x90,
[0x91] = 0x2018,
[0x92] = 0x2019,
[0x93] = 0x201C,
[0x94] = 0x201D,
[0x95] = 0x2022,
[0x96] = 0x2013,
[0x97] = 0x2014,
[0x98] = 0x02DC,
[0x99] = 0x2122,
[0x9A] = 0x0161,
[0x9B] = 0x203A,
[0x9C] = 0x0153,
[0x9D] = 0x9D,
[0x9E] = 0x017E,
[0x9F] = 0x0178,
[0xA0] = 0x00A0,
[0xA1] = 0x00A1,
[0xA2] = 0x00A2,
[0xA3] = 0x00A3,
[0xA4] = 0x00A4,
[0xA5] = 0x00A5,
[0xA6] = 0x00A6,
[0xA7] = 0x00A7,
[0xA8] = 0x00A8,
[0xA9] = 0x00A9,
[0xAA] = 0x00AA,
[0xAB] = 0x00AB,
[0xAC] = 0x00AC,
[0xAD] = 0x00AD,
[0xAE] = 0x00AE,
[0xAF] = 0x00AF,
[0xB0] = 0x00B0,
[0xB1] = 0x00B1,
[0xB2] = 0x00B2,
[0xB3] = 0x00B3,
[0xB4] = 0x00B4,
[0xB5] = 0x00B5,
[0xB6] = 0x00B6,
[0xB7] = 0x00B7,
[0xB8] = 0x00B8,
[0xB9] = 0x00B9,
[0xBA] = 0x00BA,
[0xBB] = 0x00BB,
[0xBC] = 0x00BC,
[0xBD] = 0x00BD,
[0xBE] = 0x00BE,
[0xBF] = 0x00BF,
[0xC0] = 0x00C0,
[0xC1] = 0x00C1,
[0xC2] = 0x00C2,
[0xC3] = 0x00C3,
[0xC4] = 0x00C4,
[0xC5] = 0x00C5,
[0xC6] = 0x00C6,
[0xC7] = 0x00C7,
[0xC8] = 0x00C8,
[0xC9] = 0x00C9,
[0xCA] = 0x00CA,
[0xCB] = 0x00CB,
[0xCC] = 0x00CC,
[0xCD] = 0x00CD,
[0xCE] = 0x00CE,
[0xCF] = 0x00CF,
[0xD0] = 0x00D0,
[0xD1] = 0x00D1,
[0xD2] = 0x00D2,
[0xD3] = 0x00D3,
[0xD4] = 0x00D4,
[0xD5] = 0x00D5,
[0xD6] = 0x00D6,
[0xD7] = 0x00D7,
[0xD8] = 0x00D8,
[0xD9] = 0x00D9,
[0xDA] = 0x00DA,
[0xDB] = 0x00DB,
[0xDC] = 0x00DC,
[0xDD] = 0x00DD,
[0xDE] = 0x00DE,
[0xDF] = 0x00DF,
[0xE0] = 0x00E0,
[0xE1] = 0x00E1,
[0xE2] = 0x00E2,
[0xE3] = 0x00E3,
[0xE4] = 0x00E4,
[0xE5] = 0x00E5,
[0xE6] = 0x00E6,
[0xE7] = 0x00E7,
[0xE8] = 0x00E8,
[0xE9] = 0x00E9,
[0xEA] = 0x00EA,
[0xEB] = 0x00EB,
[0xEC] = 0x00EC,
[0xED] = 0x00ED,
[0xEE] = 0x00EE,
[0xEF] = 0x00EF,
[0xF0] = 0x00F0,
[0xF1] = 0x00F1,
[0xF2] = 0x00F2,
[0xF3] = 0x00F3,
[0xF4] = 0x00F4,
[0xF5] = 0x00F5,
[0xF6] = 0x00F6,
[0xF7] = 0x00F7,
[0xF8] = 0x00F8,
[0xF9] = 0x00F9,
[0xFA] = 0x00FA,
[0xFB] = 0x00FB,
[0xFC] = 0x00FC,
[0xFD] = 0x00FD,
[0xFE] = 0x00FE,
[0xFF] = 0x00FF,
}
local map_unicode_to_1252 = {}
for code1252, code in pairs(map_1252_to_unicode) do
map_unicode_to_1252[code] = code1252
end
function string.fromutf8(utf8str)
local pos, result_1252 = 1, {}
while pos <= #utf8str do
local code, size = utf8_to_unicode(utf8str, pos)
pos = pos + size
code = code < 128 and code or map_unicode_to_1252[code] or ('?'):byte()
table_insert(result_1252, char(code))
end
return table_concat(result_1252)
end
function string.toutf8(str1252)
local result_utf8 = {}
for pos = 1, #str1252 do
local code = str1252:byte(pos)
table_insert(result_utf8, unicode_to_utf8(map_1252_to_unicode[code] or code))
end
return table_concat(result_utf8)
end
Usage:
local str1252 = "1\128" -- "one euro" in latin-1
local str_utf8 = str1252:toutf8() -- "1\226\130\172" -- one euro in utf-8
local str1252_2 = str_utf8:fromutf8()

How do I get the my timer to display the right number format using NSDateComponentFormatter

I've been trying to get my StopWatch to display the time in the following format
00h:00m:00s (suffixes are optional) using the NSDateComponentFormatter()
But I get is a continuous column of 0s.... any suggestions would be greatly appreciated.
func timerResults(){
++stopWatchCounter
let formatter = NSDateComponentsFormatter()
formatter.unitsStyle = .Abbreviated
formatter.allowedUnits = .CalendarUnitSecond | .CalendarUnitMinute | .CalendarUnitHour
let counterComponents = NSDateComponents()
counterComponents.hour = 00
counterComponents.minute = 00
counterComponents.second = 00
if let stopwatch = formatter.stringFromDateComponents(counterComponents){
// stopWatch.text = "\(stopwatch)"
stopWatch.text = "\(stopWatchCounter)"
println(stopwatch)
}}
Thats not possible using NSDateComponentsFormatter(). If you use .Positional you would get something like this 1:01:01. If you use .Short would be like this "1 hr, 1 min, 1 sec". You can use String(format:) and create your own format as a NStimeInterval extension as follow:
extension NSTimeInterval {
var time:String {
return String(format:"%02dh:%02dm:%02ds", Int((self/3600.0)%100),Int((self/60.0)%60), Int((self) % 60 ))
}
}
(359999.0).time // "99h:59m:59s"

How to generate random fixed interval within date range in JMeter?

I have StartDate (for instance 2011-01-01) and EndDate (for instance 2011-12-31).
All my data are placed in this range.
In test plan I need to generate random interval with fixed duration
(for 4 cases: 1, 3, 7 days and 1 month long)
which are placed in this date range [2011-01-01; 2011-12-31].
Each of these cases must have defined weights.
How should I do to get fixed interval with random Start Date and random End Date (and put these random dates into 2 variables)?
I have found this variant of java-script
The initial script is here:
var startDate = new Date();
startDate.setDate(1);
startDate.setMonth(0);
startDate.setYear(1991);
var startDateTime = startDate.getTime();
var endDate = new Date();
endDate.setDate(31);
endDate.setMonth(11);
endDate.setYear(2003);
var endDateTime = endDate.getTime();
var randomDate = new Date();
var randomDateTime = startDateTime+Math.random()*(endDateTime-startDateTime);
randomDate.setTime(randomDateTime);
var rndDate = randomDate.getDate();
var rndMonth = randomDate.getMonth() + 1;
var rndYear = randomDate.getFullYear();
if (rndDate.toString().length == 1)
rndDate = "0" + rndDate;
if (rndMonth.toString().length == 1)
rndMonth = "0" + rndMonth;
rndDate + "/" + rndMonth + "/" + rndYear;
But I need generate random start date of the fixed interval (which I called ${RandomStartDate}) and then to add the length of the interval to get the end date of it (this date I called ${RandomEndDate}).
Then I have change the script for 1 day long interval (1 day is 86400 seconds):
var startDate = new Date();
startDate.setDate(01);
startDate.setMonth(01);
startDate.setYear(2011);
var startDateTime = startDate.getTime();
var endDate = new Date();
endDate.setDate(31);
endDate.setMonth(12);
endDate.setYear(2011);
var endDateTime = endDate.getTime();
var randomSDate = new Date();
var randomSDateTime = startDateTime+Math.random()*((endDateTime - 86400) -startDateTime );
randomSDate.setTime(randomSDateTime);
var randomEDate = new Date();
var randomEDateTime = (randomSDateTime + 86400); //add 1 day long interval (86400 s)
randomEDate.setTime(randomEDateTime); //convert number format to string format of date
var rndSDate = randomSDate.getDate();
var rndSMonth = randomSDate.getMonth()+1 ;
var rndSYear = randomSDate.getFullYear();
var rndEDate = randomEDate.getDate();
var rndEMonth = randomEDate.getMonth()+1 ;
var rndEYear = randomEDate.getFullYear();
if (rndSDate.toString().length == 1)
rndSDate = "0" + rndSDate;
if (rndSMonth.toString().length == 1)
rndSMonth = "0" + rndSMonth;
if (rndEDate.toString().length == 1)
rndEDate = "0" + rndEDate;
if (rndEMonth.toString().length == 1)
rndEMonth = "0" + rndEMonth;
var RandomStartDate = rndSYear + "-" + rndSMonth + "-" + rndSDate;
vars.put ("RandomStartDate", RandomStartDate);
var RandomEndDate = rndEYear + "-" + rndEMonth + "-" + rndEDate;
vars.put ("RandomEndDate", RandomEndDate);
But this script generates RandomEndDate which is equal to RandomStartDate.
If I generate RandomStartDate separately (without the parts of code which are connected with RandomEndDate) the script works good.
Could you help me, please? What is wrong?
You can do it in Beanshell with much less amount of code:
import java.text.SimpleDateFormat;
import java.util.Calendar;
calendar = Calendar.getInstance();
calendar.set(2011, 0, 1);
startTime = calendar.getTimeInMillis();
calendar.set(2012, 11, 31);
endTime = calendar.getTimeInMillis();
randomTime1 = startTime + (long)(Math.random()*(endTime-startTime));
randomTime2 = randomTime1 + (long)(Math.random()*(endTime - randomTime1)+86400000);
formatter = new SimpleDateFormat("yyyy-MM-dd");
calendar.setTimeInMillis(randomTime1);
vars.put("start", formatter.format(calendar.getTime()));
calendar.setTimeInMillis(randomTime2);
vars.put("end", formatter.format(calendar.getTime()));
For situations like this I would opt to put the complexity outside of jMeter, and create a perl script to generate 100 pairs of dates according to your requirements and read them into jMeter variables using CSV Data Set Config.
I have found the solution!
This is the correct script, which allow to model the random interval with fixed length (1 day long interval) and get 2 variables fot it start and end - ${RandomStartDate} and ${RandomEndDate}:
var startDate = new Date();
startDate.setDate(01);
startDate.setMonth(01);
startDate.setYear(2011);
var startDateTime = startDate.getTime();
var endDate = new Date();
endDate.setDate(31);
endDate.setMonth(12);
endDate.setYear(2011);
var endDateTime = endDate.getTime();
var randomSDate = new Date();
var randomSDateTime = startDateTime+Math.random()*((endDateTime - 86400000) -startDateTime );
randomSDate.setTime(randomSDateTime);
var randomEDate = new Date();
var randomEDateTime = (randomSDateTime + 86400000); //add 1 day long interval (86400000 ms)
randomEDate.setTime(randomEDateTime); //convert number format to string format of date
var rndSDate = randomSDate.getDate();
var rndSMonth = randomSDate.getMonth()+1 ;
var rndSYear = randomSDate.getFullYear();
var rndEDate = randomEDate.getDate();
var rndEMonth = randomEDate.getMonth()+1 ;
var rndEYear = randomEDate.getFullYear();
if (rndSDate.toString().length == 1)
rndSDate = "0" + rndSDate;
if (rndSMonth.toString().length == 1)
rndSMonth = "0" + rndSMonth;
if (rndEDate.toString().length == 1)
rndEDate = "0" + rndEDate;
if (rndEMonth.toString().length == 1)
rndEMonth = "0" + rndEMonth;
var RandomStartDate = rndSYear + "-" + rndSMonth + "-" + rndSDate;
vars.put ("RandomStartDate", RandomStartDate);
var RandomEndDate = rndEYear + "-" + rndEMonth + "-" + rndEDate;
vars.put ("RandomEndDate", RandomEndDate);
My mistake was I thought that the time is in seconds, but it is in milliseconds!

Print a header on set page using Abc PDF

I have created pdf from HTML page using Abc PDF now my problem is I want to print a table header on next page, but only if table data is display within a another page, if not display header on a different page, any one have idea about how we can do this using Abc pdf.
What you need to do is create the page with some space at the top, then once your document is built in abc PDF loop though the pages and add a header.
The code below is what I use to add a header, the header in this case has three bits a image at the top and two boxes with text in.
Remember the cord in abc pdf are from the bottom right not the top left.
private static Doc AddHeader(Doc theDoc, Core.Property propertyDetails)
{
int theCount = theDoc.PageCount;
int i = 0;
//Image header
for (i = 1; i <= theCount; i++)
{
theDoc.Rect.Width = 590;
theDoc.Rect.Height = 140;
theDoc.Rect.Position(0, 712);
theDoc.PageNumber = i;
//Check Which office to use.
string imagefilePath = HttpContext.Current.Server.MapPath("/images/pdf/pdf-header.png");
Bitmap myBmp = (Bitmap)Bitmap.FromFile(imagefilePath);
theDoc.AddImage(myBmp);
}
//page header boxes.
//Grey header box
theDoc.Rect.String = "20 15 590 50";
theDoc.Rect.Position(13, 672);
System.Drawing.Color colour = System.Drawing.ColorTranslator.FromHtml("#CCCCCC");
theDoc.Color.Color = colour;
theDoc.PageNumber = 1;
theDoc.FillRect();
theDoc.Rect.String = "20 15 586 50";
theDoc.Rect.Position(30, 660);
System.Drawing.Color pageoneText = System.Drawing.ColorTranslator.FromHtml("#50474A");
theDoc.Color.Color = pageoneText;
string thePageFont = "Century Gothic";
theDoc.Font = theDoc.AddFont(thePageFont);
theDoc.FontSize = 16;
theDoc.PageNumber = 1;
theDoc.AddText("My Text!!!!!");
theDoc.Rect.String = "20 15 590 50";
theDoc.Rect.Position(13, 630);
System.Drawing.Color greyBox = System.Drawing.ColorTranslator.FromHtml("#468DCB");
theDoc.Color.Color = greyBox;
theDoc.PageNumber = 1;
theDoc.FillRect();
theDoc.Rect.String = "20 15 586 50";
theDoc.Rect.Position(30, 620);
System.Drawing.Color greyText = System.Drawing.ColorTranslator.FromHtml("#ffffff");
theDoc.Color.Color = greyText;
string thePageFontTwo = "Century Gothic";
theDoc.Font = theDoc.AddFont(thePageFontTwo);
theDoc.FontSize = 14;
theDoc.PageNumber = 1;
theDoc.AddText("This is more text");
return theDoc;
}
Then once the pdf file is created just call
var theDoc = new Doc();
/// Your document creation stuff!!!
theDoc = AddHeader(theDoc, propertyDetails);

Resources