Forum moved here!

Home / How to compile to can preview mobi files?

ComptonalAlvaro

I have read that to can enabled the preview of files different than PDF, like mobi files, I have to compile the project after modifying the premake5.lua file.

I am trying to compile with Visual Studio 2022 community.

The process that I follow is this:

1.- I download the code of sumatra. In this case the last version, 3.4.

2.- Edit the premake5.lua file and I search for this lines:

    pdf_preview_files()
    filter {"configurations:Debug"}
      -- defines { "BUILD_XPS_PREVIEW" }
      -- TODO: use EngineMupdf for XPS
      defines {
        "BUILD_DJVU_PREVIEW", "BUILD_EPUB_PREVIEW",
        "BUILD_FB2_PREVIEW", "BUILD_MOBI_PREVIEW", "BUILD_CBZ_PREVIEW",
        "BUILD_CBR_PREVIEW", "BUILD_CB7_PREVIEW", "BUILD_CBT_PREVIEW",
        "BUILD_TGA_PREVIEW"
      }
    filter {}
    -- TODO: "chm" should only be for Debug config but doing links { "chm" }
    -- in the filter breaks linking by setting LinkLibraryDependencies to false
    links { "utils", "unrar", "libmupdf", "chm" }
    links { "comctl32", "gdiplus", "msimg32", "shlwapi", "version" }

After this code, I added this code:

    pdf_preview_files()
    **filter {"configurations:Release"}**
      -- defines { "BUILD_XPS_PREVIEW" }
      -- TODO: use EngineMupdf for XPS
      defines {
        "BUILD_DJVU_PREVIEW", "BUILD_EPUB_PREVIEW",
        "BUILD_FB2_PREVIEW", "BUILD_MOBI_PREVIEW", "BUILD_CBZ_PREVIEW",
        "BUILD_CBR_PREVIEW", "BUILD_CB7_PREVIEW", "BUILD_CBT_PREVIEW",
        "BUILD_TGA_PREVIEW"
      }
    filter {}
    -- TODO: "chm" should only be for Debug config but doing links { "chm" }
    -- in the filter breaks linking by setting LinkLibraryDependencies to false
    links { "utils", "unrar", "libmupdf", "chm" }
    links { "comctl32", "gdiplus", "msimg32", "shlwapi", "version" }

Just I copy the code of the debug configuration and set it as release.

3.- I Install Go. If I am not wrong, it is needed to rebuild the project and create the new projects of Visual Studio.

4.- I run the doit.bat file to regenerate the files of the project.

5.- I open the SumatraPdf.sln file in visual studio.

6.- I compile the solution in x64.

7.- I get the result in the folder “rel64”.

8.- Copy all the folder to my applications folder. It is about 900MB of data. It is not like when I download the application from the web, that is only 4 files and few megabytes.

9.- I Configure this compiled version of sumatra as default application to open the mobi files.

But I only see a icon with “PDF” text and i can’t see anything in the preview pane.

I am compile in the wrong way? I have to configure something in windows after compile it?

Thanks.

GitHubRulesOK

long time since trying, there will be lots of small-files generated for combining and processing to get just the 4 final files you want for installation the results will be in a rel folder
one is the installed exe one is the common PdfPreview.dll which is roughly 600Kb.

You will need to uninstall your previous copy and install your custom build to register and use your own previewer (never use 2 at the same time). I do not know if anyone has compiled the previewer recently since it can be difficult and all formats apart from PDF are untested thus how it may work with MuPDF changes.

So your very much on your own there. Certainly setting the association with mobi files should help since MuPDF does not handle those file types but it is the dll that provides the mini viewer and so I don’t think it simply needs the file to be associated in the normal way. With SumatraPDF.exe it is the registered previewer for that filetype that will be needed, so you might need to build your own registry key if you did not include in the build (which you seem to have done)