![]() |
Application to export to an PDF
:D excuse me for the thread typo if you have noticed it
Good morning to you all, this is my first post but I have been around here a little while already. So I tried to search the forums and did not find anything about an application with code that writes text to a pdf file. I succeeded with .txt and .doc, however I really do not know how to do so with PDF. It is for a school project, so If anyone could help me, I'd really be gratefull. So here is what I got so far. (changing .doc to .pdf does create the pdf file with the title given but afterwards I can not open the pdf file! :
|
Re: Application to export to an PDF
All you're doing is writing text to a file. Therefore, the resultant file is plain text, no matter what you call it. Changing the extension from .TXT to .PDF doesn't make it into a Portable Document Format file, any more than changing the extension from .TXT to .EXE would make it into a program.
A PDF file is basically a collection of drawing commands (these can draw either graphics or text), and when it's opened, Acrobat Reader or whatever program just reads the file and recreates the 'paper appearance' of it. Without the special formatting codes, software won't recognize it as a valid .PDF file. If you're set on creating .PDFs, then you have two choices. First, you can write the code yourself, and to do this, you'll need to be familiar with the .PDF specification. You can find it here. If you take this approach I hope you like reading, as the thing is about 1400 pages of technical material. The second, much easier, approach is to use a library designed to output .PDF files, such as iTextSharp. If all you need to do is output the contents of textboxes while preserving format information, you can use the RichTextBox control. This control has methods for controlling the appearance of text within the control, as well as a SaveFile() method that will allow you to write the text to a file, as a .RTF file. These files can be opened in many word processors, and the format allows for such metadata as fonts and colors. |
Re: Application to export to an PDF
Much apreciated for the post.
My purpose is to make an invoice. It's an ASP webpage with a computer configurator. When a customer presses on OK after selecting his/her products from the comboboxes, the programm has to make a PDF file with default store lay-out and the textboxes (item, price, quantity...etc) in the right area. http://img376.imageshack.us/img376/6...ple1qu6.th.jpg The outcome would be something like Image was too large, please click http://www.office-kit.com/excel_invo...ce_printed.gif Will iTextSharp or a RichTextBox do it? Im sorry i did not mention it was for ASP.NET |
Re: Application to export to an PDF
Quote:
Since it's a web-based application, have you considered simply giving the user HTML output for their report? Since they will be interacting with the app in a browser, they could print or save the content from their browser. |
Re: Application to export to an PDF
Quote:
It is possible, but our teacher does not agree on that, because he find it too easy. It will also leave out competences such as SQL, and ASP (after the user selects OK the lines will be written in a underlying database) Oh, I don't know hot to use iTextSharp. I have checked the FAQ and some other help recourses. What I tried is, run 'itextsharp.sln', then Batch build the release. The outcome were 2 files in the Release folder itextsharp.dll and iTextSharp.xml, now I don't know what to do with that. Could anyone help me use itextsharp? |
Re: Application to export to an PDF
Quote:
Quote:
As an example, imagine the database stores what products are kept in stock (along with a price, description, supplier, etc for each). It also stores records of each transaction (what was sold, when it was sold, etc). By querying the database, the software can assemble a picture of what is going on. It might present a graph that shows sales of a certain type of product, say bicycles, reach their peak in the summer, and barely sell at all during the winter. It could show which stores are the most productive, or which employees make the most sales, dollar-wise. It really depends on the type of report the user wants to see (your software should probably provide several). Quote:
I personally think the point of your project is to show you can develop a 'data-driven' ASP.NET application, and not that you know how to create .PDF files on the fly. Look at the web site for any company that does business online. You will probably be able to search for products, browse by category, and the like. When viewing a particular product, you'll probably be presented with a description of it (details such as price, brand, what is included, what stores stock it, and so on), as well as a picture of the product. All of this can be stored in the database (though the pictures are often stored as simple files, with a name that matches the product ID), and it's fetched when the user requests it. The HTML the user sees is all generated on-the-fly by the ASP.NET engine. |
Re: Application to export to an PDF
to use itextsharp, take the .dll file from the release folder and add it to your project through the add existing item menu. then from the add references menu, choose the browse tab and browse to the .dll file in your project. that will give you access to al the classes in itextsharp.
Edit: forgot to mention that this method will allow you to Ise itextsharp on the server without actually installing anything there. |
Re: Application to export to an PDF
thank you a lot for the usefull reply mbd and lectricpharaoh!!!
I will try this out and let you guys know how it went |
Re: Application to export to an PDF
Ok I successfully implemented iTextSharp, and Im making improvement, im very exiting about this project :D.
So if anyone else was interested, I found these toturials to get you going http://itextsharp.sourceforge.net/tutorial/ch01.html http://itextsharp.sourceforge.net/examples/Chap0101.cs thanks again everyone |
Re: Application to export to an PDF
Is it possible to create "Contents" and "Bibliography" by using itextsharp? I know latex can automatically create "Contents" and "Bibliography" etc. But, I never see anyone talking about this for itextsharp. I need create a complex pdf financial report with content pages by using C# program.
|
| All times are GMT -5. The time now is 12:55 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC