How to obtains a image from PDF file inn a Web Page working in Visual Studio .NET 2008 and the Adobe Acrobat 9.0 installed. We want in basis to a PDF file, obtain the .jpg, .png or .bmp bitmap for usage in a Web Page without use of Windows Forms. In the server side work. Tanks
We work with other image formats like .jpg or .png but with .pdf we can not obtain the image for work with him. Is not posible to use the other applications, we need work all in the behavior code of the page. Thanks but is not a solution.
The problem is in obtains a Image from PDF file. I working in Visual Studio .Net 2008 in a web form.
The code is very simple:
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim PathApp As String = "C:UsersUsuarioDocumentsVisual Studio 2008WebSitesMafWebArchivosAuxiliares"
Dim filePath As String = PathApp & "IS2008.pdf"
Dim fileSave As String = filePath.Replace(".pdf", ".png")
Dim pdfDocument As New Acrobat.AcroPDDoc, pdfPage As Acrobat.AcroPDPage
Dim pdfFile As System.IO.FileStream
Dim newWidth As Integer, newHeight As Integer, numPages As Integer
Dim pointPdfSize As Acrobat.AcroPoint, HDC As Integer, rectPdfSize As New Acrobat.AcroRect
Booleano = pdfDocument.Open(filePath)
numPages = pdfDocument.GetNumPages
pdfPage = pdfDocument.AcquirePage(0)
pdfFile = New System.IO.FileStream(filePath, System.IO.FileMode.Open, System.IO.FileAccess.Read)
pointPdfSize = pdfPage.GetSize
newWidth = CInt(pointPdfSize.x)
newHeight = CInt(pointPdfSize.y)
rectPdfSize.Top = 0
rectPdfSize.Left = 0
rectPdfSize.right = newWidth
rectPdfSize.bottom = newHeight
'if I do: pdfPage.CopyToClipboard(rectPdfSize, 0, 0, 100) I am in clipboard the image and I can paste it in a word document or something similar but only when i run in a Local Server
Dim newBitmap As Bitmap, newGraphic As Graphics, Objeto As Object
newBitmap = New Bitmap(newWidth, newHeight)
newGraphic = Graphics.FromImage(newBitmap)
HERE IS THE PROBLEM:
Dim nHDC As Integer = newGraphic.GetHdc()
Dim nHWND As Integer = nHDC
WHAT ARE THE CORRECTS nHWND and nHDC? The result of next sentence are allways: Arithmetic operation has resulted in an overflow.
I PROUVE WITH ALL COMBINATIONS FOR nHWND and nHDC with IntPtr.Zero as GetDC for display… thousands runs any exit
pdfPage.Draw(nHWND, nHDC, 0, 0, 100) ' but how obtains nHWND and nHDC?, where puts the image?
'pdfPage.DrawEx(nHWND, nHDC, rectPdfSize, 0, 0, 100) ' but how obtains nHWND and nHDC, where puts the image?
newBitmap.Save(fileSave)
Panel__Doc.BackImageUrl = fileSave
End Sub
I am the complete Adobe Acrobat 9.0 installed in my PC and into sample application I have:
Imports System.Runtime.InteropServices
Imports System.Windows
Imports System.Drawing
Imports System.Drawing.Imaging
Imports System.Drawing.Drawing2D
Imports System.Drawing.Design
Imports Acrobat
Imports AcroPDFLib
Can you help me, please?
Free Guide: Managing storage for virtual environments
Complete a brief survey to get a complimentary 70-page whitepaper featuring the best methods and solutions for your virtual environment, as well as hypervisor-specific management advice from TechTarget experts. Don’t miss out on this exclusive content!
Discuss This Question: 3  Replies