Code Monkey home page Code Monkey logo

go-libreofficekit's People

Contributors

acaloiaro avatar dveselov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-libreofficekit's Issues

Unfreed memory usage

I have a problem where i push hundreds of .fodt => .pdf files through this loop and get a ~.5MiB extra memory usage per file and it is not feed (so not gc).
Moving office into the loop explodes the memory usage over time so i'm out of ides. Am i doing something wrong here or is something related to the document not freed on doc.Close()?

type Request struct {
	SourceFile string
	TargetFile string
	TargetExt  string
	Filter     string
	done       chan bool
}

var request chan *Request

func office() {
	office, err := libreofficekit.NewOffice("/usr/lib/libreoffice/program")
	if err != nil {
		log.Fatal(err)
	}
	defer office.Close()

	for {
		select {
		case r := <-request:
			doc, err := office.LoadDocument(r.SourceFile)
			if err != nil {
				office.GetError()
				r.done <- true
				continue
			}
			defer doc.close()

			if err := doc.SaveAs(r.TargetFile, r.TargetExt, r.Filter); err != nil {
				r.done <- true
				continue
			}

			r.done <- true
		}
	}
}

fatal error: LibreOfficeKit/LibreOfficeKitInit.h: No such file or directory

import (
"github.com/dveselov/go-libreofficekit"
"testing"
)

func TestLibreoffice(t *testing.T) {
office, _ := libreofficekit.NewOffice("C:\Program Files\LibreOffice\program\soffice.exe")

document, _ := office.LoadDocument("d:/aa.docx")
document.SaveAs("d:/aa.pdf", "pdf", "skipImages")

document.Close()
office.Close()

}

fatal error: LibreOfficeKit/LibreOfficeKitInit.h: No such file or directory

Full option filters like "skipImages"

Hi,

Where can I find the full list of options like "skipImages" as seen in the following code?

document.SaveAs("kittens.pdf", "pdf", "skipImages")

E.x: If I want to embed images into the exported PDF file, which option do I should use?

Thanks

No named member error using Docker

I using a mac but trying to run this inside a docker. While building the app I get the error as shown below.

# github.com/dveselov/go-libreofficekit
In file included from /go/src/github.com/dveselov/go-libreofficekit/libreofficekit.go:6:0:
/go/src/github.com/dveselov/go-libreofficekit/lokbridge.h: In function 'get_views_count':
/go/src/github.com/dveselov/go-libreofficekit/lokbridge.h:70:25: error: 'LibreOfficeKitDocumentClass {aka struct _LibreOfficeKitDocumentClass}' has no member named 'getViewsCount'; did you mean 'getViews'?
     return pThis->pClass->getViewsCount(pThis);

How to convert the pdf support chinese ?

hi dve.
How to convert the pdf support chinese ?

func main() {
office, _ := libreofficekit.NewOffice("/usr/lib/libreoffice/program/")

document, _ := office.LoadDocument("test.docx")
document.SaveAs("test.pdf", "pdf", "skipImages")

document.Close()
office.Close()

}

Thanks a lot and look forward to hearing from you soon.
Best Regards,
jjw

fatal error: non-Go code set up signal handler without SA_ONSTACK flag

Using go-libreofficekit I have this error message coming up:

signal 23 received but handler not on signal stack
fatal error: non-Go code set up signal handler without SA_ONSTACK flag

runtime stack:
runtime: unexpected return pc for runtime.sigtramp called from 0x7f25a7ad1228
stack: frame={sp:0xc000078ed8, fp:0xc000078f30} stack=[0xc000070e08,0xc000079208)

To avoid it I had to recompile libreoffice with the following patch:

diff --git a/sal/osl/unx/signal.cxx b/sal/osl/unx/signal.cxx
index 79721def6c5e..0694fc3c7b26 100644
--- a/sal/osl/unx/signal.cxx
+++ b/sal/osl/unx/signal.cxx
@@ -197,7 +197,7 @@ bool onInitSignal()
 
     struct sigaction act;
     act.sa_sigaction = signalHandlerFunction;
-    act.sa_flags = SA_RESTART | SA_SIGINFO;
+    act.sa_flags = SA_RESTART | SA_SIGINFO | SA_ONSTACK;
 
     sigfillset(&(act.sa_mask));

I will attempt to report the problem to the libreoffice project but meanwhile we have a workaround.

How to install on OSX ?

x-MacBook-Pro:cmd apple$ go get -u github.com/dveselov/go-libreofficekit/...
# github.com/dveselov/go-libreofficekit
In file included from ../../../../../dveselov/go-libreofficekit/libreofficekit.go:6:
../../../../../dveselov/go-libreofficekit/lokbridge.h:2:10: fatal error: 'LibreOfficeKit/LibreOfficeKitInit.h' file not found
#include "LibreOfficeKit/LibreOfficeKitInit.h"
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.


About newOffice path

the path should be the docx path or others?
pull the docxPath will export the nil pointers:

root@800-180329-PC:/usr/local/GoWorkspace# go run packageMain.go
installation path "usr/local/GoWorkspace/" does not exist
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x488ec3]

goroutine 1 [running]:
_/usr/local/GoWorkspace/libreofficekit.(*Office).LoadDocument(0x0, 0x4bc8db, 0x9, 0x0, 0x0, 0x0)
/usr/local/GoWorkspace/libreofficekit/libreofficekit.go:78 +0x93
main.main()
/usr/local/GoWorkspace/packageMain.go:7 +0x62
exit status 2
root@800-180329-PC:/usr/local/GoWorkspace#

the docx path is :/usr/local/GoWorkspace/test.docx
root@800-180329-PC:/usr/local/GoWorkspace# ls
libreofficekit packageMain.go packageMain.sublime-workspace test.docx

thankyou!!!

Exchanging words in word but converted pdf is same

hi dve.
Why I exchanging words in word but converted pdf always same at all.
But when I restart Ubuntu,the program convert the new pdf what I exchanging words.

If the Ubuntu does not restart.How to solve this problem.

func main() {
office, _ := libreofficekit.NewOffice("/usr/lib/libreoffice/program/")

document, _ := office.LoadDocument("test.docx")
document.SaveAs("test.pdf", "pdf", "skipImages")

document.Close()
office.Close()
}

Thanks a lot and look forward to hearing from you soon.
Best Regards,
jjw

Missing c library/s

Went to build this but realised the c files are missing.
Is there a link to them somewhere?

Debian stretch (stable) compile error

Hi ...
I tried to install this nice go pkg on my debian stable, that uses libreofficekit-dev 5.2.7, but this error happend.

./lokbridge.h: In function 'get_views_count':
./lokbridge.h:70:25: error: 'LibreOfficeKitDocumentClass {aka struct _LibreOfficeKitDocumentClass}' has no member named 'getViewsCount'; did you mean 'getViews'?
     return pThis->pClass->getViewsCount(pThis);
                         ^~

What versions are needed of this lib in order to make this compile ?

How to retain URLs when calling document.SaveAs

When I use document.SaveAs with "pdf" as the extension (and a .docx as the input file), the URL links are stripped:

// SaveAs saves document at desired path in desired format with applied filter rules
// Actual (from libreoffice) error message can be read with Office.GetError
func (document *Document) SaveAs(path string, format string, filter string) error {
	cPath := C.CString(path)
	defer C.free(unsafe.Pointer(cPath))
	cFormat := C.CString(format)
	defer C.free(unsafe.Pointer(cFormat))
	cFilter := C.CString(filter)
	defer C.free(unsafe.Pointer(cFilter))
	status := C.document_save(document.handle, cPath, cFormat, cFilter)
	if status != 1 {
		return fmt.Errorf("Failed to save document")
	}
	return nil
}

Is it possible to retain these with a filter option?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.