特定の条件に基づいて動的にPDFを作成しようとしましたが、私たちのマシンとクライアントのマシンの1つでかなりうまく機能します。しかし、別の顧客の場合、システムを展開したときに、pdf が正しく生成されません。これを生成する次のコードがあります
public void pdf_ModerateData(string name, string dob, string gender, string age)
{
Phrase pat_name = new Phrase();
Phrase phr_paitient_name = new Phrase();
Phrase phr_paitient_dob = new Phrase();
Paragraph pat_det = new Paragraph();
Paragraph paitient_name_dob = new Paragraph();
Paragraph mul_column = new Paragraph();
iTextSharp.text.Font fntNormalText = FontFactory.GetFont(FontFactory.TIMES, 12, iTextSharp.text.Font.NORMAL);
iTextSharp.text.Font fntBoldText = FontFactory.GetFont(FontFactory.TIMES, 12, iTextSharp.text.Font.BOLD);
iTextSharp.text.Font fntsmallText = FontFactory.GetFont(FontFactory.TIMES, 8, iTextSharp.text.Font.NORMAL);
phr_paitient_name = new Phrase(System.Environment.NewLine + System.Environment.NewLine + name + " " + dob, fntNormalText);
pat_name = new Phrase(System.Environment.NewLine + " " + System.Environment.NewLine + " ", fntsmallText);
pat_det.Add(phr_paitient_name);
pat_det.Add(pat_name);
Phrase emt = new Phrase();
Paragraph emty = new Paragraph();
emt = new Phrase(System.Environment.NewLine + " ", fntNormalText);
emty.Add(emt);
HttpContext.Current.Response.ContentType = "application/pdf";
HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=GridViewExport.pdf");
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
Document pdfDoc = new Document();
PdfWriter.GetInstance(pdfDoc, HttpContext.Current.Response.OutputStream);
pdfDoc.Open();
iTextSharp.text.Image logo = iTextSharp.text.Image.GetInstance("C:/trial/dms/img/moderatetool.jpg");
logo.ScaleAbsolute(475, 600);
PdfPTable table = new PdfPTable(1);
table.TotalWidth = 500f;
table.LockedWidth = true;
iTextSharp.text.Image barcode = iTextSharp.text.Image.GetInstance("C:/trial/dms/barcode/brcode.gif");
barcode.ScaleAbsolute(100, 50);
PdfPTable nested = new PdfPTable(2);
mul_column.Add(pat_det);
PdfPCell mul = new PdfPCell(mul_column);
mul.HorizontalAlignment = Element.ALIGN_LEFT;
mul.BorderWidth = 0;
nested.AddCell(mul);
//PdfPCell imag = new PdfPCell(barcode);
//imag.HorizontalAlignment = Element.ALIGN_RIGHT;
//imag.BorderWidth = 0;
//nested.AddCell(imag);
PdfPCell imag = new PdfPCell(barcode);
imag.HorizontalAlignment = Element.ALIGN_RIGHT;
imag.BorderWidth = 0;
nested.AddCell(imag);
PdfPTable nested1 = new PdfPTable(2);
//mul_column.Add(pat_det);
PdfPCell mul1 = new PdfPCell(emty);
mul1.HorizontalAlignment = Element.ALIGN_LEFT;
mul1.BorderWidth = 0;
nested1.AddCell(mul1);
PdfPCell imag1 = new PdfPCell(barcode);
imag1.HorizontalAlignment = Element.ALIGN_RIGHT;
imag1.BorderWidth = 0;
nested1.AddCell(imag1);
PdfPCell nesthousing = new PdfPCell(nested1);
nesthousing.Padding = 0f;
nesthousing.BorderWidth = 0;
table.AddCell(nesthousing);
PdfPCell image_header = new PdfPCell(logo);
image_header.HorizontalAlignment = Element.ALIGN_CENTER;
image_header.BorderWidth = 0;
table.AddCell(image_header);
Paragraph para = new Paragraph();
//string pat = get_patientDET();
//para = new Paragraph(pat);
PdfPCell header = new PdfPCell(para);
header.HorizontalAlignment = Element.ALIGN_CENTER;
header.Colspan = 4;
header.BorderWidth = 0;
//table.AddCell(header);
PdfPCell nesthousing1 = new PdfPCell(nested);
nesthousing.Padding = 0f;
nesthousing.BorderWidth = 0;
nesthousing1.BorderColor = BaseColor.WHITE;
table.AddCell(nesthousing1);
pdfDoc.Add(table);
pdfDoc.Close();
HttpContext.Current.Response.Write(pdfDoc);
HttpContext.Current.Response.End();
}
誰でもこれを解決するために私を導くことができます..
サーバー: Windows 2008 R2 データセンター 64 ビット servicepack1
PDF をダウンロードすると、「 Gridviewreoprt.pdf,attachment 」としてダウンロードされ、正しく動作しません。