using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.IO.Compression;
private static int stopLine = 3000000;
public static void Main()
string input =@"<printjob document=""Receipt with Arabic.pdf"" origin=""\\DESKTOP-C9PC88G\m"" version=""3.6.3.8236"" dpi=""300"" printer=""XML Printer"">
<page number=""1"" type=""NorthAmericaLetter"" width-px=""3300"" height-px=""2550"" width-mm=""279"" height-mm=""216"" orientation=""landscape"">
<text left=""109"" top=""167"" width=""237"" height=""43"" font-face=""C:\\Users\\abdul\\Downloads\\with arabic-00001\\with arabic_00000.ttf"" font-size=""7.5"">7/27/23, 1:12 AM</text>
<text left=""1632"" top=""167"" width=""391"" height=""43"" font-face=""C:\\Users\\abdul\\Downloads\\with arabic-00001\\with arabic_00000.ttf"" font-size=""7.5"">Edit Receipt :: Skynova.com</text>
<text left=""109"" top=""2337"" width=""745"" height=""43"" font-face=""C:\\Users\\abdul\\Downloads\\with arabic-00001\\with arabic_00000.ttf"" font-size=""7.5"">https://www.skynova.com/app/receipts/edit?c=300959</text>
<text left=""3148"" top=""2337"" width=""43"" height=""43"" font-face=""C:\\Users\\abdul\\Downloads\\with arabic-00001\\with arabic_00000.ttf"" font-size=""7.5"">1/1</text>
<path fillcolor=""#ffffffff"">
<line style=""beginning"">
<point x=""480"" y=""226""/>
<point x=""2825"" y=""226""/>
<point x=""2825"" y=""1972""/>
<point x=""480"" y=""1972""/>
<point x=""480"" y=""226""/>
<path fillcolor=""#ff000000"" fillmode=""F1"">
<line style=""beginning"">
<point x=""480"" y=""1623""/>
<point x=""2825"" y=""1623""/>
<point x=""2825"" y=""1626""/>
<point x=""480"" y=""1626""/>
<point x=""480"" y=""1623""/>
<path fillcolor=""#ff000000"">
<line style=""beginning"">
<point x=""2821"" y=""970""/>
<point x=""2824"" y=""970""/>
<point x=""2824"" y=""1627""/>
<point x=""2821"" y=""1627""/>
<point x=""2821"" y=""970""/>
<line style=""beginning"">
<point x=""480"" y=""970""/>
<point x=""483"" y=""970""/>
<point x=""483"" y=""1627""/>
<point x=""480"" y=""1627""/>
<point x=""480"" y=""970""/>
<path fillcolor=""#ffe9eced"" fillmode=""F1"">
<line style=""beginning"">
<point x=""483"" y=""970""/>
<point x=""747"" y=""970""/>
<point x=""747"" y=""1064""/>
<point x=""483"" y=""1064""/>
<point x=""483"" y=""970""/>
<path fillcolor=""#ff000000"">
<line style=""beginning"">
<point x=""483"" y=""970""/>
<point x=""747"" y=""970""/>
<point x=""747"" y=""973""/>
<point x=""483"" y=""973""/>
<point x=""483"" y=""970""/>
<line style=""beginning"">
<point x=""483"" y=""1061""/>
<point x=""747"" y=""1061""/>
<point x=""747"" y=""1064""/>
<point x=""483"" y=""1064""/>
<point x=""483"" y=""1061""/>
<path fillcolor=""#ffe9eced"" fillmode=""F1"">
<line style=""beginning"">
<point x=""746"" y=""970""/>
<point x=""2030"" y=""970""/>
<point x=""2030"" y=""1064""/>
<point x=""746"" y=""1064""/>
<point x=""746"" y=""970""/>
<path fillcolor=""#ff000000"">
<line style=""beginning"">
<point x=""746"" y=""970""/>
<point x=""2030"" y=""970""/>
<point x=""2030"" y=""973""/>
<point x=""746"" y=""973""/>
<point x=""746"" y=""970""/>
<line style=""beginning"">
<point x=""746"" y=""1061""/>
<point x=""2030"" y=""1061""/>
<point x=""2030"" y=""1064""/>
<point x=""746"" y=""1064""/>
<point x=""746"" y=""1061""/>
<path fillcolor=""#ffe9eced"" fillmode=""F1"">
<line style=""beginning"">
<point x=""2030"" y=""970""/>
<point x=""2294"" y=""970""/>
<point x=""2294"" y=""1064""/>
<point x=""2030"" y=""1064""/>
<point x=""2030"" y=""970""/>
<path fillcolor=""#ff000000"">
<line style=""beginning"">
<point x=""2030"" y=""970""/>
<point x=""2294"" y=""970""/>
<point x=""2294"" y=""973""/>
<point x=""2030"" y=""973""/>
<point x=""2030"" y=""970""/>
<line style=""beginning"">
<point x=""2030"" y=""1061""/>
<point x=""2294"" y=""1061""/>
<point x=""2294"" y=""1064""/>
<point x=""2030"" y=""1064""/>
<point x=""2030"" y=""1061""/>
<path fillcolor=""#ffe9eced"" fillmode=""F1"">
<line style=""beginning"">
<point x=""2294"" y=""970""/>
<point x=""2558"" y=""970""/>
<point x=""2558"" y=""1064""/>
<point x=""2294"" y=""1064""/>
<point x=""2294"" y=""970""/>
<path fillcolor=""#ff000000"">
<line style=""beginning"">
<point x=""2294"" y=""970""/>
<point x=""2558"" y=""970""/>
<point x=""2558"" y=""973""/>
<point x=""2294"" y=""973""/>
<point x=""2294"" y=""970""/>
<line style=""beginning"">
<point x=""2294"" y=""1061""/>
<point x=""2558"" y=""1061""/>
<point x=""2558"" y=""1064""/>
<point x=""2294"" y=""1064""/>
<point x=""2294"" y=""1061""/>
<path fillcolor=""#ffe9eced"" fillmode=""F1"">
<line style=""beginning"">
<point x=""2558"" y=""970""/>
<point x=""2822"" y=""970""/>
<point x=""2822"" y=""1064""/>
<point x=""2558"" y=""1064""/>
<point x=""2558"" y=""970""/>
<path fillcolor=""#ff000000"">
<line style=""beginning"">
<point x=""2558"" y=""970""/>
<point x=""2822"" y=""970""/>
<point x=""2822"" y=""973""/>
<point x=""2558"" y=""973""/>
<point x=""2558"" y=""970""/>
<line style=""beginning"">
<point x=""2558"" y=""1061""/>
<point x=""2822"" y=""1061""/>
<point x=""2822"" y=""1064""/>
<point x=""2558"" y=""1064""/>
<point x=""2558"" y=""1061""/>
<path fillcolor=""#ffffffff"" fillmode=""F1"">
<line style=""beginning"">
<point x=""480"" y=""1620""/>
<point x=""2825"" y=""1620""/>
<point x=""2825"" y=""1972""/>
<point x=""480"" y=""1972""/>
<point x=""480"" y=""1620""/>
<path strokecolor=""#ff000000"" width=""0.72"" fillmode=""F1"">
<line style=""beginning"">
<point x=""481"" y=""1622""/>
<point x=""2823"" y=""1622""/>
<point x=""2823"" y=""1970""/>
<point x=""481"" y=""1970""/>
<point x=""481"" y=""1622""/>
<point x=""481"" y=""1622""/>
<path fillcolor=""#ff000000"" fillmode=""F1"">
<line style=""beginning"">
<point x=""1837"" y=""1623""/>
<point x=""1840"" y=""1623""/>
<point x=""1840"" y=""1969""/>
<point x=""1837"" y=""1969""/>
<point x=""1837"" y=""1623""/>
<path fillcolor=""#ff000000"">
<line style=""beginning"">
<point x=""1839"" y=""1708""/>
<point x=""2822"" y=""1708""/>
<point x=""2822"" y=""1711""/>
<point x=""1839"" y=""1711""/>
<point x=""1839"" y=""1708""/>
<path fillcolor=""#ffe9eced"" fillmode=""F1"">
<line style=""beginning"">
<point x=""1839"" y=""1875""/>
<point x=""2549"" y=""1875""/>
<point x=""2549"" y=""1969""/>
<point x=""1839"" y=""1969""/>
<point x=""1839"" y=""1875""/>
<path fillcolor=""#ff000000"" fillmode=""F1"">
<line style=""beginning"">
<point x=""1839"" y=""1875""/>
<point x=""2549"" y=""1875""/>
<point x=""2549"" y=""1878""/>
<point x=""1839"" y=""1878""/>
<point x=""1839"" y=""1875""/>
<path fillcolor=""#ffe9eced"" fillmode=""F1"">
<line style=""beginning"">
<point x=""2549"" y=""1875""/>
<point x=""2822"" y=""1875""/>
<point x=""2822"" y=""1969""/>
<point x=""2549"" y=""1969""/>
<point x=""2549"" y=""1875""/>
<path fillcolor=""#ff000000"" fillmode=""F1"">
<line style=""beginning"">
<point x=""2549"" y=""1875""/>
<point x=""2822"" y=""1875""/>
<point x=""2822"" y=""1878""/>
<point x=""2549"" y=""1878""/>
<point x=""2549"" y=""1875""/>
<text left=""2332"" top=""709"" width=""206"" height=""52"" font-face=""with arabic_00001.ttf"" font-size=""9"">Receipt #</text>
<text left=""2652"" top=""710"" width=""168"" height=""52"" font-face=""with arabic_00002.ttf"" font-size=""9"">0000001</text>
<text left=""2438"" top=""806"" width=""100"" height=""52"" font-face=""with arabic_00001.ttf"" font-size=""9"">Date</text>
<text left=""2593"" top=""807"" width=""228"" height=""52"" font-face=""with arabic_00002.ttf"" font-size=""9"">07/26/2023</text>
<text left=""480"" top=""259"" width=""333"" height=""52"" font-face=""with arabic_00002.ttf"" font-size=""9"">Ahmed Mohamed</text>
<text left=""480"" top=""298"" width=""436"" height=""52"" font-face=""with arabic_00002.ttf"" font-size=""9"">30 Imbaba Amr STreet</text>
<text left=""480"" top=""667"" width=""177"" height=""52"" font-face=""with arabic_00002.ttf"" font-size=""9"">Sayed Ali</text>
<text left=""480"" top=""705"" width=""175"" height=""52"" font-face=""with arabic_00002.ttf"" font-size=""9"">50 Algiza</text>
<text left=""2366"" top=""248"" width=""203"" height=""118"" font-face=""with arabic_00003.ttf"" font-size=""19.5"" color=""#ff2b2b2b"">R E C</text>
<text left=""2583"" top=""248"" width=""93"" height=""118"" font-face=""with arabic_00003.ttf"" font-size=""19.5"" color=""#ff2b2b2b"">E I</text>
<text left=""2690"" top=""248"" width=""120"" height=""118"" font-face=""with arabic_00003.ttf"" font-size=""19.5"" color=""#ff2b2b2b"">P T</text>
<text left=""509"" top=""989"" width=""84"" height=""59"" font-face=""with arabic_00003.ttf"" font-size=""10"">Item</text>
<text left=""761"" top=""989"" width=""226"" height=""59"" font-face=""with arabic_00003.ttf"" font-size=""10"">Description</text>
<text left=""2088"" top=""989"" width=""192"" height=""59"" font-face=""with arabic_00003.ttf"" font-size=""10"">Unit Price</text>
<text left=""2377"" top=""989"" width=""167"" height=""59"" font-face=""with arabic_00003.ttf"" font-size=""10"">Quantity</text>
<text left=""2640"" top=""989"" width=""156"" height=""59"" font-face=""with arabic_00003.ttf"" font-size=""10"">Amount</text>
<text left=""509"" top=""1077"" width=""134"" height=""48"" font-face=""with arabic_00002.ttf"" font-size=""8.5"">Product</text>
<text left=""761"" top=""1077"" width=""201"" height=""48"" font-face=""with arabic_00002.ttf"" font-size=""8.5"">Item No 01</text>
<text left=""2155"" top=""1077"" width=""123"" height=""48"" font-face=""with arabic_00002.ttf"" font-size=""8.5"">120.00</text>
<text left=""2463"" top=""1077"" width=""79"" height=""48"" font-face=""with arabic_00002.ttf"" font-size=""8.5"">2.00</text>
<text left=""2671"" top=""1077"" width=""123"" height=""48"" font-face=""with arabic_00002.ttf"" font-size=""8.5"">240.00</text>
<text left=""509"" top=""1165"" width=""134"" height=""48"" font-face=""with arabic_00002.ttf"" font-size=""8.5"">Product</text>
<text left=""761"" top=""1165"" width=""201"" height=""48"" font-face=""with arabic_00002.ttf"" font-size=""8.5"">Item No 02</text>
<text left=""2177"" top=""1165"" width=""101"" height=""48"" font-face=""with arabic_00002.ttf"" font-size=""8.5"">30.00</text>
<text left=""2463"" top=""1165"" width=""79"" height=""48"" font-face=""with arabic_00002.ttf"" font-size=""8.5"">1.00</text>
<text left=""2693"" top=""1165"" width=""101"" height=""48"" font-face=""with arabic_00002.ttf"" font-size=""8.5"">30.00</text>
<text left=""509"" top=""1252"" width=""134"" height=""48"" font-face=""with arabic_00002.ttf"" font-size=""8.5"">Product</text>
<text left=""761"" top=""1252"" width=""201"" height=""48"" font-face=""with arabic_00002.ttf"" font-size=""8.5"">Item No 03</text>
<text left=""2155"" top=""1252"" width=""123"" height=""48"" font-face=""with arabic_00002.ttf"" font-size=""8.5"">302.00</text>
<text left=""2463"" top=""1252"" width=""79"" height=""48"" font-face=""with arabic_00002.ttf"" font-size=""8.5"">2.00</text>
<text left=""2671"" top=""1252"" width=""123"" height=""48"" font-face=""with arabic_00002.ttf"" font-size=""8.5"">604.00</text>
<text left=""509"" top=""1340"" width=""147"" height=""48"" font-face=""with arabic_00002.ttf"" font-size=""8.5"">Expense</text>
<text left=""761"" top=""1340"" width=""63"" height=""48"" font-face=""with arabic_00000.ttf"" font-size=""8.5"">هلابه</text>
<text left=""814"" top=""1340"" width=""12"" height=""48"" font-face=""with arabic_00002.ttf"" font-size=""8.5""> </text>
<text left=""826"" top=""1340"" width=""31"" height=""48"" font-face=""with arabic_00000.ttf"" font-size=""8.5"">وبا</text>
<text left=""858"" top=""1340"" width=""12"" height=""48"" font-face=""with arabic_00002.ttf"" font-size=""8.5""> </text>
<text left=""870"" top=""1340"" width=""53"" height=""48"" font-face=""with arabic_00000.ttf"" font-size=""8.5"">ديسلا</text>
<text left=""924"" top=""1340"" width=""12"" height=""48"" font-face=""with arabic_00002.ttf"" font-size=""8.5""> </text>
<text left=""936"" top=""1340"" width=""55"" height=""48"" font-face=""with arabic_00000.ttf"" font-size=""8.5"">ىلع</text>
<text left=""982"" top=""1340"" width=""12"" height=""48"" font-face=""with arabic_00002.ttf"" font-size=""8.5""> </text>
<text left=""995"" top=""1340"" width=""78"" height=""48"" font-face=""with arabic_00000.ttf"" font-size=""8.5"">باسح</text>
<text left=""2155"" top=""1340"" width=""123"" height=""48"" font-face=""with arabic_00002.ttf"" font-size=""8.5"">200.00</text>
<text left=""2463"" top=""1340"" width=""79"" height=""48"" font-face=""with arabic_00002.ttf"" font-size=""8.5"">1.00</text>
<text left=""2671"" top=""1340"" width=""123"" height=""48"" font-face=""with arabic_00002.ttf"" font-size=""8.5"">200.00</text>
<text left=""509"" top=""1428"" width=""131"" height=""48"" font-face=""with arabic_00002.ttf"" font-size=""8.5"">Service</text>
<text left=""761"" top=""1428"" width=""151"" height=""48"" font-face=""with arabic_00002.ttf"" font-size=""8.5"">Nawloon</text>
<text left=""2155"" top=""1428"" width=""123"" height=""48"" font-face=""with arabic_00002.ttf"" font-size=""8.5"">120.00</text>
<text left=""2463"" top=""1428"" width=""79"" height=""48"" font-face=""with arabic_00002.ttf"" font-size=""8.5"">1.00</text>
<text left=""2671"" top=""1428"" width=""123"" height=""48"" font-face=""with arabic_00002.ttf"" font-size=""8.5"">120.00</text>
<text left=""483"" top=""1768"" width=""13"" height=""52"" font-face=""with arabic_00002.ttf"" font-size=""9""> </text>
<text left=""1942"" top=""1641"" width=""180"" height=""52"" font-face=""with arabic_00001.ttf"" font-size=""9"">Subtotal</text>
<text left=""2622"" top=""1642"" width=""173"" height=""52"" font-face=""with arabic_00002.ttf"" font-size=""9"">1,194.00</text>
<text left=""1942"" top=""1729"" width=""108"" height=""52"" font-face=""with arabic_00001.ttf"" font-size=""9"">Total</text>
<text left=""2622"" top=""1730"" width=""173"" height=""52"" font-face=""with arabic_00002.ttf"" font-size=""9"">1,194.00</text>
<text left=""1942"" top=""1802"" width=""273"" height=""52"" font-face=""with arabic_00001.ttf"" font-size=""9"">Amount Paid</text>
<text left=""2622"" top=""1803"" width=""173"" height=""52"" font-face=""with arabic_00002.ttf"" font-size=""9"">1,194.00</text>
<text left=""1942"" top=""1896"" width=""264"" height=""52"" font-face=""with arabic_00001.ttf"" font-size=""9"">Balance Due</text>
<text left=""2709"" top=""1897"" width=""86"" height=""52"" font-face=""with arabic_00002.ttf"" font-size=""9"">0.00</text>
<image left=""2640"" top=""1132"" width=""131"" height=""131"" src=""C:\\Users\\abdul\\Downloads\\with arabic-00001\\with arabic_00000.png"">
<line style=""beginning"">
<point x=""2640"" y=""1132""/>
<point x=""2771"" y=""1132""/>
<point x=""2771"" y=""1263""/>
<point x=""2640"" y=""1263""/>
<point x=""2640"" y=""1132""/>
<image left=""2640"" top=""1143"" width=""131"" height=""132"" src=""C:\\Users\\abdul\\Downloads\\with arabic-00001\\with arabic_00001.png"">
<line style=""beginning"">
<point x=""2640"" y=""1143""/>
<point x=""2771"" y=""1143""/>
<point x=""2771"" y=""1275""/>
<point x=""2640"" y=""1275""/>
<point x=""2640"" y=""1143""/>
<image left=""2657"" top=""1149"" width=""98"" height=""97"" src=""C:\\Users\\abdul\\Downloads\\with arabic-00001\\with arabic_00002.png"">
<line style=""beginning"">
<point x=""2698"" y=""1149""/>
<point x=""2694"" y=""1150""/>
<point x=""2691"" y=""1151""/>
<point x=""2687"" y=""1152""/>
<point x=""2686"" y=""1153""/>
<point x=""2682"" y=""1155""/>
<point x=""2681"" y=""1156""/>
<point x=""2679"" y=""1157""/>
<point x=""2678"" y=""1158""/>
<point x=""2676"" y=""1159""/>
<point x=""2669"" y=""1166""/>
<point x=""2668"" y=""1168""/>
<point x=""2666"" y=""1170""/>
<point x=""2662"" y=""1178""/>
<point x=""2661"" y=""1179""/>
<point x=""2660"" y=""1183""/>
<point x=""2659"" y=""1186""/>
<point x=""2658"" y=""1190""/>
<point x=""2657"" y=""1197""/>
<point x=""2657"" y=""1246""/>
<point x=""2712"" y=""1245""/>
<point x=""2717"" y=""1244""/>
<point x=""2721"" y=""1243""/>
<point x=""2724"" y=""1242""/>
<point x=""2732"" y=""1238""/>
<point x=""2733"" y=""1237""/>
<point x=""2735"" y=""1236""/>
<point x=""2745"" y=""1226""/>
<point x=""2746"" y=""1224""/>
<point x=""2747"" y=""1223""/>
<point x=""2749"" y=""1219""/>
<point x=""2750"" y=""1216""/>
<point x=""2752"" y=""1212""/>
<point x=""2753"" y=""1208""/>
<point x=""2754"" y=""1203""/>
<point x=""2755"" y=""1192""/>
<point x=""2754"" y=""1192""/>
<point x=""2754"" y=""1188""/>
<point x=""2753"" y=""1188""/>
<point x=""2753"" y=""1184""/>
<point x=""2752"" y=""1184""/>
<point x=""2752"" y=""1182""/>
<point x=""2751"" y=""1182""/>
<point x=""2751"" y=""1180""/>
<point x=""2750"" y=""1180""/>
<point x=""2750"" y=""1177""/>
<point x=""2749"" y=""1177""/>
<point x=""2749"" y=""1175""/>
<point x=""2748"" y=""1175""/>
<point x=""2748"" y=""1173""/>
<point x=""2747"" y=""1173""/>
<point x=""2747"" y=""1171""/>
<point x=""2746"" y=""1170""/>
<point x=""2745"" y=""1170""/>
<point x=""2745"" y=""1168""/>
<point x=""2735"" y=""1158""/>
<point x=""2733"" y=""1157""/>
<point x=""2732"" y=""1156""/>
<point x=""2724"" y=""1152""/>
<point x=""2718"" y=""1150""/>
<point x=""2714"" y=""1149""/>
<point x=""2698"" y=""1149""/>
<line style=""beginning"">
<point x=""2657"" y=""1149""/>
<point x=""2755"" y=""1149""/>
<point x=""2755"" y=""1246""/>
<point x=""2657"" y=""1246""/>
<point x=""2657"" y=""1149""/>
<image left=""2683"" top=""1175"" width=""48"" height=""36"" src=""C:\\Users\\abdul\\Downloads\\with arabic-00001\\with arabic_00003.png"">
<line style=""beginning"">
<point x=""2690"" y=""1175""/>
<point x=""2687"" y=""1176""/>
<point x=""2685"" y=""1177""/>
<point x=""2683"" y=""1181""/>
<point x=""2683"" y=""1205""/>
<point x=""2684"" y=""1205""/>
<point x=""2684"" y=""1208""/>
<point x=""2685"" y=""1208""/>
<point x=""2685"" y=""1210""/>
<point x=""2687"" y=""1210""/>
<point x=""2728"" y=""1211""/>
<point x=""2728"" y=""1210""/>
<point x=""2730"" y=""1210""/>
<point x=""2730"" y=""1208""/>
<point x=""2731"" y=""1179""/>
<point x=""2730"" y=""1179""/>
<point x=""2730"" y=""1177""/>
<point x=""2728"" y=""1176""/>
<point x=""2725"" y=""1175""/>
<point x=""2690"" y=""1175""/>
<line style=""beginning"">
<point x=""2693"" y=""1181""/>
<point x=""2691"" y=""1182""/>
<point x=""2690"" y=""1184""/>
<point x=""2690"" y=""1203""/>
<point x=""2691"" y=""1203""/>
<point x=""2725"" y=""1204""/>
<point x=""2725"" y=""1182""/>
<point x=""2722"" y=""1181""/>
<point x=""2693"" y=""1181""/>
<line style=""beginning"">
<point x=""2683"" y=""1175""/>
<point x=""2731"" y=""1175""/>
<point x=""2731"" y=""1211""/>
<point x=""2683"" y=""1211""/>
<point x=""2683"" y=""1175""/>
<image left=""2683"" top=""1213"" width=""48"" height=""10"" src=""C:\\Users\\abdul\\Downloads\\with arabic-00001\\with arabic_00004.png"">
<line style=""beginning"">
<point x=""2689"" y=""1213""/>
<point x=""2686"" y=""1214""/>
<point x=""2684"" y=""1216""/>
<point x=""2683"" y=""1218""/>
<point x=""2684"" y=""1219""/>
<point x=""2684"" y=""1221""/>
<point x=""2685"" y=""1221""/>
<point x=""2687"" y=""1222""/>
<point x=""2729"" y=""1223""/>
<point x=""2729"" y=""1222""/>
<point x=""2730"" y=""1221""/>
<point x=""2731"" y=""1216""/>
<point x=""2729"" y=""1214""/>
<point x=""2726"" y=""1213""/>
<point x=""2689"" y=""1213""/>
<line style=""beginning"">
<point x=""2683"" y=""1213""/>
<point x=""2731"" y=""1213""/>
<point x=""2731"" y=""1223""/>
<point x=""2683"" y=""1223""/>
<point x=""2683"" y=""1213""/>
<path fillcolor=""#ffededed"" fillmode=""F1"">
<curve style=""beginning"">
<point x=""2690"" y=""1184""/>
<point x=""2690"" y=""1182""/>
<point x=""2691"" y=""1181""/>
<point x=""2693"" y=""1181""/>
<point x=""2722"" y=""1181""/>
<point x=""2723"" y=""1181""/>
<point x=""2725"" y=""1182""/>
<point x=""2725"" y=""1184""/>
<point x=""2725"" y=""1201""/>
<point x=""2725"" y=""1203""/>
<point x=""2723"" y=""1204""/>
<point x=""2722"" y=""1204""/>
<point x=""2693"" y=""1204""/>
<point x=""2691"" y=""1204""/>
<point x=""2690"" y=""1203""/>
<point x=""2690"" y=""1201""/>
<point x=""2690"" y=""1184""/>
<point x=""2690"" y=""1184""/>
<path fillcolor=""#ff000000"" fillmode=""F1"">
<line style=""beginning"">
<point x=""2683"" y=""1175""/>
<point x=""2683"" y=""1223""/>
<point x=""2731"" y=""1223""/>
<point x=""2731"" y=""1175""/>
<point x=""2683"" y=""1175""/>
<line style=""beginning"">
<point x=""2722"" y=""1181""/>
<point x=""2722"" y=""1181""/>
<point x=""2693"" y=""1181""/>
<point x=""2693"" y=""1181""/>
<point x=""2691"" y=""1181""/>
<point x=""2692"" y=""1181""/>
<point x=""2690"" y=""1182""/>
<point x=""2691"" y=""1182""/>
<point x=""2690"" y=""1183""/>
<point x=""2690"" y=""1183""/>
<point x=""2690"" y=""1184""/>
<point x=""2690"" y=""1184""/>
<point x=""2690"" y=""1202""/>
<point x=""2690"" y=""1201""/>
<point x=""2690"" y=""1203""/>
<point x=""2690"" y=""1202""/>
<point x=""2691"" y=""1204""/>
<point x=""2690"" y=""1203""/>
<point x=""2692"" y=""1204""/>
<point x=""2691"" y=""1204""/>
<point x=""2693"" y=""1204""/>
<point x=""2693"" y=""1204""/>
<point x=""2722"" y=""1204""/>
<point x=""2722"" y=""1204""/>
<point x=""2723"" y=""1204""/>
<point x=""2723"" y=""1204""/>
<point x=""2724"" y=""1203""/>
<point x=""2724"" y=""1204""/>
<point x=""2725"" y=""1202""/>
<point x=""2724"" y=""1203""/>
<point x=""2725"" y=""1201""/>
<point x=""2725"" y=""1202""/>
<point x=""2725"" y=""1184""/>
<point x=""2725"" y=""1184""/>
<point x=""2724"" y=""1183""/>
<point x=""2725"" y=""1183""/>
<point x=""2724"" y=""1182""/>
<point x=""2724"" y=""1182""/>
<point x=""2723"" y=""1181""/>
<point x=""2723"" y=""1181""/>
<point x=""2722"" y=""1181""/>
<point x=""2722"" y=""1181""/>
<line style=""beginning"">
<point x=""2724"" y=""1179""/>
<point x=""2726"" y=""1180""/>
<point x=""2727"" y=""1182""/>
<point x=""2728"" y=""1184""/>
<point x=""2728"" y=""1202""/>
<point x=""2727"" y=""1204""/>
<point x=""2726"" y=""1206""/>
<point x=""2724"" y=""1207""/>
<point x=""2722"" y=""1207""/>
<point x=""2692"" y=""1207""/>
<point x=""2690"" y=""1207""/>
<point x=""2688"" y=""1206""/>
<point x=""2687"" y=""1204""/>
<point x=""2687"" y=""1202""/>
<point x=""2687"" y=""1184""/>
<point x=""2687"" y=""1182""/>
<point x=""2688"" y=""1180""/>
<point x=""2690"" y=""1179""/>
<point x=""2692"" y=""1178""/>
<point x=""2722"" y=""1178""/>
<point x=""2724"" y=""1179""/>
<point x=""2724"" y=""1179""/>
<image left=""2693"" top=""1187"" width=""11"" height=""10"" src=""C:\\Users\\abdul\\Downloads\\with arabic-00001\\with arabic_00005.png"">
<line style=""beginning"">
<point x=""2696"" y=""1187""/>
<point x=""2695"" y=""1188""/>
<point x=""2693"" y=""1192""/>
<point x=""2694"" y=""1193""/>
<point x=""2694"" y=""1195""/>
<point x=""2695"" y=""1195""/>
<point x=""2696"" y=""1196""/>
<point x=""2701"" y=""1197""/>
<point x=""2701"" y=""1196""/>
<point x=""2703"" y=""1195""/>
<point x=""2704"" y=""1190""/>
<point x=""2703"" y=""1190""/>
<point x=""2703"" y=""1188""/>
<point x=""2701"" y=""1187""/>
<point x=""2696"" y=""1187""/>
<line style=""beginning"">
<point x=""2693"" y=""1187""/>
<point x=""2704"" y=""1187""/>
<point x=""2704"" y=""1197""/>
<point x=""2693"" y=""1197""/>
<point x=""2693"" y=""1187""/>
<image left=""2710"" top=""1187"" width=""11"" height=""10"" src=""C:\\Users\\abdul\\Downloads\\with arabic-00001\\with arabic_00005.png"">
<line style=""beginning"">
<point x=""2713"" y=""1187""/>
<point x=""2712"" y=""1188""/>
<point x=""2710"" y=""1192""/>
<point x=""2711"" y=""1193""/>
<point x=""2711"" y=""1195""/>
<point x=""2712"" y=""1195""/>
<point x=""2713"" y=""1196""/>
<point x=""2718"" y=""1197""/>
<point x=""2718"" y=""1196""/>
<point x=""2720"" y=""1195""/>
<point x=""2721"" y=""1190""/>
<point x=""2720"" y=""1190""/>
<point x=""2720"" y=""1188""/>
<point x=""2718"" y=""1187""/>
<point x=""2713"" y=""1187""/>
<line style=""beginning"">
<point x=""2710"" y=""1187""/>
<point x=""2721"" y=""1187""/>
<point x=""2721"" y=""1197""/>
<point x=""2710"" y=""1197""/>
<point x=""2710"" y=""1187""/>
Configuration config = new Configuration(1077, 761, 2000, 2155, 2400, 2463, 2600, 2671, 2700, "Subtotal");
config.BuyerNameStartX = 400;
config.BuyerNameEndX = 900;
config.BuyerAddressY = 705;
config.BuyerAddressStartX = 400;
config.BuyerAddressEndX = 900;
config.ProductStartPhrase = "Item";
config.InvoiceNumberY = 710;
config.InvoiceStartX = 2600;
config.InvoiceEndX = 2800;
Invoice inv = ProcessPrintXMLInv(input, config);
string json = JsonConvert.SerializeObject(inv, Newtonsoft.Json.Formatting.Indented);
byte[] compressed = Compress(json);
string decompressed = Decompress(compressed);
Console.WriteLine(decompressed);
int originalSize = json.Length;
int compressedSize = compressed.Length;
double compressionRate = (1 - (double)compressedSize / originalSize) * 100;
Console.WriteLine("Original Size: {0} bytes",originalSize);
Console.WriteLine("Compressed Size: {0} bytes",compressedSize);
Console.WriteLine("Compression Rate: {0}",compressionRate);
private static byte[] Compress(string text)
using (MemoryStream memoryStream = new MemoryStream())
using (GZipStream gzipStream = new GZipStream(memoryStream, CompressionMode.Compress))
using (StreamWriter writer = new StreamWriter(gzipStream))
compressedData = memoryStream.ToArray();
private static string Decompress(byte[] compressedData)
string decompressedJson=null;
using (MemoryStream memoryStream = new MemoryStream(compressedData))
using (GZipStream gzipStream = new GZipStream(memoryStream, CompressionMode.Decompress))
using (StreamReader reader = new StreamReader(gzipStream))
decompressedJson = reader.ReadToEnd();
private static Invoice ProcessPrintXMLInv(string input, Configuration config)
XmlDocument xmlDoc = new XmlDocument();
Invoice inv = new Invoice();
HashSet<Record> lines = new HashSet<Record>();
string arabicPattern = @"[\u0600-\u06FF]+";
string cleanNumbersPattern = @"[,\n]";
string newLinePattern = @"[\s]+";
string pattern = @"<text left=""([\d]+)"" top=""([\d]+)"" width=""([\d]+)"" height=""([\d]+)""[\w|\W]*?>([a-zA-Z\s0-9 #.ا-ي,\/]*)";
RegexOptions options = RegexOptions.Multiline;
inv.BuyerInfo = new BuyerInfo();
XmlNodeList elements = xmlDoc.GetElementsByTagName("text");
foreach (XmlNode element in elements)
Int32 x = int.Parse(element.Attributes["left"].Value);
Int32 y = int.Parse(element.Attributes["top"].Value);
string text = element.InnerText;
if (y == config.BuyerNameY && x >= config.BuyerNameStartX && x <= config.BuyerNameEndX)
inv.BuyerInfo.Name = text;
if (y == config.BuyerAddressY && x >= config.BuyerAddressStartX && x <= config.BuyerAddressEndX)
inv.BuyerInfo.Address = text;
if (y == config.InvoiceNumberY && x >= config.InvoiceStartX && x <= config.InvoiceEndX)
inv.InvoiceNumber = text;
if (y == config.ProductStartY || y > config.ProductStartY)
if (text.Equals(config.StopLinePhrase))
if (y != stopLine && y < stopLine)
bool f = lines.TryGetValue(r, out rr);
if (x >= config.ProductUnitPriceStartX && x <= config.ProductUnitPriceEndX)
rr.UnitPrice = Decimal.Parse(Regex.Replace(text, cleanNumbersPattern, ""));
if (x >= config.ProductTotalPriceStartX && x <= config.ProductTotalPriceEndX)
rr.TotalPrice = Decimal.Parse(Regex.Replace(text, cleanNumbersPattern, ""));
if (x >= config.ProductUnitQuantStartX && x <= config.ProductUnitQuantEndX)
rr.Quantity = Decimal.Parse(Regex.Replace(text, cleanNumbersPattern, ""));
if (x >= config.ProductNameStartX && x <= config.ProductNameEndX)
if (!Regex.IsMatch(text, arabicPattern))
rr.AddProductChunck(Regex.Replace(text, newLinePattern, " "));
rr.AddProductChunck(Regex.Replace(ReverseString(text)+" ", newLinePattern, " "));
inv.Lines=lines.Select(p => new Line{Quantity=p.Quantity,UnitPrice=p.UnitPrice,TotalPrice=p.TotalPrice,ProductName=p.ProductName,Y=p.Y}).Where(line => line.Quantity > 0).ToList();
private static string ReverseString(string input)
StringBuilder sb = new StringBuilder();
char[] array = input.ToCharArray();
for (int i = 0; i < array.Length; i++)
sealed class Configuration
public int BuyerNameY { get; set; }
public int BuyerNameStartX { get; set; }
public int BuyerNameEndX { get; set; }
public int BuyerAddressY { get; set; }
public int BuyerAddressStartX { get; set; }
public int BuyerAddressEndX { get; set; }
public int InvoiceNumberY { get; set; }
public int InvoiceStartX { get; set; }
public int InvoiceEndX { get; set; }
public int ProductStartY { get; set; }
public string ProductStartPhrase { get; set; }
public int LineHeight { get; set; }
public int ProductNameStartX { get; set; }
public int ProductNameEndX { get; set; }
public int ProductUnitPriceStartX { get; set; }
public int ProductUnitPriceEndX { get; set; }
public int ProductUnitQuantStartX { get; set; }
public int ProductUnitQuantEndX { get; set; }
public int ProductTotalPriceStartX { get; set; }
public int ProductTotalPriceEndX { get; set; }
public string StopLinePhrase { get; set; }
public Configuration(int productStartY, int productNameStartX, int productNameEndX, int productUnitPriceStartX, int productUnitPriceEndX, int productUnitQuantStartX, int productUnitQuantEndX, int productTotalPriceStartX, int productTotalPriceEndX, string stopLinePhrase)
ProductStartY = productStartY;
ProductNameStartX = productNameStartX;
ProductNameEndX = productNameEndX;
ProductUnitPriceStartX = productUnitPriceStartX;
ProductUnitPriceEndX = productUnitPriceEndX;
ProductUnitQuantStartX = productUnitQuantStartX;
ProductUnitQuantEndX = productUnitQuantEndX;
ProductTotalPriceStartX = productTotalPriceStartX;
ProductTotalPriceEndX = productTotalPriceEndX;
StopLinePhrase = stopLinePhrase;
public string Identification { get; set; }
public string Name { get; set; }
public string Address { get; set; }
public string Identification { get; set; }
public string Name { get; set; }
public string Address { get; set; }
public string POS { get; set; }
public string InvoiceNumber { get; set; }
public string DueDate { get; set; }
public SellerInfo SellerInfo { get; set; }
public BuyerInfo BuyerInfo { get; set; }
public List<Line> Lines { get; set; }
public override string ToString()
return string.Format("InvoiceNumber={0},Buyer Name={1}, Buyer Address = {2}", InvoiceNumber, BuyerInfo.Name, BuyerInfo.Address);
protected Queue<string> product;
protected decimal quantity;
protected decimal totalPrice;
protected bool arabicText;
this.product = new Queue<string>();
public Record(int y, Queue<string> product, decimal quantity, decimal price, decimal totalPrice)
this.quantity = quantity;
this.totalPrice = totalPrice;
Console.WriteLine("Constructor created");
public Queue<string> Product
public decimal TotalPrice
public string ProductName
StringBuilder sb = new StringBuilder();
foreach (string p1 in product)
Array ar = product.ToArray();
for (int i = ar.Length - 1; i >= 0; i--)
sb.Append(ar.GetValue(i));
public void AddProductChunck(string nameChunck)
this.product.Enqueue(nameChunck);
public override int GetHashCode()
public override bool Equals(object obj)
return obj is Record && Equals((Record)obj);
public bool Equals(Record r)
public override string ToString()
return string.Format("{4}-Product name={0},Unit Price={1}, Quantity = {2},Total Price={3}", ProductName, price, quantity, totalPrice, y);
public int Y { get; set; }
public string ProductName { get; set; }
public decimal Quantity { get; set; }
public decimal UnitPrice { get; set; }
public decimal TotalPrice { get; set; }
public override string ToString()
return string.Format("{4}-Product name={0},Unit Price={1}, Quantity = {2},Total Price={3}", ProductName, UnitPrice, Quantity, TotalPrice, Y);