ASP.net で、オファー フォームに入力するための Web ページを作成しました。3つの部門があります。入力する TextBoxes を持つ左の div。フォーム自体である中央のセクター。ボタンを持つ右の div。
これまでのところ、左側とすべてに記入した内容で、中央部のみを PDF にエクスポートできました。問題は、絶対配置を使用して作成された CSS を完全に無視していることです。したがって、CSS スタイルを含めて、1 つの連続したテキストではなく、想定どおりに見えるようにする方法をお尋ねしたいと思います。
ミドルセクターのコードは次のとおりです。
<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, is slechts toegestaan na schriftelijk toestemming van Visser Supplies B.V.</label>
</div>
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;
}
最後に、関数の背後にあるコードを次に示します: (編集: 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);
}
finally
{
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)
{
}
次の場所でエラーが発生します: Server.Execute("middlesector", strWriter); そして同じエラー: Server.Execute("OfferteForm1.aspx", strWriter);
これは、IUSRS_machinename および ASPNET ユーザーのアクセス許可に関係しています。しかし、マニフェストがなく、どういうわけか作成できないため、アクセス許可を追加する方法がわかりません。
私も試しました: Server.HtmlDecode("middlesector", strWriter); そして: Server.HtmlDecode("OfferteForm1.aspx", strWriter);
PDFをコンパイルしますが、画像しかありません。私が望むのは、XMLWorker が記入済みのフォームをミドルセクターの Div に含めることだけです。