2015-12-23 42 views
0

我正在嘗試生成PDF,但掛起系統和Web的字節錯誤有一些問題。生成帶字節錯誤的文本PDF錯誤

我發現了一些原因,但仍找不到解決方案。

當我調試時,我的編解碼器停在這裏,並凍結我的網頁。然後,我重新啓動後,它將非常緩慢地加載我的網頁。

我發現如果我寫了超過200個字符,它會錯誤的系統。但如果我不這樣做,一切都會好起來的。我只想知道爲什麼。

我在這裏不是很專業。感謝您的幫助。這是停止並凍結的編解碼器調試。誰能幫我?

Dim bytes() As Byte 
     Dim fs As FileStream = New FileStream(strNewPathPDF, FileMode.Open, FileAccess.Read) 
     Dim reader As BinaryReader = New BinaryReader(fs) 
     bytes = reader.ReadBytes(CType(fs.Length, Integer)) 
     fs.Close() 
+0

你用C#標記這個的原因嗎? – DavidG

+0

c#也可以參與.. – user3921882

+0

您是否正在運行Avast或AVG? [不](http://dottech.org/102416/why-i-switched-from-avast-to-avira-better-computer-performance-and-speed-opinion/)。 –

回答

0

你從這裏得到nreco DLL:https://www.nuget.org/packages/NReco.PdfGenerator/

你也可以使用下面的代碼:

    NReco.PdfGenerator.HtmlToPdfConverter nPdf = new NReco.PdfGenerator.HtmlToPdfConverter(); 

nPdf.Size = PageSize.Letter; 

PageMargins mar = new PageMargins(); 
mar.Bottom = -5; 
mar.Left = -5; 
mar.Top = -5; 
mar.Right = -5; 
nPdf.Margins = mar; 

nPdf.Orientation = PageOrientation.Landscape; 
var pdffilename = "D:\Documents"+"filename" + ".pdf"; 

var htmltext="this testing pdf" 
var pdfBytes = nPdf.GeneratePdf(htmltext); 
File.WriteAllBytes(pdffilename, pdfBytes);