VS 2012 Best way to save form to PDF-VBForums
Results 1 to 5 of 5

Thread: Best way to save form to PDF

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2017
    Posts
    22

    Best way to save form to PDF

    Hey Dears,

    what is the best way to save form to pdf without using external links like isharp or others?

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    97,092

    Re: Best way to save form to PDF

    There isn't one. There's nothing specific to the PDF file format built into the .NET Framework. You'd have to understand the PDF specification and actually write the appropriate data to a file through a FileStream. That would be tedious for a specific case and really time-consuming for the general case. That's why components like iTextSharp exist. They have done all that tedious and time-consuming work already and wrapped it up into one or more easy-to-use types.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    4,045

    Re: Best way to save form to PDF

    On my system I have the option of using "Microsoft Print to PDF" in my printer selection. I don't know if that is provided by the Operating System, or came as part of installing some other Microsoft application. I don't think it is the most efficient, as it creates a much larger PDF file than if I use something in an application that has a "save to PDF" built in.

  4. #4
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    97,092

    Re: Best way to save form to PDF

    Quote Originally Posted by passel View Post
    On my system I have the option of using "Microsoft Print to PDF" in my printer selection. I don't know if that is provided by the Operating System, or came as part of installing some other Microsoft application. I don't think it is the most efficient, as it creates a much larger PDF file than if I use something in an application that has a "save to PDF" built in.
    I didn't even think of that but you're quite right. If there's a PDF printer driver installed, which you can do yourself if there isn't one by default, then you can print straight to PDF. The selection of the printer driver would be done by the user at run time and your code would print using a PrintDocument, just as you would if you were printing on paper. I'm guessing that the file size is likely due to a page being one big image rather than parts containing text, etc.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5
    Fanatic Member jdc20181's Avatar
    Join Date
    Oct 2015
    Location
    Indiana
    Posts
    1,021

    Re: Best way to save form to PDF

    Integrations from like Microsoft Word are about the only way to save files to PDF in vb.net, sadly. There is plently of costly solutions, but you need a deep pitted wallet for that. They cost anywhere from 1500-4500$ a license
    Disclaimer: When code is given for example - it is merely a example. See my First CodeBank Submission Upgrading to the newest IE when using the Webbrowser control See my Second CodeBank SubmissionVB.NET - Recording History or changes using WebbrowserControl RichTextBox Textbox
    See my Third codebank submission VB.NET - Detecting Secure/Insecure Websites (ssl) w/ Webbrowser control See CodeBank Submission 4 A Simple Large View Calendar Control See my browser project BeffsBrowser Try my SpeedTest Project

    Unless said otherwise (e.g. From one of my projects thus, those are mostly licensed under MIT) - All Code snippets advice or otherwise that I post on this site, are expressly licensed under Creative Commons Attribution 4.0 International Please respect my copyrights.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.