2013-09-02 1 views
0

RazorPDF를 사용할 때 히브리어 문자를 표시 할 수 없습니다. 가능한 경우 또는 HTML을 PDF로 변환하는 다른 좋은 솔루션이 있는지 알고 싶습니다. 가장 좋은 것은 뷰를 지정하고 MVC 4를 사용하고 PDF 문서를 얻는 것입니다.RazorPDF 인코딩

+0

http://www.codeproject.com/Articles/335595/Rotativa-how-to-print-PDF-in-Asp-Net- : 여기

PDF로 iTextSharp HTML을위한 샘플입니다 MVC – Steve

+0

rotativa는 훌륭한 솔루션이지만 공유 환경에서 실행하지 않는 한 클라우드에서 작동하지 않습니다. – UshaP

답변

0

구름의 경우 iTextSharp 라이브러리를 사용하여이를 수행 할 수 있습니다. itextsharp.text.html.simpleparser.html 근로자을 확인하십시오.

다른 신뢰할 수있는 방법은 Ghostscript 라이브러리를 사용하는 것입니다 (클라우드에서 사용할 수 있는지 확실하지 않습니다). 먼저 HTML을 Postscript로 변환 한 다음 Postscript를 PDF로 변환 할 수 있습니다.

.NET 용으로 가장 완벽한 Ghostscript 래퍼가 필요하면 다음을보십시오. Ghostscript.NET.

private MemoryStream createPDF(string html) 
{ 
    MemoryStream msOutput = new MemoryStream(); 
    TextReader reader = new StringReader(html); 

    // step 1: creation of a document-object 
    Document document = new Document(PageSize.A4, 30, 30, 30, 30);    

    // step 2: 
    // we create a writer that listens to the document 
    // and directs a XML-stream to a file 
    PdfWriter writer = PdfWriter.GetInstance(document, msOutput); 

    // step 3: we create a worker parse the document 
    HTMLWorker worker = new HTMLWorker(document); 

    // step 4: we open document and start the worker on the document 
    document.Open(); 
    worker.StartDocument(); 

    // step 5: parse the html into the document 
    worker.Parse(reader); 

    // step 6: close the document and the worker 
    worker.EndDocument(); 
    worker.Close(); 
    document.Close(); 

    return msOutput; 
} 
+0

영어 이외의 문자를 지원합니까? 어떻게 PDF를 화면에 표시합니까? 내가 FileResult (내가 MVC 4를 사용하여)를 시도했을 때 오류가 발생했습니다 – UshaP

+0

보십시오 : http://stackoverflow.com/questions/11524293/displaying-pdf-asp-net-mvc – HABJAN

+0

죄송합니다, 나는 의미가 없습니다. 기존 파일을 어떻게 표시할지, 방금 생성 한 파일을 표시하는 방법 - 동일한 창에서 다운로드 /. – UshaP