jya-dev / supernote-tool

Unofficial python tool for Supernote
Apache License 2.0
255 stars 27 forks source link

pdf.mark #27

Open Sourgin opened 1 year ago

Sourgin commented 1 year ago

Hi, so I did a thing with your stuff in order to read PDF.mark an convert them to png.

In essence

parse.py 
class SupernoteXParser(SupernoteParser):
    SN_SIGNATURES = [
+       'markSN_FILE_VER_20220013'  // ADD recognition for the file type

converter.py
def _flatten_layers(self, page, imgs, visibility_overlay=None):
-        for name in reversed(layer_order):
-            is_visible = visibility.get(name)
-            if visibility_overlay is not None:
-                overlay = visibility_overlay.get(name)
-               if overlay == VisibilityOverlay.INVISIBLE or (overlay == VisibilityOverlay.DEFAULT and not is_visible):
-                    continue
-            else:
-                if not is_visible:
-                    continue
-            img_layer = imgs.get(name)
-            if img_layer is not None:
-                if name == 'BGLAYER':
-                    # convert transparent to white for custom template
-                    img_layer = self._whiten_transparent(img_layer)
-                flatten_img = flatten(img_layer, flatten_img)

+       img_layer = imgs.get(layer_order[0])
+       flatten_img = flatten(img_layer, flatten_img)

If it helps you. For my project 90% of the code is irrelevant and will strip down everithing I can, just need the result of all PDF.Mark > PNG for now, but it can help other people if PDF.mark conversion is integrated.

tiberiufrat commented 1 year ago

Would it be possible to integrate this feature in the toolset if it's so easy to implement? It would be very helpful to be able to see .mark files and perhaps overlay them on the corresponding pdfs.