2011-03-17 52 views
0
string pdfpath = Server.MapPath("images"); 
    string imagepath = Server.MapPath("Images"); 

    using (Stream inputPdfStream = new FileStream(pdfpath + "\\NLI_Filled_out.pdf", FileMode.Open, FileAccess.Read, FileShare.Read)) 
    using (Stream inputImageStream = new FileStream(imagepath + "\\sign2.gif", FileMode.Open, FileAccess.Read, FileShare.Read)) 
    using (Stream outputPdfStream = new FileStream(pdfpath + "\\NLI_Filled_output.pdf", FileMode.Create, FileAccess.Write, FileShare.None)) 
    { 
     var reader = new PdfReader(inputPdfStream); 

     var stamper = new PdfStamper(reader, outputPdfStream); 

     var pdfContentByte = stamper.GetOverContent(3); 

     iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(inputImageStream); 

     image.ScalePercent(24f); 

     image.SetAbsolutePosition(100, 130); 

     pdfContentByte.AddImage(image); 

     stamper.Close(); 
    } 

我在3.5使用linq..i上面的代碼想要將其轉換成DOTNET 2.0 ...誰能請幫助...轉換LINQ代碼DOTNET 2.0

+3

LINQ在哪裏? – 2011-03-17 18:57:56

+0

你只是有一個'使用System.Linq;'在頂部?如果是這樣,只要刪除它,看看你是否有任何錯誤,這意味着你在這個頁面上有Linq代碼。 – 2011-03-17 18:59:26

回答

2

有沒有LINQ那裏。您的問題是(如果您出於任何原因針對C#2.0),在3.5之前的版本中不支持var關鍵字。只需將var實例更改爲顯式適當的類(PdfReader,PdfStamper,以及GetOverContent的返回類型)。

+0

thnx所有...我從來沒有使用過「使用」和「var」這種方式... – user321963 2011-03-18 02:35:55