c# - iTextSharp aspx to pdf, Server.Execute error -
in asp.net have made webpage used fill in offer form. there 3 divs. left div has textboxes fill in. middlesector form itself. right div has buttons.
so far i've been able export midlesector pdf stuff filled in on left , all. problem neglects css, has been made using absolute positioning. therefore ask how include css style looks way it's supposed instead of 1 continuous text.
this code middlesector:
<div id="middlesector" runat="server"> <%--><asp:gridview id="gridview1" runat="server"></asp:gridview>--%> <asp:image id="textarea1" runat="server" imageurl="images\vissergroup.png"></asp:image> <label id="textarea2" runat="server" cols="20" name="s2"></label> <label id="textarea3" runat="server" cols="20" name="s3">visser international trade & engineering</label> <label id="textarea4" runat="server" cols="20" name="s4">t.a.v</label> <label id="textarea5" runat="server" cols="20" name="s5">postbus</label> <label id="textarea6" runat="server" name="s6"></label> <label id="textarea7" runat="server" cols="20" name="s7"></label> <label id="textarea8" runat="server" cols="20" name="s8"></label> <label id="textarea9" runat="server" name="s9"></label> <label id="textarea10" runat="server" cols="20" name="s10"></label> <label id="textarea11" runat="server" cols="20" name="s11"></label> <label id="textarea12" runat="server" cols="20" name="s12">-offerte-</label> <label id="textarea13" runat="server" name="s13">geachte</label> <label id="textarea14" runat="server" name="s14"></label> <label id="textarea15" runat="server" cols="20" name="s15">met referte aan het aangename onderhoud hebben wij het genoegen u bijgaand onze offerte te doen toekomen voor het leveren van:</label> <label id="textarea16" runat="server" cols="20" name="s16"></label> <label id="textarea17" runat="server" cols="20" name="s17">wij danken u voor deze aanvraag en hopen u hiermee een passend voorstel te hebben gedaan. voor het bespreken van verdere details en toelichting op de offerte zullen wij op korte termijn contact met u opnemen. indien u direct uw eventuele vragen aan ons wenst voor te leggen dan horen wij dit graag van u.</label> <label id="textarea18" runat="server" cols="20" name="s18">wij vertrouwen u hiermee voldoende van dienst te zijn en houden ons van harte aanbevolen voor uw gewaardeerde opdracht.</label> <label id="textarea19" runat="server" cols="20" name="s19">met vriendelijke groet,visser supplies b.v.</label> <label id="textarea20" runat="server" cols="20" name="s20">personal info</label> <label id="textarea21" runat="server" cols="20" name="s21">website : www.vissersupplies.nl</label> <label id="textarea22" runat="server" cols="20" name="s22">e-mail : personal info</label> <label id="textarea23" runat="server" cols="20" name="s23">telefoonnummer : personal info 9894</label> <label id="textarea24" runat="server" cols="20" name="s24">copyright visser supplies b.v.:</label> <label id="textarea25" runat="server" cols="20" name="s25">deze offerte en alle andere informatie mogen alleen door geadresseerde gebruikt worden. overdracht aan derden, in welke vorm dan ook, slechts toegestaan na schriftelijk toestemming van visser supplies b.v.</label> </div>
here css:
#middlesector { position:absolute; left: 150px; top: 60px; } #textarea1 { height: 250px; width: 640px; position: absolute; top:-40px; border:none; scrollbar-3dlight-color: #fff; scrollbar-arrow-color: #fff; scrollbar-base-color: #fff; } #textarea2 { border-style: none; border-color: inherit; border-width: medium; height: 105px; width: 320px; position:absolute; top:220px; scrollbar-3dlight-color: #fff; scrollbar-arrow-color: #fff; scrollbar-base-color: #fff; } #textarea3 { border-style: none; border-color: inherit; border-width: medium; height: 30px; width: 310px; position:absolute; top:215px; left: 410px; scrollbar-3dlight-color: #fff; scrollbar-arrow-color: #fff; scrollbar-base-color: #fff; } #textarea4 { border-style: none; border-color: inherit; border-width: medium; height: 15px; width: 310px; position:absolute; top:250px; left: 410px; scrollbar-3dlight-color: #fff; scrollbar-arrow-color: #fff; scrollbar-base-color: #fff; } #textarea5 { border-style: none; border-color: inherit; border-width: medium; height: 15px; width: 310px; position:absolute; top:270px; left: 410px; scrollbar-3dlight-color: #fff; scrollbar-arrow-color: #fff; scrollbar-base-color: #fff; } #textarea6 { border-style: none; border-color: inherit; border-width: medium; height: 15px; width: 100px; position:absolute; top:290px; left: 410px; scrollbar-3dlight-color: #fff; scrollbar-arrow-color: #fff; scrollbar-base-color: #fff; } #textarea7 { border-style: none; border-color: inherit; border-width: medium; height: 15px; width: 310px; position:absolute; top:310px; left: 410px; scrollbar-3dlight-color: #fff; scrollbar-arrow-color: #fff; scrollbar-base-color: #fff; } #textarea8 { border-style: none; border-color: inherit; border-width: medium; height: 15px; width: 210px; position:absolute; top:290px; left: 480px; scrollbar-3dlight-color: #fff; scrollbar-arrow-color: #fff; scrollbar-base-color: #fff; } #textarea9 { border-style: none; border-color: inherit; border-width: medium; height: 15px; width: 130px; position:absolute; top: 360px; left: 360px; scrollbar-3dlight-color: #fff; scrollbar-arrow-color: #fff; scrollbar-base-color: #fff; } #textarea10 { height: 15px; width: 180px; position:absolute; top:360px; left: 450px; border:none; scrollbar-3dlight-color: #fff; scrollbar-arrow-color: #fff; scrollbar-base-color: #fff; } #textarea11 { border-style: none; border-color: inherit; border-width: medium; height: 15px; width: 320px; position:absolute; top:360px; scrollbar-3dlight-color: #fff; scrollbar-arrow-color: #fff; scrollbar-base-color: #fff; left: 0px; } #textarea12 { border-style: none; border-color: inherit; border-width: medium; font-size: large; font-weight: bold; height: 25px; width: 120px; position:absolute; top:400px; scrollbar-3dlight-color: #fff; scrollbar-arrow-color: #fff; scrollbar-base-color: #fff; left: 270px; } #textarea13 { border-style: none; border-color: inherit; border-width: medium; height: 15px; width: 75px; position:absolute; top:450px; scrollbar-3dlight-color: #fff; scrollbar-arrow-color: #fff; scrollbar-base-color: #fff; left: 0px; } #textarea14 { border-style: none; border-color: inherit; border-width: medium; height: 15px; width: 200px; position:absolute; top:450px; scrollbar-3dlight-color: #fff; scrollbar-arrow-color: #fff; scrollbar-base-color: #fff; left: 65px; margin-left: auto; } #textarea15 { height: 30px; width: 640px; text-align:start; text-anchor:end; position: absolute; top:480px; border:hidden; scrollbar-3dlight-color: #fff; scrollbar-arrow-color: #fff; scrollbar-base-color: #fff; left: 0px; } #textarea16 { border-style: none; border-color: inherit; border-width: medium; font-size:large; font-weight: bold; height: 25px; width: 250px; position:absolute; top:540px; scrollbar-3dlight-color: #fff; scrollbar-arrow-color: #fff; scrollbar-base-color: #fff; left: 270px; } #textarea17 { height: 75px; width: 645px; text-align:start; text-anchor:end; position: absolute; top:580px; border:hidden; scrollbar-3dlight-color: #fff; scrollbar-arrow-color: #fff; scrollbar-base-color: #fff; left: 0px; } #textarea18 { height: 30px; width: 640px; text-align:start; text-anchor:end; position: absolute; top:660px; border:hidden; scrollbar-3dlight-color: #fff; scrollbar-arrow-color: #fff; scrollbar-base-color: #fff; left: 0px; } #textarea19 { width: 240px; position: absolute; top: 700px; scrollbar-3dlight-color: #fff; scrollbar-arrow-color: #fff; scrollbar-base-color: #fff; border:hidden; left: 0px; } #textarea20 { height: 15px; width: 400px; position: absolute; top: 760px; scrollbar-3dlight-color: #fff; scrollbar-arrow-color: #fff; scrollbar-base-color: #fff; border:hidden; left: 0px; } #textarea21 { height: 15px; width: 400px; position: absolute; top: 800px; scrollbar-3dlight-color: #fff; scrollbar-arrow-color: #fff; scrollbar-base-color: #fff; border:hidden; left: 0px; } #textarea22 { height: 15px; width: 400px; position: absolute; top: 820px; scrollbar-3dlight-color: #fff; scrollbar-arrow-color: #fff; scrollbar-base-color: #fff; border:hidden; left: 0px; } #textarea23 { height: 15px; width: 400px; position: absolute; top: 840px; scrollbar-3dlight-color: #fff; scrollbar-arrow-color: #fff; scrollbar-base-color: #fff; border:hidden; left: 0px; } #textarea24 { height: 10px; width: 400px; font-size:smaller; position: absolute; top: 880px; scrollbar-3dlight-color: #fff; scrollbar-arrow-color: #fff; scrollbar-base-color: #fff; border:hidden; left: 0px; } #textarea25 { height: 40px; width: 550px; font-size: x-small; position: absolute; top: 895px; scrollbar-3dlight-color: #fff; scrollbar-arrow-color: #fff; scrollbar-base-color: #fff; border:hidden; left: 0px; }
and here code behind function: (edited: 10-10-2013: 14:22:gtm+1)
protected void saveaspdf(object sender, eventargs e) { system.web.ui.htmlcontrols.htmlgenericcontrol middlesector = new system.web.ui.htmlcontrols.htmlgenericcontrol("middlesector"); string strhtml = null; //memorystream memstream = new memorystream(); stringwriter strwriter = new stringwriter(); server.execute("offerteform1.aspx", strwriter); strhtml = strwriter.tostring(); strwriter.close(); strwriter.dispose(); itextsharp.text.image addlogo = default(itextsharp.text.image); addlogo = itextsharp.text.image.getinstance(server.mappath("images") + "/vissersupplies.jpg"); itextsharp.text.document docworkingdocument = new itextsharp.text.document(pagesize.a4, 40, 40, 40, 40); stringreader srddoctostring = null; try { pdfwriter pdfwrite = default(pdfwriter); var filecounter = 1; while (file.exists("c:/users/milans/documents/pdfs/" + textarea11.innertext + " - " + filecounter + ".pdf")) { filecounter++; } pdfwrite = pdfwriter.getinstance(docworkingdocument, new filestream("c:/users/milans/documents/pdfs/" + textarea11.innertext + " - " + filecounter + ".pdf", filemode.create)); srddoctostring = new stringreader(strhtml); docworkingdocument.open(); addlogo.scalepercent(50); addlogo.alignment = itextsharp.text.image.align_center; docworkingdocument.add(addlogo); xmlworkerhelper.getinstance().parsexhtml(pdfwrite, docworkingdocument, srddoctostring); } catch (exception ex) { response.write(ex.message); } { if ((docworkingdocument != null)) { docworkingdocument.close(); docworkingdocument.dispose(); } if ((srddoctostring != null)) { srddoctostring.close(); srddoctostring.dispose(); } } //page.clientscript.registerclientscriptblock(this.gettype(), "myscript", "window.open('c:/users/milans/documents/pdfs/" + textarea11.innertext + ".pdf" + "','_blank','location=0,menubar=0,status=0,titlebar=0,toolbar=0');", true); } public override void verifyrenderinginserverform(control control) { }
i error at: server.execute("middlesector", strwriter); , same error for: server.execute("offerteform1.aspx", strwriter);
it has permissions iusrs_machinename , aspnet users. don't know how add permissions since don't have manifest , somehow can't create one.
i've tried: server.htmldecode("middlesector", strwriter); and: server.htmldecode("offerteform1.aspx", strwriter);
it compile pdf has image. want xmlworker include filled in form in middlesector div.
Comments
Post a Comment