在asp.net web应用程序中从html字符串创建pdf [英] create pdf from html string in asp.net web application

查看:79
本文介绍了在asp.net web应用程序中从html字符串创建pdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Everybody,



我正在创建一个Web应用程序,我正在从数据库中获取HTML代码包含

    和< img>标签与内联样式。当我使用iTextSharp从该字符串创建PDF时,文本覆盖在图像上,但相同的html在浏览器中工作正常。



    如何解决这个问题问题?



    有人可以帮帮我吗?



    我的HTML是

    ================================================== ======

     <   html  >  
    < body >
    < span style = color:#005AA0; font-family:Arial,Helvetica,sans-serif; font-size:15px!important; font-weight:bold; margin-bottom:5px; margin-top :5px; text-tra nsform:uppercase; > 在关于我们上添加图片< / span >
    < br / >
    < br / >
    < br / >
    < span style = font-family:Arial,Helvetica,sans-serif; font-size:15px; > 关于我们:< / span >
    < ol style = font-family:Arial,Helvetica,sans-serif; font-尺寸:15px;行高:40px; >
    < li > 选择&添加图像块&。 < img src = http:// localhost:2107 / Images / HelpImages / AddImageBlock。 jpg > < / li >
    < li > 点击&添加/编辑图像&。 < img src = http:// localhost:2107 / Images / HelpImages / AddEditImage。 jpg > < / li >
    < li > 如果图片位于图片库中,请点击图片(不是复选框)并转到第9步。< / li >
    < li > 将图片添加到从您的计算机库中,单击&'Brows E&安培;'上。 < br / >
    < img src = http:// localhost:2107 / Images / HelpImages / imgBrowse.jpg > < / li >
    < li > 双击要上传的图像文件。注意:您只能上传jpeg,jpg,gif或png图片。< / li < span class =code-keyword>>
    < li > 输入图片的名称。< / li >
    < li > 选择&'上传&'。< / li >
    < li > 您的图片现在将显示在图像编辑器中。单击图像(不是复选框)。< / li >
    < li > 系统会自动调整图像大小以适合图像块的宽度。< / li >
    < li > 要调整图像高度,请转到图像底部,直到看到抓取器。用鼠标向上或向下拉动抓取器,直到图像调整正确。< br / >
    < img < span class =code-attribute> src = http:// localhost:2107 / Images / HelpImages / imgResize.jpg width = 109px < span class =code-attribute> height = 165px > < / li >
    < li > 注意:系统不允许您可以使图像比图像块更宽。< / li >
    < li > 从步骤3的下拉框中选择,选择图像的对齐方式。< br / > < img src = http:// localhost:2107 / Images / HelpImages / ChooseAlign.jpg > < / li >
    < li > 要超链接图像,请参阅&创建图像链接&者;在帮助菜单中。< / li >
    < li > 完成后选择&'Insert&步骤5中的按钮。< img src = http:// localhost:2107 / Images /HelpImages/Insert.jpg\"> < / li >
    < li > 您的图片现在将显示在关于我们的图片块中。< ; / li >
    < / ol >
    < / body >
    < / html >





    =========== =============================================

    解决方案

    要使用PDF,请使用iText或其.NET端口,iTextSharp:

    http://en.wikipedia.org/wiki/IText [ ^ ],

    http://itextpdf.com / [ ^ ],

    http://sourceforge.net/projects/itextsharp/ [ ^ ]。



    包括对Java iText网站的引用,因为大多数文档在那里。如果您了解C#,那么理解基于Java的API文档并不困难。



    -SA

    Hello Everybody,

    I am creating one web application, within that i am getting HTML Code from Database which contains

      and <img> tags with inline styles.when i create the PDF using iTextSharp from that string, the text overlay on images but the same html works fine in browser.

      How to solve this issue?

      Can anybody help me?

      my HTML is
      ========================================================

      <html>
          <body>
              <span style="color:#005AA0;font-family:Arial,Helvetica,sans-serif;font-size: 15px !important;font-weight: bold;margin-bottom: 5px;margin-top: 5px;text-transform: uppercase;">Add Image on About Us</span>
              <br/>
              <br/>
              <br/>
              <span style="font-family:Arial,Helvetica,sans-serif;font-size: 15px;" >On About Us:</span>
              <ol style="font-family:Arial,Helvetica,sans-serif;font-size: 15px;line-height:40px;">
                  <li> Select &apos;Add Image Block&apos;. <img src="http://localhost:2107/Images/HelpImages/AddImageBlock.jpg"></li>
                  <li> Click &apos;Add/Edit Image&apos;. <img src="http://localhost:2107/Images/HelpImages/AddEditImage.jpg"></li>
                  <li> If the image is in your image gallery click on the image (not the check box) and go to step 9.</li>
                  <li> To add an image to the gallery from your computer, click &apos;Browse&apos;. <br/>
                      <img src="http://localhost:2107/Images/HelpImages/imgBrowse.jpg"></li>
                  <li> Double click on the image file that you would like to upload.  Note: You may only upload images that are jpeg, jpg, gif or png.</li>
                  <li> Enter a name for the image.</li>
                  <li> Select &apos;Upload&apos;.</li>
                  <li> Your image will now appear in the Image Editor.  Click on the image (not the check box).</li>
                  <li> The system will automatically resize your image to fit the width of the image block.</li>
                  <li> To adjust the image height, go to the bottom of the image until you see the grabbers.  Pull the grabber with your mouse up or down until your image is adjusted properly.<br/>
                      <img src="http://localhost:2107/Images/HelpImages/imgResize.jpg" width="109px" height="165px"></li>
                  <li> Note: The system will not allow you to make the image wider than the image block.</li>
                  <li> Choose the alignment of your image by selecting from the drop down box in step 3.<br/> <img src="http://localhost:2107/Images/HelpImages/ChooseAlign.jpg"></li>
                  <li> To hyperlink your image, see &apos;Create Link to Image&apos; in the Help Menu.</li>
                  <li> When finished select the &apos;Insert&apos; button in Step 5. <img src="http://localhost:2107/Images/HelpImages/Insert.jpg"></li>
                  <li> Your image will now appear in the image block on About Us.</li>
              </ol>
          </body>
      </html>



      ========================================================

    解决方案

    To work with PDF, use iText, or its .NET port, iTextSharp:
    http://en.wikipedia.org/wiki/IText[^],
    http://itextpdf.com/[^],
    http://sourceforge.net/projects/itextsharp/[^].

    In included the reference to Java iText site as well, because most documentation is there. If you understand C#, it would not be difficult to understand Java-bases API documentation.

    —SA


    这篇关于在asp.net web应用程序中从html字符串创建pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆