Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: Converting a pdf document to a jpeg image C#

137 views
Skip to first unread message

Aandi_...@adobeforums.com

unread,
Apr 1, 2008, 11:47:56 PM4/1/08
to
Before you can start the code, you need a suitable product installed.
This may be more challenging than you realise.

You cannot use Acrobat for this, because Acrobat must not be installed
on a server. Adobe's PDF Library might work, but that has a C/C++
linkage. Adobe's LiveCycle products seem to be Java based; not sure if
one of them does this.

Aandi Inston

theon...@adobeforums.com

unread,
Apr 1, 2008, 10:40:50 PM4/1/08
to
HI There,

How can I convert a pdf document to a jpeg image using c sharp? I need to do this on a web application. If someone can help me out with some code that would be great.

Sean - thanks in advance

wim.va...@hotmail.com

unread,
Apr 7, 2008, 8:16:50 AM4/7/08
to
On Apr 2, 4:40 am, theonlys...@adobeforums.com wrote:
try this from codeproject
pdfDoc = (Acrobat.CAcroPDDoc)
Microsoft.VisualBasic.Interaction.CreateObject("AcroExch.PDDoc", "");
int ret = pdfDoc.Open(inputFile);
if (ret == 0)
{
throw new FileNotFoundException();
}
// Get the number of pages (to be used later if you wanted to store
that information)
int pageCount = pdfDoc.GetNumPages();
// Get the first page
pdfPage = (Acrobat.CAcroPDPage)pdfDoc.AcquirePage(0);
pdfPoint = (Acrobat.CAcroPoint)pdfPage.GetSize();
pdfRect = (Acrobat.CAcroRect)
Microsoft.VisualBasic.Interaction.CreateObject("AcroExch.Rect", "");
pdfRect.Left = 0;
pdfRect.right = pdfPoint.x;
pdfRect.Top = 0;
pdfRect.bottom = pdfPoint.y;
// Render to clipboard, scaled by 100 percent (ie. original size)
// Even though we want a smaller image, better for us
to scale in .NET
// than Acrobat as it would greek out small text
// see http://www.adobe.com/support/techdocs/1dd72.htm
pdfPage.CopyToClipboard(pdfRect, 0, 0, 100);
IDataObject clipboardData = Clipboard.GetDataObject();
if (clipboardData.GetDataPresent(DataFormats.Bitmap))
{
Bitmap pdfBitmap =
(Bitmap)clipboardData.GetData(DataFormats.Bitmap);
}

success Wim

0 new messages