0

I am working on a project in VB.Net that requires me to save Forms and Panel setups as PDF files.

Doing some research I found that there is no internal way in VB.Net to do this, and after setting up and testing CutePDF Writer with a PrinterDialog setup as an alternative, found that it is not good enough to meet the needs required for the project.

As such I am looking for external tools for me to use to meet these goals. I need to be able to do the following:

  1. Take the elements on a Windows Form or Panel and save them to a PDF file
  2. The file needs to be able to be saved programmatically, no need for dialog boxes to confirm file names or locations
  3. I need to be able to essentially set up my project so that I can be looking at my Form or Panel, click save, and just wait for a small message box that I can program in as save confirmation.

Thanks for anyone who has suggestions. I am currently looking myself, but thought I'd check and see what other people have been using and having success with. I am also in a position to spend money to purchase licenses, so I am not just looking for free tool suggestions :)

migrated from stackoverflow.com Aug 3 '18 at 17:56

This question came from our site for professional and enthusiast programmers.

1

SharpPDF is an open source dot Net library that you can use to generate PDF's programmatically.

  • I am using SharpPDF on a PowerShell project, dead simple to use and has plenty of documentation. – Sonamor Sep 3 '18 at 7:57
0

PDFTechLib from pdf-technologies.com is a .NET library for C#, ASP.NET and VB.NET.

PDFTechLib is a full function PDF .NET Library developed with 100% Managed C# .NET code. Whether you work in C#, VB.NET or ASP.NET, you can use the PDFTechLib Component Library to quickly create great looking PDF documents. You can develop as many applications as you wish and distribute your work freely with the flexible Royalty Free licensing model.

0

You should be able to obtain the form contents as image without using any external software or library with this code:

'Capture entire form as a bitmap
Dim bmp As New Bitmap(Me.Width, Me.Height)
Me.DrawToBitmap(bmp, New Rectangle(0, 0, Me.Width, Me.Height))
'Find client rectangle without borders or title
Dim rect = RectangleToScreen(ClientRectangle)
Dim dx = rect.Left - Me.Left, dy = rect.Top - Me.Top
rect = ClientRectangle
rect.Offset(dx, dy)
'Get the bitmap we need without borders or title
Dim bmp2 = bmp.Clone(rect, Imaging.PixelFormat.Format24bppRgb)

You can save the bitmap as an image (like JPEG or PNG) using bmp.Save(), but if you want to save it as PDF, you will need a library that supports saving PDF. The company I work for sells the LEADTOOLS PDF Pro SDK, which can convert the image to PDF using the following code:

'Convert bitmap and save it as PDF using LEADTOOLS
Dim img = RasterImageConverter.ConvertFromImage(bmp2, ConvertFromImageOptions.None)
Dim codecs As New RasterCodecs()
codecs.Save(img, OutputPDF, RasterImageFormat.RasPdfJpeg411, 24)

If you would like to try it, there's a free evaluation edition here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.