zoukankan      html  css  js  c++  java
  • html导出pdf

    PdfConverter pdfConverter = new PdfConverter();
    
    pdfConverter.PdfDocumentOptions.PdfPageSize = PdfPageSize.A4;
    pdfConverter.PdfDocumentOptions.PdfCompressionLevel = PdfCompressionLevel.Normal;
    pdfConverter.PdfDocumentOptions.ShowHeader = true;
    pdfConverter.PdfDocumentOptions.ShowFooter = true;
    pdfConverter.PdfDocumentOptions.LeftMargin = 5;
    pdfConverter.PdfDocumentOptions.RightMargin = 5;
    pdfConverter.PdfDocumentOptions.TopMargin = 5;
    pdfConverter.PdfDocumentOptions.BottomMargin = 5;
    pdfConverter.PdfDocumentOptions.GenerateSelectablePdf = true;
    
    pdfConverter.PdfDocumentOptions.ShowHeader = false;
    //pdfConverter.PdfHeaderOptions.HeaderText = "Sample header: " + TxtURL.Text;
    //pdfConverter.PdfHeaderOptions.HeaderTextColor = Color.Blue;
    //pdfConverter.PdfHeaderOptions.HeaderDescriptionText = string.Empty;
    //pdfConverter.PdfHeaderOptions.DrawHeaderLine = false;
    
    pdfConverter.PdfFooterOptions.FooterText = "Sample footer: " + TxtURL.Text + 
    ". You can change color, font and other options";
    pdfConverter.PdfFooterOptions.FooterTextColor = Color.Blue;
    pdfConverter.PdfFooterOptions.DrawFooterLine = false;
    pdfConverter.PdfFooterOptions.PageNumberText = "Page";
    pdfConverter.PdfFooterOptions.ShowPageNumber = true;
    
    //pdfConverter.LicenseKey = "put your serial number here";
    byte[] downloadBytes = pdfConverter.GetPdfFromUrlBytes(url);
    
    
    System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
    response.Clear();
    response.AddHeader("Content-Type", "binary/octet-stream");
    response.AddHeader("Content-Disposition",
        "attachment; filename=" + downloadName + "; size=" + downloadBytes.Length.ToString());
    response.Flush();
    response.BinaryWrite(downloadBytes);
    response.Flush();
    response.End();
    



  • 相关阅读:
    c#中的构造方法
    c# Dictionary拓展2个key得到1个value
    虚拟主机的提权两个小技巧
    teamviewer提权
    域渗透:mstsc连接记录清理
    linux之 vim 常用命令
    Linux之 find 命令学习
    域渗透:MS14-068
    学习:脱壳之Anti Dump和修复PE
    学习:KiUserExceptionDispatcher之寻找OEP
  • 原文地址:https://www.cnblogs.com/lovenan/p/2818028.html
Copyright © 2011-2022 走看看