Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

c# acrobat pdf convert to Image (export Image)

Community Beginner ,
Jun 11, 2020 Jun 11, 2020

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?

TOPICS
Edit and convert PDFs
2.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 11, 2020 Jun 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 11, 2020 Jun 11, 2020
LATEST

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#?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines