Itextsharp Dll For Asp.net Free Download

0 views
Skip to first unread message

Rodney Liuzzo

unread,
Aug 4, 2024, 4:21:32 PM8/4/24
to tardsellparcui
Id like to know if ITextSharp has the capability of converting HTML to PDF. Everything I will convert will just be plain text but unfortunately there is very little to no documentation on ITextSharp so I can't determine if that will be a viable solution for me.

Here's what I was able to get working on version 5.4.2 (from the nuget install) to return a pdf response from an asp.net mvc controller. It could be modfied to use a FileStream instead of MemoryStream for the output if that's what is needed.


The above blog has specific instructions for how to include this package (it's a 32 bit dll and requires .net4). here is my code. The incoming HTML is actually assembled via HTML Agility pack (I'm automating invoice generations):


I prefer using another library called Pechkin because it is able to convert non trivial HTML (that also has CSS classes). This is possible because this library uses the WebKit layout engine that is also used by browsers like Chrome and Safari.


The above code will certainly help in converting HTML to PDF but will fail if the the HTML code has IMG tags with relative paths. iTextSharp library does not automatically convert relative paths to absolute ones.


Converting HTML to PDF is very simple to do now. All you have to do is use NuGet to install itext7 and itext7.pdfhtml. You can do this in Visual Studio by going to "Project" > "Manage NuGet Packages..."


Most existing packages will not support asp.net Core 5 yet; because of the significant differences, they need to be manually updated. If you're wanting to use iTextSharp, you'll either need to stick to asp.net 5 (not Core) or wait for the creators of iTextSharp to release a Core version.


I am making a webpage with c# code running in the back. I am using the itextsharp library to search through PDF files. I am able to compile and deploy the code because I did add the .dll reference and added the required using statements to import the .dll. But in run-time i get this error message:


I tried to build a very small ASP.NET application (2 tables from SQL Server 2012) using IIS Express and Browse after generation, but ran into an error "C:\Users\\Documents\IISExpress\config\applicationhost.config not found." I've tried reinstalling ASP.NET Maker and IIS Express with admin privileges. I installed the community edition of VS2013. No luck.


I then downloaded the demo (after running it on your site). It complained first about the iTextSharp DLL missing. I picked it up from the SourceForge site (sourceforge.net/projects/itextsharp/files/) which got rid of hundreds of errors. However it still complains about version errors (below) and missing the MessagingToolKit.


iTextSharp is for pdfexport extension and MessagingToolKit is for Barcode and QRCode Custom View Tag. Read the notes when you setup the Extension and/or Custom View Tag, see Tools -> Extensions and Field Setup -> Custom View Tag in the help file. As explained in the notes, due to license issues the DLLs cannot be included in the extension or Custom View Tags, you do need to download them from the developer's website yourself. Also read "Third Party Tools" -> "iTextSharp" and "Barcode and QRCode" in the help file or here:


"C:\Users\\Documents\IISExpress\config\applicationhost.config" is a file created by IIS Express when it is first started. If not found, IIS Express may not be installed properly. Try reinstall: ... s-overview


I guess I was suggesting that what is delivered "out-of-the-box" for a demo of ASP.NET Maker should work without a lot of changing of parameters. After I downloaded your demo I did nothing to ask for PDF creation or QR/barcode libraries to be required. This must have been in the package that was downloaded.


I'll fiddle some more and probably de-install IIS Express and ASP.NET Maker and try another installation. I like what you have done over the years and am just now getting back into the .NET world so I'll plug along.


In this article I am going to demonstrate how ASP.Net developers can programmatically create PDF documents using iTextSharp. iTextSharp is a software component, that allows developers to programmatically create or manipulate PDF documents. Also this article discusses the process of creating in-memory file, read/write data from/to the in-memory file utilizing the new feature MemoryMappedFile.


I have a database of users, where I need to send a notice to all my users as a PDF document. The sending mail part of it is not covered in this article. The PDF document will contain the company letter head, to make it more official.


I have extracted the Zip file and added the itextsharp.dll as a reference to my project. Also I have added a web form named default.aspx to my project. After doing all this, the solution explorer have the following view.


Now I am going to create a pdf document when the user clicking on the Generate PDF button. As I mentioned before, I am going to work with the file in memory, I am not going to create a file in the disk. I added an event handler for button by specifying onrowcommand event handler. My gridview source looks like


string msg = @"There are some changes in the company policy, due to this matter you need to submit your latest address to us. Please update your contact details personnal details by visiting the member area of the website. ................................... ";


The below portion of the code using MemoryMappedFile object to create a test pdf document in memory and perform read/write operation on file. The CreateViewStream() object will give you a stream that can be used to read or write data to/from file. The code is very straight forward and I included comment so that you can understand the code.


Converting ASP.NET Repeater HTML to PDF using iTextSharp This article describes you how to convert asp.net repeater controls HTML or entire webpage to pdf using iTextSharp. It will also give introduction to iTextSharp library.


iTextSharp is a free library to create PDF documents using C#.net. It gives you more flexibility to documents in terms of look and feel and overall customization of PDF documents. iTextSharp's objects like Table, Cell, paragraph, phrase, etc. makes things easy to create professional pdf documents. It allows you to control every pixel and line of PDF file. Using iTextSharp you can only create PDF files. Download the latest iTextSharp dll by clicking here.


Add a button control to the aspx page created in the previous step. The functionality for this button would be to export details of customers displayed on the current page. The page has the feature of paging so only customers shown for the current page will be export to PDF using iTextSharp dll.


Due to paging, at any given time you will have only customers that are displayed for current page index. So you will have to create a new Repeater control and bind it to all customers using C# code.


As we are using ASP.NET Response object to convert html to PDF so it depends on various factor which Response object will use while converting html to PDF. If you want to have absolute control o PDF formatting and data you will have to use iTextSharps object. Go throughfor more info ... -sharpcorner.com/UploadFile/f2e803/basic-pdf-creation-using-itextsharp-part-i/


@CooperCloud, you have to set it your font to page and its control before you call RenderControl() method of GridView. If you want to have more control on formatting, display, font, color use iTextSharp libary and its table objects


Indeed iTextSharp works fine with simple html. I had to convert a more complicated page lately containing some SVG charts and for that needed to use a more complicated html to pdf converter. ExpertPdf ( -to-pdf.net/) proved to work just fine and I recommend it as an alternative.


Thanku sir ..sir i have 4 page (login.aspx ,default.aspx,def1aspx,def2.aspx).i m working def2.aspx.if i click browser back button throw out login.aspx or show error page (custom control ).how i can used?


I found the problem. ITextSharp did not like the horizontal-line tags that i have in my asp.net page. I removed those horizontal-line tags and the tool ran fine but the output captured into the PDF file with missing info -- the image was modified by the user by adding some check mark and those check marks were not shown in the PDF file


Hi. Mr.Suresh,

Error Location: this.Page.RenderControl(hw);

Error Message="The extension 'upaGrafico' extension is not registered. Extender controls must be registered using RegisterExtenderControl() before calling RegisterScriptDescriptors(). Parameter name: ExtenderControl".

Can you help me? thanks.




i want to use Indian rupee symbol before the value instead of Rs. in pdf.

Am using itextsharp to generate the pdf. even i get the background image for that pdf but am suffering due to this rupee symbol prob..

Can i get any help?

Thanks in advance sir!



Hi suresh,



I used for concept to export data from gridview to PDF. but , could you plz tell me how to handle the case by using itextsharp, if not data content is there to display , but need to show that information to user inside PDF . Hope you will help on this soon.



Regards,

Minnu


hii suresh i am using your code but the problem is if i am having java script on my page then that also get printed in pdf can you help or you can tell me how i can make pdf exact like print preview that we see in browser of a page


Script control 'UpdateProgress1' is not a registered script control. Script controls must be registered using RegisterScriptControl() before calling RegisterScriptDescriptors().

Parameter name: scriptControl



ERROR CAME LIKE THIS


i m using this code bt i m getting error..



Input string was not in a correct format.



Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.



Exception Details: System.FormatException: Input string was not in a correct format.



3a8082e126
Reply all
Reply to author
Forward
0 new messages