Skip to main content
Participant
June 11, 2020
Question

c# acrobat pdf convert to Image (export Image)

  • June 11, 2020
  • 1 reply
  • 2552 views

Hi

I want to extarct image using acrobat sdk.(Single page pdf to image)

I found the code and test that.

My problem is I don't know the size (mm) of the document.

 

 

Code is

 

string fileName = "C:/.../.../test.pdf";
Acrobat.AcroPDDoc pdfDoc = new Acrobat.AcroPDDoc();
bool ret = pdfDoc.Open(fileName);
            if (ret == false)
            {
                throw new FileNotFoundException();
            }

            int totalPage = pdfDoc.GetNumPages();
            int currentPage = 0;
            
            Acrobat.AcroPDPage pdfPage = 
            (Acrobat.AcroPDPage)pdfDoc.AcquirePage(currentPage);
            Acrobat.AcroPoint pdfSize = (Acrobat.AcroPoint)pdfPage.GetSize();
            Acrobat.AcroRect pdfRect = new Acrobat.AcroRect();
            
                    
            pdfRect.Left = 0;
            pdfRect.right = pdfSize.x  ;     
            pdfRect.Top = 0;
            pdfRect.bottom = pdfSize.y;

            MessageBox.Show(Convert.ToString( pdfSize.x) + Convert.ToString( pdfSize.y) );
            
            pdfPage.CopyToClipboard(pdfRect, 0, 0, 100);


            IDataObject clipboardData = Clipboard.GetDataObject();
            Console.WriteLine(Convert.ToChar ( clipboardData));
            if (clipboardData.GetDataPresent(DataFormats.Bitmap))
            {
              Bitmap pdfBitmap = (Bitmap)clipboardData.GetData(DataFormats.Bitmap);
              pdfBitmap.Save("C:/.../.../.bmp");

            }

 

 

then Message Box show pixels of x,y . And DPI(dot per inches) is changed.

 

I want to extract it to the actual size of the document. Or Is there DPI function in interop.Acrobat?

This topic has been closed for replies.

1 reply

Legend
June 11, 2020

There is no dpi/ppi in PDF files. There is no size in pixels for a page - so your code is not reporting a size in pixels. There is a dimension in points, which can be converted to inches or mm as required.

Sup.SHAuthor
Participant
June 11, 2020

Thanks for reply.

How can I convert the point dimension to mm??

 

Additionally, to be precise my ultimate goal is to use the export function of the Adobe Acrobat program. Rather than copying and pasting to the clipboard. Do you know the export function in Acrobat c#?