dcsimg
Results 1 to 15 of 15

Thread: VB6 PDFium-Binding (Viewing + Text- and ImageExports)

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jun 2013
    Posts
    4,345

    VB6 PDFium-Binding (Viewing + Text- and ImageExports)

    On request, here a little Demo which shows how to use the (license-wise very generous), "pdfium.dll in action".

    PDFium (licensed under BSD by Google/Foxit) is the only PDF-reader/viewer-tool I know of,
    which can be used (and deployed) also in commercial Apps ...
    (the size of pdfium.dll is about 4 to 5MB in its windows-version, depending on optional compile-includes - that's normal)

    The VB6-Demo here comes in form of a little Viewer-App, which also allows Exports of:
    - Document-PlainText (into a Zip-Archive, which later will contain page_1.txt to page_n.txt files)
    - Document-Images (also into a Zip, either as *.png or *.jpg images, within page_x subfolders)
    Those exports are done in two stages:
    Stage 1 is an export into appropriate InMemoryDB-tables (Tables Text and Images, from where the contents can be selected into a Rs - containing two Fields -> Name As Text and Data As Blob aka. ByteArray, so the FileSystem is not touched by stage 1).

    Stage 2 (as used in the Zip-File-Export, triggered by appropriate Buttons in the Viewer-App),
    will convert the contents of either the Text- or Images MemDB-Tables into a Zip-ByteArray (still not touching the FileSystem)

    Stage 3 (one line of code) will then simply write-out the appropriate Zip-ByteArray to disk.

    Also the Read-Direction (of a PDF) can be triggered "FileSystem-less", when the PDF-content exists in a ByteArray somewhere
    (e.g. when retrieved via a Download, or retrieved via a RemoteDB-call, sitting in an Rs-BlobField).


    Ok, the 3 RC5-Base-libs (+ vbWidgets.dll in addition) are a requirement for this demo -
    please download and (re-)register them in a recent version (Zip-Archive support is only available in recent ones).

    As for a recent build of the pdfium.dll, there's a build-service provided by Pieter van Ginkel on GitHub here:
    https://github.com/pvginkel/PdfiumBu.../master/Builds

    There's several different versions of it available behind the above URL,
    the one I'm using is under: 2018-04-08/Pdfium-x86-no_v8-no_xfa

    So, to make the Demo work in the IDE, you will have to install (or re-register) the RC5-libs
    in a folder of your choice on your dev-machine...
    (this should not be the Project-Folder of this Demo, but a spearate RC5-Folder - as e.g. C:\RC5\
    ...please make sure, that both: vbRichClient5.dll and vbWidgets.dll are reigstered beforehand)

    Another pre-requisite before you run the Demo, is to place the pdfium.dll in the DemoProjects \Bin\-Folder.
    (it is the only Dll which needs to be placed there, when you run the Demo in the IDE,
    ...if you compile - and run the Executable, then also the 4 RC5-BaseDlls need to be placed in \Bin\)
    The just mentioned \Bin\ Folder of the Demo-Project does currently contain only a ReadMe.txt, which describes this as well).

    The pdfium-wrapping is done in 3 Classes:
    - cPDFium (the main-class)
    - cPDFiumPageText (a cPDFium-derivable ChildClass, which allows interaction with Page-Texts)
    - cPDFiumPageObject (a cPDFium-derivable ChildClass, which allows interaction with Page-Objects)

    The latter class above, can represent different (enumerable) PageObject-types as shown in the following enum:
    Code:
    Public Enum ePdfObjectType
      FPDF_PAGEOBJ_UNKNOWN = 0
      FPDF_PAGEOBJ_TEXT = 1
      FPDF_PAGEOBJ_PATH = 2
      FPDF_PAGEOBJ_IMAGE = 3
      FPDF_PAGEOBJ_SHADING = 4
      FPDF_PAGEOBJ_FORM = 5
    End Enum
    The magenta-colored entry above, is the one we will filter for, when we do Image-Exports (per Page).

    Note, that this Demo (due to using the RC5-libs), is (when compiled):
    - directly regfree deployable as a true portable App (without any Setup)
    - fully DPI-aware also on HighRes-Displays (without any problems with e.g. 200% DPI-scaling)
    - not using any Win32-API-calls (and thus fully "linux-aware", when compiled by a future platform-independent compiler)
    - not really requiring any manifesting (since the UI is not using any Windows-CommonControls, and DPI-awareness is ensured by Cairo)

    Here a ScreenShot:


    And here the Zipped Demo-Source (without any Dlls in the Bin-Folder, please ensure its population yourself)
    PDFiumViewer.zip

    Have fun!

    Olaf
    Last edited by Schmidt; Aug 24th, 2019 at 09:41 AM.

  2. #2
    Hyperactive Member
    Join Date
    Jul 2013
    Posts
    372

    Re: VB6 PDFium-Binding (Viewing + Text- and ImageExports)

    Nice job, and very useful
    Thank you
    Carlos

  3. #3
    Hyperactive Member
    Join Date
    Jan 2015
    Posts
    299

    Re: VB6 PDFium-Binding (Viewing + Text- and ImageExports)

    I'll try to test it, but I need to install RC5.

    My actual homemade PDF viewer is very powerfull, and based on MODI.
    I export everything to JPG, then open and manage with MODI, including OCR, extracting, etc...
    And 100% working on all Windows, and TS also

    but of course quite a lot of code behind

  4. #4
    Hyperactive Member
    Join Date
    Jul 2013
    Posts
    372

    Re: VB6 PDFium-Binding (Viewing + Text- and ImageExports)

    My actual homemade PDF viewer is very powerfull, and based on MODI.
    But one needs to have Microsoft Office, right?
    Carlos

  5. #5
    Hyperactive Member
    Join Date
    Jan 2015
    Posts
    299

    Re: VB6 PDFium-Binding (Viewing + Text- and ImageExports)

    No need to have Microsoft Office.
    Just installing the MODI from the officepack (ich is free)

  6. #6
    Hyperactive Member
    Join Date
    Jul 2013
    Posts
    372

    Re: VB6 PDFium-Binding (Viewing + Text- and ImageExports)

    Quote Originally Posted by Thierry69 View Post
    No need to have Microsoft Office.
    Just installing the MODI from the officepack (ich is free)
    Well, I "googled" around and couldn't get an installer to download. What is that "officepack"?
    All I could find was some tricky solutions from microsoft itself. Is there a simple solution to deploy it?
    Carlos

  7. #7
    Hyperactive Member
    Join Date
    Jan 2015
    Posts
    299

    Re: VB6 PDFium-Binding (Viewing + Text- and ImageExports)

    Search Sharepointdesigner.exe

  8. #8
    Hyperactive Member
    Join Date
    Jul 2013
    Posts
    372

    Re: VB6 PDFium-Binding (Viewing + Text- and ImageExports)

    Quote Originally Posted by Thierry69 View Post
    Search Sharepointdesigner.exe
    SharePoint Designer for Office 2007 is no long available. I was able to install MDI to TIFF though, and got mdi2tif.exe, mstfcore.dll, mstfink.dll, msptls.dll, and richedit20.dll inside Program File(x86)\modiconv. Is this all one need?
    Carlos

  9. #9
    Hyperactive Member
    Join Date
    Jan 2015
    Posts
    299

    Re: VB6 PDFium-Binding (Viewing + Text- and ImageExports)

    You can still download it, not hard to find it, and no problem to install it
    You'll have an OCX installed, and it is powerfull

  10. #10
    Hyperactive Member
    Join Date
    Jul 2013
    Posts
    372

    Re: VB6 PDFium-Binding (Viewing + Text- and ImageExports)

    Quote Originally Posted by Thierry69 View Post
    You can still download it, not hard to find it, and no problem to install it
    You'll have an OCX installed, and it is powerfull
    I think I tried from everywhere. All I could get is for Office 2013.
    I guess it's a no way road now.
    Thanks anyway.
    Carlos

  11. #11
    Hyperactive Member
    Join Date
    Jan 2015
    Posts
    299

    Re: VB6 PDFium-Binding (Viewing + Text- and ImageExports)

    Yes, there is no newest version.
    When isntalling it, just install the Imaging part, and no need for the remaining

  12. #12
    Hyperactive Member
    Join Date
    Jul 2013
    Posts
    372

    Re: VB6 PDFium-Binding (Viewing + Text- and ImageExports)

    What I mean is the OLDER version available is for Office 2013 and it doesn't include the Imaging Tools.
    The last one with MODI is for Office 2007 and MS link simply "disappeared".
    I was hoping that being freeware the installer could be found somewhere else, but no, there must be "something" in the license the prevents it, as usually with MS pseudo-free stuff.
    Carlos

  13. #13
    Hyperactive Member
    Join Date
    Jan 2015
    Posts
    299

    Re: VB6 PDFium-Binding (Viewing + Text- and ImageExports)

    MP Sent

  14. #14
    Frenzied Member
    Join Date
    Dec 2008
    Posts
    1,205

    Re: VB6 PDFium-Binding (Viewing + Text- and ImageExports)

    Schmidt,
    Will it work (developing) in XP ?
    Rob

  15. #15

    Thread Starter
    PowerPoster
    Join Date
    Jun 2013
    Posts
    4,345

    Re: VB6 PDFium-Binding (Viewing + Text- and ImageExports)

    Quote Originally Posted by Bobbles View Post
    Schmidt,
    Will it work (developing) in XP ?
    The pdfium.dll on the link I gave in the opener post, was built with a newer VC-environment,
    and that (depending on the VC-project-settings) can cause problems on "systems, which ran out of support".

    Out of interest, I've just tested "pdfium.dll" with "depends.exe" on an XP-VM,
    and it says that "ieshims.dll" and also "wer.dll" were expected - but missing.
    (those were introduced with IE8 for Vista, though not with IE8 for XP).

    So, whilst the RC5-package would work on XP (compiled with a 7year old VC-environment and statically linked msvcrt-deps),
    the pdfium.dll will not load on XP "out of the box" due to the above missing dependencies.

    There might be a chance, that those are contained in some "MS-VC-redist"-setup (or some other older MS-upgrade-package for XP),
    but I don't have the time to find out, which one you might have to install to fix those dependencies.

    5 years ago, I might have tried to solve that "for VB6-devs who still had to deploy to XP",
    but in the meantime there's not much of an XP-userbase left "in the wild", to bother with it.

    IMO (regarding "time to invest" on your end), you'd be better off,
    to just move your VB6-stuff over to at least a Win7-installation (or -VM).

    Olaf

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width