Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extract images from PDF #60

Closed
ghosttie opened this issue Mar 8, 2022 · 1 comment
Closed

extract images from PDF #60

ghosttie opened this issue Mar 8, 2022 · 1 comment

Comments

@ghosttie
Copy link

ghosttie commented Mar 8, 2022

Some of the PDF files that my application processes were created by scanners, so they're basically a PDF containing nothing but one image per page.

I would like to extract the images so that I can deal with them as images rather than PDFs. I don't want to use GetImage to convert the whole page to an image because this will include the margins around the image.

Looking at the source code, it looks like Docnet includes the PDFium calls required to extract images from PDF files:

[SuppressUnmanagedCodeSecurity]
[DllImport("pdfium", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "FPDFImageObj_GetBitmap")]
internal static extern IntPtr FPDFImageObjGetBitmap(IntPtr image_object);

[SuppressUnmanagedCodeSecurity]
[DllImport("pdfium", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "FPDFBitmap_GetBuffer")]
internal static extern IntPtr FPDFBitmapGetBuffer(IntPtr bitmap);
[SuppressUnmanagedCodeSecurity]
[DllImport("pdfium", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "FPDFBitmap_GetWidth")]
internal static extern int FPDFBitmapGetWidth(IntPtr bitmap);
[SuppressUnmanagedCodeSecurity]
[DllImport("pdfium", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "FPDFBitmap_GetHeight")]
internal static extern int FPDFBitmapGetHeight(IntPtr bitmap);
[SuppressUnmanagedCodeSecurity]
[DllImport("pdfium", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "FPDFBitmap_GetStride")]
internal static extern int FPDFBitmapGetStride(IntPtr bitmap);

It would be great if this was exposed so it was available to be used through Docnet.

@Modest-as
Copy link
Member

Duplicate to #39 we want to expose a way to detect if there are embedded images in pages and extract them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants