Also note that you should create a folder called Reportsat the root of your Web site into which the generated PDF documents can be written. When setting up this example, that you should add a logo image to an Imagesfolder located at the root of your Web site. The PDF-generation logic for this example is contained in the example page TestGenPdf.aspx. The main page is called TestGenPdf.aspx and this page will call an example page called TestReport.aspx. When setting this example up, please consider the same setup explanation: The example below is the VB.NET version of the C# example I have provided above. Example HTML Report with an Image in an iTextSharp PDF in VB.NET Protected Sub Page_Load(sender As Object, e As System.EventArgs) (this.GetType(), "myscript", "window.open('reports/" strFileShortName "','_blank','location=0,menubar=0,status=0,titlebar=0,toolbar=0') ", true) XMLWorkerHelper.GetInstance().ParseXHtml(pdfWrite, docWorkingDocument, srdDocToString) addLogo.SetAbsolutePosition(0, - 100) docWorkingDocument.Add(addLogo) SrdDocToString = new StringReader(strHtml) ĪddLogo.ScaleToFit(128, 37) addLogo.Alignment = _RIGHT PdfWrite = PdfWriter.GetInstance(docWorkingDocument, new FileStream(strFileName, FileMode.Create)) docWorkingDocument = new (4.Rotate(), 1, 1, 0, 0) String strFileName = ("reports\\" strFileShortName) String strFileShortName = "test" ".pdf" addLogo = default() addLogo = (Server.MapPath("Images") "/logo.gif") Server.Execute("TestReport.aspx", strWriter) StringWriter strWriter = new StringWriter() MemoryStream memStream = new MemoryStream() Protected void Button1_Click(object sender, System.EventArgs e) If you are including an image in an HTML page that you are exporting to PDF with iTextSharp, then you’ll quickly see that iTextSharp will not include the image from the traditional HTML Adding your Image Programmatically while Generating your PDF NET libraries then have a look at some of the other articles covering iTextSharp I have written on the topic. If you are interested in working with the iTextSharp.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |