rorycl / rm2pdf

Convert reMarkable tablet notebooks and annotated PDFs to layered PDF documents
MIT License
70 stars 4 forks source link

Build/Test not running #1

Closed gitbock closed 4 years ago

gitbock commented 4 years ago

Hi,

thanks for your work! This ist exactly what I am loking for as I regulary sync my remarkable to my linux system and want to convert the notebooks by batch :)

However I cannot get it built:

root@: /tmp/rm2pdf# go test -v ./...
main.go:12:2: cannot find package "github.com/jessevdk/go-flags" in any of:
        /usr/lib/go-1.10/src/github.com/jessevdk/go-flags (from $GOROOT)
        /root/go/src/github.com/jessevdk/go-flags (from $GOPATH)
main.go:14:2: cannot find package "github.com/rorycl/rm2pdf/rmpdf" in any of:
        /usr/lib/go-1.10/src/github.com/rorycl/rm2pdf/rmpdf (from $GOROOT)
        /root/go/src/github.com/rorycl/rm2pdf/rmpdf (from $GOPATH)
files/files.go:14:2: cannot find package "github.com/google/uuid" in any of:
        /usr/lib/go-1.10/src/github.com/google/uuid (from $GOROOT)
        /root/go/src/github.com/google/uuid (from $GOPATH)
rmpdf/pdf.go:13:2: cannot find package "github.com/jung-kurt/gofpdf" in any of:
        /usr/lib/go-1.10/src/github.com/jung-kurt/gofpdf (from $GOROOT)
        /root/go/src/github.com/jung-kurt/gofpdf (from $GOPATH)
rmpdf/pdf.go:14:2: cannot find package "github.com/jung-kurt/gofpdf/contrib/gofpdi" in any of:
        /usr/lib/go-1.10/src/github.com/jung-kurt/gofpdf/contrib/gofpdi (from $GOROOT)
        /root/go/src/github.com/jung-kurt/gofpdf/contrib/gofpdi (from $GOPATH)
rmpdf/pdf.go:17:2: cannot find package "github.com/rorycl/rm2pdf/files" in any of:
        /usr/lib/go-1.10/src/github.com/rorycl/rm2pdf/files (from $GOROOT)
        /root/go/src/github.com/rorycl/rm2pdf/files (from $GOPATH)
rmpdf/pdf.go:16:2: cannot find package "github.com/rorycl/rm2pdf/rmparse" in any of:
        /usr/lib/go-1.10/src/github.com/rorycl/rm2pdf/rmparse (from $GOROOT)
        /root/go/src/github.com/rorycl/rm2pdf/rmparse (from $GOPATH)
rmpdf/localcolour.go:12:2: cannot find package "golang.org/x/image/colornames" in any of:
        /usr/lib/go-1.10/src/golang.org/x/image/colornames (from $GOROOT)
        /root/go/src/golang.org/x/image/colornames (from $GOPATH)

It seems dependencies are missing (?) Sorry, I am not familiar with go :(

I am using an odroid C2 running ubuntu 18. root@: /tmp/rm2pdf# uname -a Linux 3.16.78-48 #1 SMP PREEMPT Thu Dec 5 07:27:42 -02 2019 aarch64 aarch64 aarch64 GNU/Linux

Can you give me a hint?

gitbock commented 4 years ago

Ok, I don't know if this is the proper way, but I was able to build it by executing first

go get github.com/jessevdk/go-flags
go get github.com/rorycl/rm2pdf/rmpdf
go get github.com/google/uuid
go get github.com/jung-kurt/gofpdf
rorycl commented 4 years ago

Hi @gitbock. go test -v ./... should have downloaded the dependencies. Are you on go 1.13 by any chance? Unfortunately module support is an emerging feature of go development.

Glad you were able to download the dependencies. Did go build work for you? Let me know how you get on.

There is a problem with the pdf importing library, causing some PDFs to fail the import process. If you suffer from that problem you may need to pre-process the PDF using, for example, the pdftk tool. For example mv original.pdf original.pdf.bak && pdftk original.pdf.bak cat output original.pdf. pdftk appears to rewrite the xref table of problematic PDF files so that the pdf import library (gofpdi) can run ok.

I'm looking into an alternative import library or for information to assist in fixing the problem.

gitbock commented 4 years ago

Hi rorycl, It's working out pretty well at the moment.

Yes go builddid work! It created the bin file which I can use now. Right now I am not using the PDF Import but the convert rm to PDF. Good to know the hint anyway.

I am just building a python wrapper to batch convert my notebooks into PDFs. Looking good so far :)

16.01.2020 22:18:04 - INFO - -------------------------------------------------------
16.01.2020 22:18:04 - INFO - Starting RM Converter on "seneca"...
16.01.2020 22:18:04 - INFO - Fetching Notebook files and metadata...
16.01.2020 22:18:04 - INFO - Converting /mnt/daten/remarkable/raw/9e1ed98c-7132-4389-954d-c558552a8b21 to /mnt/daten/remarkable/pdf/DevSecOps.pdf ..
16.01.2020 22:18:04 - DEBUG - Convert command: /opt/rm2pdf/rm2pdf -t /opt/rm2pdf/templates/A4.pdf /mnt/daten/remarkable/raw/9e1ed98c-7132-4389-954d-c558552a8b21 /mnt/daten/remarkable/pdf/DevSecOps.pdf
16.01.2020 22:18:05 - INFO - Converting /mnt/daten/remarkable/raw/32070424-c3a3-4ca1-b785-30aee5ec3408 to /mnt/daten/remarkable/pdf/Entwicklung.pdf ..
16.01.2020 22:18:05 - DEBUG - Convert command: /opt/rm2pdf/rm2pdf -t /opt/rm2pdf/templates/A4.pdf /mnt/daten/remarkable/raw/32070424-c3a3-4ca1-b785-30aee5ec3408 /mnt/daten/remarkable/pdf/Entwicklung.pdf
16.01.2020 22:18:08 - INFO - Converting /mnt/daten/remarkable/raw/9653e1fd-b67d-45e5-bf70-48fb159517a7 to /mnt/daten/remarkable/pdf/Security.pdf ..
16.01.2020 22:18:08 - DEBUG - Convert command: /opt/rm2pdf/rm2pdf -t /opt/rm2pdf/templates/A4.pdf /mnt/daten/remarkable/raw/9653e1fd-b67d-45e5-bf70-48fb159517a7 /mnt/daten/remarkable/pdf/Security.pdf
16.01.2020 22:18:11 - INFO - Converting /mnt/daten/remarkable/raw/65e1da44-f3e7-4af5-8273-76b17a551172 to /mnt/daten/remarkable/pdf/Tagebuch.pdf ..
16.01.2020 22:18:11 - DEBUG - Convert command: /opt/rm2pdf/rm2pdf -t /opt/rm2pdf/templates/A4.pdf /mnt/daten/remarkable/raw/65e1da44-f3e7-4af5-8273-76b17a551172 /mnt/daten/remarkable/pdf/Tagebuch.pdf
16.01.2020 22:18:20 - INFO - Converting /mnt/daten/remarkable/raw/74f5bd21-7a18-4a1e-b9ba-378eb52c47cb to /mnt/daten/remarkable/pdf/Quick sheets.pdf ..
16.01.2020 22:18:20 - DEBUG - Convert command: /opt/rm2pdf/rm2pdf -t /opt/rm2pdf/templates/A4.pdf /mnt/daten/remarkable/raw/74f5bd21-7a18-4a1e-b9ba-378eb52c47cb /mnt/daten/remarkable/pdf/Quick sheets.pdf
16.01.2020 22:18:20 - INFO - Ended RM Converter on "seneca". Total Duration = 0:00:16.558459

Thank you very much for your work!

rorycl commented 4 years ago

@gitbock : thanks very much for your notes -- great to hear rm2pdf is working for you.

I find that some PDFs can't be imported, due (it seems) to gofpdi #16. In the mean time rewriting the pdf with pdftk has solved that problem for me, but it is annoying. I'm looking into alternatives.

I'm considering making a go programme for operating on the contents of a xochitl directory store as rmapi does via the api. It would be convenient, for example, to quickly find a recent note by name or regex, and then process it. Could your script be used as a basis for that? Let me know what you think.

gitbock commented 4 years ago

Hi,

I don't understand exactly what you mean with "PDF cant be imported". Do you mean a plain PDF you want to transfer to the remarkable?

Right now I did not realize any "panics" converting a .rm to PDF with your tool :)

The new idea with the go programme sounds interesting! Right now my flow for backuping and converting remarkable is like this:

  1. rsync to my hard disk on server  (I am using an odroid for this)

  2. convert all rm to pdf

  3. upload PDFs to my seafile cloud instance

  4. and 3. is done by my python wrapper. If you are interested I attached it. Sorry, coding is not my business, so the code is most likely not efficient ;)

    Cool will be a CLI tool like this:

    rmtool convert --notebook-name --outpath /tmp --outformat pdf --template A4.pdf

    without need of downloading downbooks from rm first by using API or ssh. or only

    rmtool info --notebook-name (Quick.*)

    Notebook name: Quick Sheets

    Pages: 2

    Last updated: 18.01.2020 13:00

    file path: ...

    ... other useful information

    A pity I don't have time to learn "go" now, otherwise would be happy to contribute.

    Another question: I realized that drawings in grey are not grey in the PDF. It seems that the color for fineliner is not reflected? Attached is the result of the two commands:

    /opt/rm2pdf/rm2pdf -t /opt/rm2pdf/templates/A4.pdf /mnt/daten/temp/aab36d9c-0510-4af1-b5a4-aa7e549b9e8b /mnt/daten/download/test_wout_color.pdf

    /opt/rm2pdf/rm2pdf -c blue -t /opt/rm2pdf/templates/A4.pdf /mnt/daten/temp/aab36d9c-0510-4af1-b5a4-aa7e549b9e8b /mnt/daten/download/test_blue.pdf

    What do you think: Is this problem related to the one you described before?

    If you like we can also mail directly without the github stuff: My mail gitbock@bock-systems.de

    It seems that you love your remarkable as much as I do ;)

    Kind regards

    Boris.

    Rory Campbell-Lange notifications@github.com hat am 18. Januar 2020 10:53 geschrieben:

    @gitbock : thanks very much for your notes -- great to hear rm2pdf is working for you. I find that some PDFs can't be imported, due (it seems) to gofpdf #16. In the mean time rewriting the pdf with pdftk has solved that problem for me, but it is annoying. I'm looking into alternatives. I'm considering making a go programme for operating on the contents of a xochitl directory store as rmapi does via the api. It would be convenient, for example, to quickly find a recent note by name or regex, and then process it. Could your script be used as a basis for that? Let me know what you think. —You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or unsubscribe.

rorycl commented 4 years ago

Hi @gitbock

Thanks for your ideas and use of the tool. I'll email you directly when I have time.

Great you haven't had any issues converting notebooks at the moment, apart from the fineliner colour problem you mentioned.

You can use a different colour for each layer by using a colourname specified at https://godoc.org/golang.org/x/image/colornames. For example rm2pdf -c Cadetblue -c Indianred <source> <output>. Could you let me know if that works for you and suits your use case?

I'll have a think about extending the project to include connections to a reMarkable and using the visible name; thanks for those ideas.

Some PDFs cause an issue, such as the one below, so great to learn that you haven't had that issue.

~/src/go-rm2pdf/rm2pdf -c blue -c red d46ced5f-1b26-431f-bafb-7dc2d68c3f43.pdf \
/tmp/100_planning_comments.pdf
panic: Failed to initialize parser: Failed to read pdf: Failed to read xref table: Expected xref to start with 'xref'.  Got: 47
gitbock commented 4 years ago

Hi,

Yes, I already tried using 2 different color names on the CLI like this:

/opt/rm2pdf/rm2pdf -c Cadetblue -c Indianred -t /opt/rm2pdf/templates/A4.pdf /mnt/daten/temp/aab36d9c-0510-4af1-b5a4-aa7e549b9e8b /mnt/daten/download/test_2_colors.pdf

In the PDF result attached you can see that the fineliner grey (indianred) is still the same color as the black (cadetblue). The grey and black are at no different layers. So the color parameter does not make any difference here.

Never mind! I am glad it's working so good so far :)

Regards

Boris.

Rory Campbell-Lange <notifications@github.com> hat am 19. Januar 2020 22:25 geschrieben:

Hi @gitbock Thanks for your ideas and use of the tool. I'll email you directly when I have time. Great you haven't had any issues converting notebooks at the moment, apart from the fineliner colour problem you mentioned. You can use a different colour for each layer by using a colourname specified at https://godoc.org/golang.org/x/image/colornames. For example rm2pdf -c Cadetblue -c Indianred . Could you let me know if that works for you and suits your use case? I'll have a think about extending the project to include connections to a reMarkable and using the visible name; thanks for those ideas. Some PDFs cause an issue, such as the one below, so great to learn that you haven't had that issue. ~/src/go-rm2pdf/rm2pdf -c blue -c red d46ced5f-1b26-431f-bafb-7dc2d68c3f43.pdf \ /tmp/100_planning_comments.pdf panic: Failed to initialize parser: Failed to read pdf: Failed to read xref table: Expected xref to start with 'xref'. Got: 47

—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or unsubscribe.

phpdave11 commented 4 years ago

This has been fixed in gofpdi. gofpdi v1.0.9 now supports xref streams.