PDFsharp & MigraDoc Foundation https://forum.pdfsharp.net/ |
|
PDF To Bmp https://forum.pdfsharp.net/viewtopic.php?f=2&t=1738 |
Page 1 of 1 |
Author: | kompellamurthy [ Thu Aug 11, 2011 12:44 pm ] |
Post subject: | PDF To Bmp |
Hi, I want the code for convert a pdf page to a bit map. Please help me in this regard. Thanks. |
Author: | JumpyPDFsharp [ Sun Aug 28, 2011 2:33 pm ] |
Post subject: | Re: PDF To Bmp |
kompellamurthy wrote: I want the code for convert a pdf page to a bit map. PDFSharp can not render pdf files. You can use the PDFLibNet.dll which can be downloaded from "http://code.google.com/p/pdfviewer-win32/downloads/list". Here's a piece of code that will save the rasterized images to a subfolder: Code: Private Sub RasterizePDFToPNGs(ByVal SourcePDFPath As String)
Dim DestFile As String = IO.Path.GetFileNameWithoutExtension(SourcePDFPath) Dim DestFolder As String = IO.Path.Combine(IO.Path.GetDirectoryName(SourcePDFPath), DestFile) If System.IO.Directory.Exists(DestFolder) = False Then System.IO.Directory.CreateDirectory(DestFolder) End If Dim SourcePDF As New PDFLibNet.PDFWrapper() SourcePDF.LoadPDF(SourcePDFPath) SourcePDF.RenderDPI = 300 For i As Integer = 1 To SourcePDF.PageCount SourcePDF.CurrentPage = i Dim pic As New PictureBox() SourcePDF.RenderPage(pic.Handle) Dim SinglePageBMP As New Bitmap(SourcePDF.PageWidth, SourcePDF.PageHeight) Dim g As Graphics = Graphics.FromImage(SinglePageBMP) Dim bounds As New Rectangle(0, 0, SourcePDF.PageWidth, SourcePDF.PageHeight) SourcePDF.ClientBounds = bounds SourcePDF.CurrentX = 0 SourcePDF.CurrentY = 0 SourcePDF.DrawPageHDC(g.GetHdc) g.ReleaseHdc() Dim DestinationPath As String = IO.Path.Combine(DestFolder, DestFile & " " & Format(i, "0000") & ".png") SinglePageBMP.Save(DestinationPath, Drawing.Imaging.ImageFormat.Png) System.Threading.Thread.Sleep(100) Next End Sub |
Author: | kompellamurthy [ Mon Aug 29, 2011 2:56 am ] |
Post subject: | Re: PDF To Bmp |
Thanks man. Till now, I am doing the same conversion with other lib which is not free. This will really helped me. !!! Thanks once again. ~<b>Kompella Murthy<b>. |
Author: | kompellamurthy [ Mon Aug 29, 2011 6:02 am ] |
Post subject: | Re: PDF To Bmp |
I am getting the an error icon displayed when i add the pdflibnet.dll as reference. Can you please help in this regard. Thanks KompellaMurthy. |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |