Click here to Skip to main content
Click here to Skip to main content

PDF Viewer Control Without Acrobat Reader Installed

By , 6 Oct 2009
 
Prize winner in Competition "Best VB.NET article of June 2009"

Introduction

This article discusses how to create a .NET PDF Viewer control that is not dependent on Acrobat software being installed.

Fundamental Concepts

The basic steps that need to take place in order to view a PDF document:

  1. Get a page count of the PDF document that needs to be viewed to define your page number boundaries (iTextSharp or PDFLibNET)
  2. Convert the PDF document (specific page on demand) to a raster image format (GhostScript API or PDFLibNET)
  3. --(Deprecated) Extract only the current frame to be viewed from the raster image (FreeImage.Net)
  4. Convert the current frame to be viewed into a System.Image
  5. Display the current frame in a PictureBox control

Several utility classes were created or added from others which expose functionality needed from the various helper libraries.

  • GhostScriptLib.vb (contains methods to convert PDF to TIFF for Viewing and Printing)
  • AFPDFLibUtil.vb (contains methods to convert PDF to System.Image for Viewing and Printing as well as methods to create a Bookmark TreeView)
  • iTextSharpUtil.vb (contains methods for getting PDF page count, converting images to searchable PDF and for extracting PDF bookmarks into TreeNodes)
  • PrinterUtil.vb (contains methods for sending images to printers)
  • ImageUtil.vb (contains methods for image manipulation such as resize, rotation, conversion, etc.)
  • TesseractOCR.vb (contains methods for Optical Character Recognition from images)
  • PDFViewer.vb (contains the Viewer user control)

I was tempted to move every function over to PDFLibNet (XPDF) which is faster, but after a lot of testing, I decided to use Ghostscript and PDFLibNET. Ghostscript is used for printing, "PDF to image" conversion, and as a secondary renderer in case of XPDF incompatibility. PDFLibNET is used for quick PDF to screen rendering, searching, and bookmarks.

Using the Code

This project consists of 7 DLLs that must all be in the same directory:

  • FreeImage.dll
  • FreeImageNET.dll
  • gsdll32.dll
  • itextsharp.dll
  • PDFLibNET.dll
  • tessnet2_32.dll
  • PDFView.dll

Due to file size restrictions, I could not include the Ghostscript 8.64 DLL (gsdll32.dll) in the source code. Please download the Win32 Ghostscript 8.64 package from sourceforge.net and place the file "gsdll32.dll" into the \PDFView\lib directory where the other DLLs already exist.

To place a PDF control on form:

Dim PDFFileName As String = "MyPDF.pdf"

Dim PDFViewer As New PDFView.PDFViewer
' Specify whether you want to see bookmarks in the control
' Bookmarks are enabled by default
' PDFViewer.AllowBookmarks = False 'Disable bookmarks

' Get the page count of the PDF document if you want to
' conditionally set properties of the PDFViewer control
' Dim PageCount As Integer = PDFViewer.PageCount(PDFFileName)

' To use Ghostscript, UseXPDF = False
' Ghostscript is slower, but is more compatible and has higher quality rendering
' To use XPDF, UseXPDF = True
' XPDF is quite a bit faster than Ghostscript since there is no file i/o involved
' PdfViewer1.UseXPDF = False 'Disables use of XPDF and associated features

' PDFViewer displays the file as soon as the FileName property is set
' File can be a PDF or a TIFF
PDFViewer.FileName = OpenFileDialog1.FileName

PDFViewer.Dock = DockStyle.Fill 'Autosize the viewer control

Me.Controls.Add(PDFViewer)

The essential part of this solution is extracting the current frame to be viewed from a multi-frame (or single frame) image. At first I used System.Drawing to implement it. I found this to be slower than other C++ solutions that use DIBs (Device Independent Bitmaps) to perform graphic conversions.

Public Shared Function GetFrameFromTiff_
	(ByVal Filename As String, ByVal FrameNumber As Integer) As Image
    Dim fs As FileStream = File.Open(Filename, FileMode.Open, FileAccess.Read)
    Dim bm As System.Drawing.Bitmap = _
	CType(System.Drawing.Bitmap.FromStream(fs), System.Drawing.Bitmap)
    bm.SelectActiveFrame(FrameDimension.Page, FrameNumber)
    Dim temp As New System.Drawing.Bitmap(bm.Width, bm.Height)
    Dim g As Graphics = Graphics.FromImage(temp)
    g.InterpolationMode = InterpolationMode.NearestNeighbor
    g.DrawImage(bm, 0, 0, bm.Width, bm.Height)
    g.Dispose()
    GetFrameFromTiff = temp
    fs.Close()
End Function

I then tried implementing FreeImage with a .NET wrapper which gave it a little speed boost. FreeImage also has a ton of image conversion functions which may come in handy if you wanted to extend this into an editor.

Public Shared Function GetFrameFromTiff2_
	(ByVal Filename As String, ByVal FrameNumber As Integer) As Image
    Dim dib As FIMULTIBITMAP = New FIMULTIBITMAP()
    dib = FreeImage.OpenMultiBitmapEx(Filename)
    Dim page As FIBITMAP = New FIBITMAP()
    page = FreeImage.LockPage(dib, FrameNumber)
    GetFrameFromTiff2 = FreeImage.GetBitmap(page)
    page.SetNull()
    FreeImage.CloseMultiBitmapEx(dib)
End Function

I ended up implementing PDFLibNET which gave it a substantial speed boost since the amount of File I/O operations were reduced. Another streamlined routine for extracting one page from a PDF was added to the Ghostscript utility class as well.

AFPDFLibUtil.vb

Public Shared Sub DrawImageFromPDF(ByRef pdfDoc As AFPDFLibNET.AFPDFDoc,
    ByVal PageNumber As Integer, ByRef oPictureBox As PictureBox)
        If pdfDoc IsNot Nothing Then
            pdfDoc.CurrentPage = PageNumber
            pdfDoc.CurrentX = 0
            pdfDoc.CurrentY = 0
            pdfDoc.RenderDPI = RENDER_DPI
            pdfDoc.RenderPage(oPictureBox.Handle.ToInt32())
            oPictureBox.Image = Render(pdfDoc)
        End If
    End Sub

    Public Shared Function Render(ByRef pdfDoc As AFPDFLibNET.AFPDFDoc) As Bitmap
        If pdfDoc IsNot Nothing Then
            Dim backbuffer As New Bitmap(pdfDoc.PageWidth, pdfDoc.PageHeight)
            Dim g As Graphics = Graphics.FromImage(backbuffer)
            Using g
                Dim lhdc As Integer = g.GetHdc().ToInt32()
                pdfDoc.RenderHDC(lhdc)
                g.ReleaseHdc()
            End Using
            g.Dispose()
            Return backbuffer
        End If
        Return Nothing
    End Function

GhostScriptLib.vb

Public Shared Function GetPageFromPDF(ByVal filename As String,
    ByVal PageNumber As Integer, Optional ByVal ToPrinter As Boolean = False) As Image
            Dim converter As New ConvertPDF.PDFConvert
            Dim Converted As Boolean = False
            converter.RenderingThreads = Environment.ProcessorCount
            converter.OutputToMultipleFile = False
            If PageNumber > 0 Then
                converter.FirstPageToConvert = PageNumber
                converter.LastPageToConvert = PageNumber
            Else
                GetPageFromPDF = Nothing
                Exit Function
            End If
            converter.FitPage = False
            converter.JPEGQuality = 70
            If ToPrinter = True Then 'Settings for decent print quality
                converter.TextAlphaBit = -1
                converter.GraphicsAlphaBit = -1
                converter.ResolutionX = PRINT_DPI
                converter.ResolutionY = PRINT_DPI
            Else 'Settings for screen resolution
                converter.TextAlphaBit = 4
                converter.GraphicsAlphaBit = 4
                converter.ResolutionX = VIEW_DPI
                converter.ResolutionY = VIEW_DPI
            End If
            converter.OutputFormat = COLOR_PNG_RGB
            Dim input As System.IO.FileInfo = New FileInfo(filename)
            Dim output As String = System.IO.Path.GetTempPath & Now.Ticks & ".png"

            Converted = converter.Convert(input.FullName, output)
            If Converted Then
                GetPageFromPDF = New Bitmap(output)
                ImageUtil.DeleteFile(output)
            Else
                GetPageFromPDF = Nothing
            End If
        End Function

In the PDFViewer code, a page number is specified and:

  • The page is loaded from the PDF file and converted to a System.Image object.
  • The PictureBox is updated with the image.
Private Function ShowImageFromFile(ByVal sFileName As String,
    ByVal iFrameNumber As Integer, ByRef oPictureBox As PictureBox,
    Optional ByVal XPDFDPI As Integer = 0) As Image
        oPictureBox.Invalidate()
        If mUseXPDF Then 'Use AFPDFLib (XPDF)
            If ImageUtil.IsPDF(sFileName) Then
                If XPDFDPI > 0 Then
                    AFPDFLibUtil.DrawImageFromPDF(mPDFDoc, iFrameNumber + 1,
                    oPictureBox, XPDFDPI)
                Else
                    AFPDFLibUtil.DrawImageFromPDF(mPDFDoc, iFrameNumber + 1, oPictureBox)
                End If
            End If
        Else 'Use Ghostscript if PDF or use System.Drawing if TIFF
            If ImageUtil.IsPDF(sFileName) Then 'convert one frame to a tiff for viewing
                oPictureBox.Image = ConvertPDF.PDFConvert.GetPageFromPDF(sFileName,
                iFrameNumber + 1)
            ElseIf ImageUtil.IsTiff(sFileName) Then
                oPictureBox.Image = ImageUtil.GetFrameFromTiff(sFileName, iFrameNumber)
            End If
        End If
        oPictureBox.Update()
        Return oPictureBox.Image
    End Function

Points of Interest

This project was made possible due to various open source libraries that others were kind enough to distribute freely. I would like to thank all of the Ghostscript, FreeImage.NET, iTextSharp, TessNet, and AFPDFLib (PDFLibNet) developers for their efforts.

History

  • 19th June, 2009: 1.0 Initial release
  • 22nd June, 2009: Updated source code to correctly scale printed pages to the Printable Page Area of the printer that is selected
  • 7th July, 2009: Updated source code to use AFPDFLib(XPDF) or Ghostscript for PDF rendering
  • 15th July, 2009: Updated source code to use PDFLibNet(XPDF ver 3.02pl3) and added search/export options
  • 22nd July, 2009: Added "Image to PDF" import, password prompt for encrypted PDF files, fallback rendering to Ghostscript if XPDF fails, latest version of PDFLibNet with various bug fixes applied, and LZW compression for "PDF to TIFF" export
  • 20th August, 2009: Major changes:
    • Added the ability to convert images into a searchable PDF (OCR is English only for now)
    • Added the ability to export a PDF to an HTML Image Viewer
    • Pages are only rendered at the DPI needed to fill the Viewer window (good speed increase)
    • Rotated page settings are kept while viewing the document
    • Added the ability to convert images into an encrypted PDF
    • Changed bookmark tree generation to use recursion
    • Multiple bug fixes (see SVN log on the repository)
  • 5th October, 2009
    • Fixed problem with incorrect configuration error with PDFLibNet.dll
    • Removed dependencies on FreeImage

License

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

About the Author

Ron Schuler
Software Developer
United States United States
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionAuto Detect PDF Page Size and Full page Display.memberMember 237566727 Feb '13 - 16:29 
Hi,
 
Is there any way to Auto Detect the page size like A4 or A3 or A2.
 
Currently Display Size of Pdf is Fixed to One size. Irrespective of Page size is there any way to Display full page image.
 
If Can What are the Changes i need to do in my coding. Help me to resove this issue.
AnswerRe: Auto Detect PDF Page Size and Full page Display.membery_sir28 Apr '13 - 2:03 
You could try Moda Image to PDF ActiveX control.
QuestionCan you please help me to create pdf editormemberSMayur21 Jan '13 - 19:24 
Hello,
You code help me a lot to create pdf viewer in asp.net but I want to go further I want to create pdf editor. So can you please provide me a way how to create pdf editor or some code samples?
 
I will be really graceful if you help me, thanks in advance.
Question,net 4.0 BuildmemberKalpana Volety11 Jan '13 - 8:03 
Can you please post a .net 4.0 build?
Many people these days are using latest .net version and this build is not compatible.
 
Thanks a lot in advance,
Kalpana Volety
PDF Tools Online
AnswerRe: ,net 4.0 BuildmemberJueSe18 Jan '13 - 5:57 
VS 2010 on 32-Bit Windows converts the project correct.
You only need to set the second project to start project and it runs fine.
You can adjust the code to your preferences.
Great job!
Questionwill this work with Asp.net websitememberFarhan Ali10 Jan '13 - 4:42 
HI,
 
looks great component, can i add PDFview reference into my existing asp.net website and using that reference i can use all of its features by only just providing the PDF file name to view?
 
please suggest.
Thanks.
QuestionIt's not working!memberعماد أوز23 Dec '12 - 20:35 
Hi there,
 
I tried to run the SamplePDFViewer after I opened the solution and I got the following exception:
 
"An error occurred creating the form. See Exception.InnerException for details. The error is: Could not load file or assembly 'PDFLibNet, Version=1.0.6.6, Culture=neutral, PublicKeyToken=26d87f7d66fb2aee' or one of its dependencies. An attempt was made to load a program with an incorrect format."
 
Would you please clarify this issue?
 
Cheers
AnswerRe: It's not working!memberJueSe18 Jan '13 - 3:20 
If you run it on 32-Bit Windows, it should run.
If you run it on 64-Bit Windows, you have to replace
Integer
to
Int32
.
QuestionDoes this work with .NET 4 ?memberMember 945062424 Sep '12 - 6:41 
Has anyone been able to use this with .NET 4? I am trying to use it with a C# project and keep getting errors "Mixed mode assembly is built against version 'v2.0.50727'". I tried adjusting the app.config file to below, but now I get a different error.
 
configuration>
startup useLegacyV2RuntimeActivationPolicy="true">

supportedRuntime version="v2.0.50727"/>
/configuration>
 
Can anyone help? Thanks.
QuestionContinuous Page ScrollingmemberWaleed Ahmed Malik16 Aug '12 - 2:52 
Is there any way I could scroll through a document continuously, one page after another?
I am searching through the code, but can't seem to find it.
GeneralMy vote of 5memberPolinia1 Aug '12 - 3:04 
To great...
Question.NET FWK 4.0 supportmemberTim Delmoitie9 Jul '12 - 4:26 
I have the PDF Viewer implemented on a .NET framework 3.5 platform and everything works fine.
When I convert the solution to .NET 4.0 and I run the code I get the following error when accessing the FileName-property:
 
TypeLoadException was unhandled
 
Declaration referenced in a method implementation cannot be a final method. Type: 'PDFLibNet.xPDFBinaryReader'. Assembly: 'PDFLibNet, Version=1.0.6.6, Culture=neutral, PublicKeyToken=26d87f7d66fb2aee'.
 
Anyone any idea what the problem may be ?
AnswerRe: .NET FWK 4.0 supportmemberWaleed Ahmed Malik16 Aug '12 - 0:58 
You need to set the project to compile under x86 or replace all the dlls with x64 files.
SuggestionMouse WheelmemberLewis Darwin25 Jun '12 - 8:07 
It would be nice if you could scroll with the mouse wheel through the page and multiple pages.
GeneralRe: Mouse Wheelmembersneharoopa3 Jul '12 - 2:39 
Hi,
 
How can we support scrolling to view multiple pages?
 
Regards,
Sneha
GeneralRe: Mouse WheelmemberTim Delmoitie9 Jul '12 - 4:15 
You can enable the scroll but you have to capture some events...
 
I addded the following sub :
 
Private Sub PicImageMouseEnter(ByVal sender As Object, ByVal e As EventArgs)
        DirectCast(sender, PictureBox).Focus()
        DirectCast(sender, PictureBox).Parent.Focus()
End Sub
 
In the InitiliazePageView you have to add a handler to this sub :
 
if mContinuousPages Then
    ...
    AddHandler objPictureBox.MouseEnter, AddressOf PicImageMouseEnter
    ...
else
   ...
   AddHandler objPictureBox.MouseEnter, AddressOf PicImageMouseEnter
   ...
end if
 
Works for me...
QuestionCan anyone convert its Code in C#?memberVibs17 Jun '12 - 21:06 
I'm Visual Basic Disabled. Can anyone help me to convert this VB Code into C#. I have tried various online convertors and none of them are working perfectly and there are some issues coming online.
AnswerRe: Can anyone convert its Code in C#?memberk.sathishkumar30 Jul '12 - 8:04 
Hi All,
 
I also need the c# version of same project...
 
If it's possible to convert or please provide us the c# version of same aritcle would be really nice.
 
Thanks and Regards,
Sathish
QuestionWhere I can download the .NET 4 version?memberOctavioCesar4 May '12 - 10:51 
Hi:
I need to download the .NET 4 version but Google Code is locked to Cuba. Exist another way to download the lastest version of PDFLibNet?
Best Regards
QuestionNote: The code depends on GPL libsmembercodeivan1 May '12 - 7:35 
Note: The code depends on GPL libs and may not suitable for commercial use...
 

http://www.webosnation.com/copyright-infringement-lawsuit-filed-against-palm[^]
QuestionPDF Viewer [Search in Arabic Books Support]memberyousefkhidr12 Apr '12 - 6:03 
Hi 'Ron Schuler'
 
I Face a problem in your greate User Contorl "PDF Viewer".
 
Certainly Searh using Arabic Keywords does not work properly.
 
If you can help me With Code or hints.
 
Thanks in advance.
Eng. Yousef

QuestionPDFLibNEtmemberrocket Khan20 Mar '12 - 1:24 
Why there are 4 different versions of pdfLibLet.dll??... :(
AnswerRe: PDFLibNEtmemberRon Schuler20 Mar '12 - 2:56 
Net 4.0:
32 bit and 64 bit
 
Before Net 4.0:
32 bit and 64 bit
GeneralRe: PDFLibNEtmemberrocket Khan20 Mar '12 - 18:42 
thanks for ur reply is there a way to use a single version on any CPU whether its 32 or 64?
or how can we alter PDFLibNet source code(Project settings/Configurations) so that it will be compatible with all platforms?
QuestionGreat articles! Found a pure .net pdf viewer useful to everyone.memberLvse13 Mar '12 - 16:21 
Great articles! Found a pure .net pdf viewer [^] useful to everyone.
AnswerRe: Great articles! Found a pure .net pdf viewer useful to everyone.memberjonnyboy8228 Mar '12 - 8:39 
Really?
QuestionA more scalable solution to view PDF in HTML5membercodeivan9 Mar '12 - 13:11 
Instead of converting PDF to images on the server you can now render files on the clinet side and without Acrobat plugin.
 
For more info check out:
 
http://www.pdftron.com/pdfnet/webviewer[^]
 
and for online demos see:
 
http://www.pdftron.com/pdfnet/webviewer/demo.html[^]
AnswerRe: A more scalable solution to view PDF in HTML5 [modified]memberRon Schuler9 Mar '12 - 15:02 
Looks like a great product.
However, have some integrity and plug your software somwehere else...
Unless your offering the source code for free...
 
Here is a solution that renders the PDF once for hosting on the server and allows any web browser to view the file. HTML5 or Silverlight is NOT REQUIRED. Actually, a web server isn't even required. It is made from the "Export to Website" option of this article's viewer control:
 
http://whereisron.net/webdoc[^]

modified 9 Mar '12 - 21:25.

GeneralRe: A more scalable solution to view PDF in HTML5memberMember 436281924 Jul '12 - 7:13 
codeivan, Why you don't go and sell your junk somewere else ?
QuestionViewing/Adding CommentsmemberMikeCooling9 Feb '12 - 23:01 
Ron, this is a really great piece of work - thank you!
 
I have a question... I've managed to find some code to allow me to add comments to a PDF (once I figure out the coordinates!) but I don't know if it's possible to get the viewer control to display comments?
 
It would be great to simply locate them on the page in the 'correct' position, I'd be happy to figure out how to process the click after that!
 
Thank you once again, nice work!
QuestionIs this Compatible with .Net FrameWork 4.0?memberSankaroo72 Feb '12 - 2:03 
Good Post!
Kindly reply me.
Is this Compatible with .Net FrameWork 4.0?
GeneralMy vote of 5mvpKanasz Robert19 Jan '12 - 12:13 
Interesting article. I'll use it very soon Smile | :) thank you for sharing.
QuestionBadImageFormatExcpetion on Windows 7 64bit (Framework 4.0)memberlucas_kay27 Dec '11 - 5:55 
Hi,
 
I am trying to use this on 64bit Windows 7 machine. I have tried both versions of of 64-bit PDFLibNet.dll (form PDFView\lib\Net4.0\x64 and PDFView\lib\x64) but I cant get it to work. I am getting a BadImageFormatException. 32bit library works great.
I have also tried to compile the 64bit version myself, but I am stuck at missing .lib dependencies (mupdf wants gdi and fails, as it cant find it, afpdf - mupdf lib and so on). Any help would be greatly appreciated!
 
Thanks,
lmk
AnswerRe: BadImageFormatExcpetion on Windows 7 64bit (Framework 4.0)memberArend Jan18 Jan '12 - 22:29 
In Visual Studio, select Build | Configuration Manager.
Add x86 to the active solution and select it as the platform for your project.
QuestionUnicode Bookmarkmemberreza_project26 Dec '11 - 21:22 
Hi
I'm using this control and it's very useful
tanks a lot
but i get a problem with Persian Bookmark!!!
when i choose a PDF with Persian bookmark it does not show correct text
for example these values:
Quote:
¬ëں«ëںêى ?¢ں
هى©«¢
ھë§?ï ëںêى ™ë¢يë ?¦يه
êن©يç
¢ىïى ?ëë§ى ھï© ?ںëں?ى
?ى ¢¦­

I'm glad to help me
QuestionParagraph SeparationmemberGeoNav11 Nov '11 - 22:42 
Hi, My vote for 5! It is working very well in my application. I had two issues.
Issue One - is it possible to replace the character/mark used for paragraph separation in the text? My requirement is to extract text from the pdf document and join the lines together. I tried to replace vbCrLf with "" in the extracted string, but that also joined the paragraphs!
 
Issue Two - pdfdoc.ExportHtml does not work. No error messages.
 
Any suggestions?
GeneralMy vote of 5membermendy aaron9 Nov '11 - 10:43 
Very useful project.
Questioncan I built-in SamplePDFViewer in Chrome or another browser?memberBruno_C_M9 Nov '11 - 5:17 
Hi,
 
I would replace the built-in PDF reader of Google Chrome, can I replace for this PDF Viewer?
 
I tried to put the "PDFView.dll" in this path:
C:\Users\(Username)\AppData\Local\Google\Chrome\Application\14.0.835.202
 
...but nothing happens
 
Can you help-me?
Thks
QuestionWhy does RenderPage() have to be called?memberrmyott24 Aug '11 - 3:08 
I am curious why you have to call PDFLibNet renderpage() and pass in handle to a picturebox before drawing to a separate bitmap.
 
Thanks
GeneralAdded latest muPDF source to PDFLibNet.dll + NET4.0 binaries - Get from SVNmemberRon Schuler10 Jun '11 - 9:56 
I had added the PDFLibNet.dll source to the repository and have updated jbig2, freetype, and muPDF source to the latest revisions.
I have added NET 4.0 pdflibnet.dll binaries in the lib folder.
GeneralRe: Added latest muPDF source to PDFLibNet.dll + NET4.0 binaries - Get from SVNmemberbsmith5 Oct '11 - 4:34 
I am looking to get this working on a 64 bit Windows 7 machine. Did you say you have the source code out for download?
bsmith

GeneralRe: Added latest muPDF source to PDFLibNet.dll + NET4.0 binaries - Get from SVNmemberRon Schuler5 Oct '11 - 5:20 
Use the google svn link
GeneralMemory leaks fixed in latest revision in SVN repositorymemberRon Schuler29 May '11 - 15:43 
Spent over 15 hours on this.
 
The good:
No more memory leaks for XPDF or muPDF. (I suggest using muPDF)
Updated the "Export to HTML Image Viewer" to support mouseover links and unicode text search.
 
The bad:
XPDF does not have pre-rendering of adjacent pages enabled.
Only 32-bit build available.
GeneralRe: Memory leaks fixed in latest revision in SVN repositorymemberRon Schuler30 May '11 - 4:54 
Updated the pdflibnet.dll again with a proper memory leak fix for muPDF.
QuestionMemory leak inside PDFWrappermemberstancosti25 May '11 - 11:45 
Ron,
 
This post refers to a memory de-allocation issue found inside PDFLibNet. Based on project's history since October 5th, 2009, I understand that you already modified the code/configuration of PDFLibNet.
 
I was using Red-Gate's Memory Profiler tool and found that PDFLibNet.PDFWrapper and PDFPage instances are not deallocated. The hook is an event handler called RenderNotifyFinishedHandler. If indeed you are using a modified version of PDFLibNet, I would prefer to discuss it with you instead of getting the source code from Antonio Sandoval.
 
Kind regards,
costi

AnswerRe: Memory leak inside PDFWrappermemberRon Schuler25 May '11 - 15:55 
I'll try to remove the handler when Close/Dispose occurs and recompile the pdflibnet dll. I'll let Antonio know what I changed.
AnswerRe: Memory leak inside PDFWrappermemberstancosti26 May '11 - 3:40 
Great news. Thank you so much!
costi

GeneralRe: Memory leak inside PDFWrappermemberRon Schuler28 May '11 - 4:58 
Update:
I have made a fixed dll.
My use case does not use the threaded page rendering, so I can just block the subscription to that event.
Ideally, Antonio just needs to unsubscribe the event handler on PDFWrapper.Dispose() if it exists.
I tried and tried, but kept getting protected memory errors when trying to free the event handler.
I am having revisioning issues though.
I made some rotation rendering fixes that are not in the latest pdflibnet code, so I need to see what modifications that were made and add them.
I will update the repository once I have merged the changes.
Questiondoc, docx, xls, xlsx, ppt, pptx viewer neededmemberAshik Iqbal22 May '11 - 5:44 
Is there any way to make the web based viewer (jpeg) of the following common formats?
 
doc, docx, xls, xlsx, ppt, pptx
GeneralWindows 7 x64 and VB.NET 2010memberJohnBlocker28 Apr '11 - 20:13 
I am trying to get the sample pdf viewer to run under win7 x64. I was able to build it fine on my 7 x64 machine, copy it to a winxp x32 and it runs ok, but it crashes with no warning on 7 x64 (Win7 just gives a notice that the program has to be closed.) I tried changing the compile options to 32 bit as suggested for win7 and VB.NET 2008 but I had the same results. I am using VB.NET 2010 express, is there other settings I need to change? I need to get it to build and run in 32 bit since my application needs to run on x32 and x64. Sorry if this is a dumb question, thanks in advance for any help.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130516.1 | Last Updated 6 Oct 2009
Article Copyright 2009 by Ron Schuler
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid