Click here to Skip to main content
15,891,513 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys, this is my first post, please pardon any ignorance i may present.
Anyway i've started coding recently and i took on a learning project to program a windows form app which upon exporting, will be converted to a pdf file.

As of now, I've already successfully achieved the above project using itextsharp and its PdfPTable and PdfPCell components.

However, i wish to export the form exactly as i created in visual studio to PDF, which means i do not want to export the contents in a pdftable format.

I am not asking for the exact code to achieve what I have asked but i simply ask for a direction as i am still confused and lost even after reading through many relevant posts.

thanks,
Xiaonelly

What I have tried:

I am not asking for the exact code to achieve what I have asked but i simply ask for a direction as i am still confused and lost even after reading through many relevant posts.
Posted
Updated 13-Nov-18 22:24pm

1 solution

Hi,
So first let me explain my understanding of what you want to achieve. You would like to export your winform to PDF as it is, Right? If so, then you will have several options but most of them will require a component that converts stream (information in memory) into a PDF file. A very easy way would be printing the winform and selecting a PDF printer (which you can easily install one from the internet) as the printer. In this way, you are in fact changing the scope of the problem to a problem which is more easy to solve. How to print a winform? For this new problem which will at the end provide a nice solution to solve the original problem as well (how to export winform into PDF) you have the below solutions that have been discussed with others before, and they accepted the solutions:

From CodeProject:
Print-Windows-form-in-Csharp-Net

From Stack Overflow:
c# - convert windows form to pdf file - Stack Overflow

If this did not solve your problem then please leave a comment and I will assist you by improving my solution until your problem gets solved.

Cheers,
AH
 
Share this answer
 
v3
Comments
Xiaonelly 14-Nov-18 5:05am    
Hi thanks so much for the direction, I'll let you know if it works out once I get the time to try the method.
Aydin Homay 14-Nov-18 5:09am    
You are very welcome
Xiaonelly 15-Nov-18 1:30am    
Hi Aydin, I've successfully achieve the print method mentioned by you earlier, https://imgur.com/VV8xxZh
however, is it possible to remove the borders and the button in the final document? I'd like to only print the contents of the form.
once again, thanks for the help.
Aydin Homay 15-Nov-18 3:58am    
Hi, good to hear that. Just please do not forget to press that little green button and accept the solution as it will help others to consider as a valid solution and save their time. About the second topic, I would suggest you please create another question and ask it in a separate question plus copy paste your code this will help us to assist you better. I am looking forward to see your next question.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900