mirror of
https://github.com/fumiama/go-docx.git
synced 2026-06-04 23:30:25 +08:00
rename package to docx
This commit is contained in:
@@ -4,7 +4,7 @@ linters-settings:
|
||||
ignoretests: true
|
||||
|
||||
goimports:
|
||||
local-prefixes: github.com/fumiama/docxlib
|
||||
local-prefixes: github.com/fumiama/go-docx
|
||||
|
||||
forbidigo:
|
||||
# Forbid the following identifiers
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package docxlib
|
||||
package docx
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package docxlib
|
||||
package docx
|
||||
|
||||
//nolint:revive,stylecheck
|
||||
const (
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package docxlib
|
||||
package docx
|
||||
|
||||
import "unsafe"
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package docxlib
|
||||
package docx
|
||||
|
||||
// Color allows to set run color
|
||||
func (r *Run) Color(color string) *Run {
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package docxlib
|
||||
package docx
|
||||
|
||||
import "unsafe"
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package docxlib
|
||||
package docx
|
||||
|
||||
import "strings"
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/fumiama/docxlib"
|
||||
"github.com/fumiama/go-docx"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -35,21 +35,21 @@ func main() {
|
||||
analyzeOnly := flag.Bool("a", false, "analyze file only")
|
||||
unm := flag.Bool("u", false, "lease unmarshalled file")
|
||||
flag.Parse()
|
||||
var w *docxlib.Docx
|
||||
var w *docx.Docx
|
||||
if !*analyzeOnly {
|
||||
fmt.Printf("Preparing new document to write at %s\n", *fileLocation)
|
||||
|
||||
w = docxlib.NewA4()
|
||||
w = docx.NewA4()
|
||||
// add new paragraph
|
||||
para1 := w.AddParagraph().Justification("distribute")
|
||||
r, err := para1.AddAnchorDrawingFrom("testdata/fumiama.JPG")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
r.Children[0].(*docxlib.Drawing).Anchor.Size(r.Children[0].(*docxlib.Drawing).Anchor.Extent.CX/4, r.Children[0].(*docxlib.Drawing).Anchor.Extent.CY/4)
|
||||
r.Children[0].(*docxlib.Drawing).Anchor.BehindDoc = 1
|
||||
r.Children[0].(*docxlib.Drawing).Anchor.PositionH.PosOffset = r.Children[0].(*docxlib.Drawing).Anchor.Extent.CX
|
||||
r.Children[0].(*docxlib.Drawing).Anchor.Graphic.GraphicData.Pic.BlipFill.Blip.AlphaModFix = &docxlib.AAlphaModFix{Amount: 50000}
|
||||
r.Children[0].(*docx.Drawing).Anchor.Size(r.Children[0].(*docx.Drawing).Anchor.Extent.CX/4, r.Children[0].(*docx.Drawing).Anchor.Extent.CY/4)
|
||||
r.Children[0].(*docx.Drawing).Anchor.BehindDoc = 1
|
||||
r.Children[0].(*docx.Drawing).Anchor.PositionH.PosOffset = r.Children[0].(*docx.Drawing).Anchor.Extent.CX
|
||||
r.Children[0].(*docx.Drawing).Anchor.Graphic.GraphicData.Pic.BlipFill.Blip.AlphaModFix = &docx.AAlphaModFix{Amount: 50000}
|
||||
// add text
|
||||
para1.AddText("test")
|
||||
para1.AddText("test font size").Size("44")
|
||||
@@ -70,13 +70,13 @@ func main() {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
r.Children[0].(*docxlib.Drawing).Inline.Size(r.Children[0].(*docxlib.Drawing).Inline.Extent.CX*4/5, r.Children[0].(*docxlib.Drawing).Inline.Extent.CY*4/5)
|
||||
r.Children[0].(*docx.Drawing).Inline.Size(r.Children[0].(*docx.Drawing).Inline.Extent.CX*4/5, r.Children[0].(*docx.Drawing).Inline.Extent.CY*4/5)
|
||||
para4.AddTab().AddTab()
|
||||
r, err = para4.AddInlineDrawingFrom("testdata/fumiama2x.webp")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
r.Children[0].(*docxlib.Drawing).Inline.Size(r.Children[0].(*docxlib.Drawing).Inline.Extent.CX*4/5, r.Children[0].(*docxlib.Drawing).Inline.Extent.CY*4/5)
|
||||
r.Children[0].(*docx.Drawing).Inline.Size(r.Children[0].(*docx.Drawing).Inline.Extent.CX*4/5, r.Children[0].(*docx.Drawing).Inline.Extent.CY*4/5)
|
||||
|
||||
para5 := w.AddParagraph().Justification("center")
|
||||
// add text
|
||||
@@ -101,7 +101,7 @@ func main() {
|
||||
for x, r := range tbl2.TableRows {
|
||||
r.Justification("center")
|
||||
for y, c := range r.TableCells {
|
||||
c.TableCellProperties.VAlign = &docxlib.WVerticalAlignment{Val: "center"}
|
||||
c.TableCellProperties.VAlign = &docx.WVerticalAlignment{Val: "center"}
|
||||
c.AddParagraph().Justification("center").AddText(fmt.Sprintf("(%d, %d)", x, y))
|
||||
}
|
||||
}
|
||||
@@ -131,7 +131,7 @@ func main() {
|
||||
panic(err)
|
||||
}
|
||||
size := fileinfo.Size()
|
||||
doc, err := docxlib.Parse(readFile, size)
|
||||
doc, err := docx.Parse(readFile, size)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -154,9 +154,9 @@ func main() {
|
||||
fmt.Println("Plain text:")
|
||||
for _, it := range doc.Document.Body.Items {
|
||||
switch para := it.(type) {
|
||||
case docxlib.Paragraph:
|
||||
case docx.Paragraph:
|
||||
fmt.Println(para.String())
|
||||
case docxlib.WTable:
|
||||
case docx.WTable:
|
||||
fmt.Println("------------------------------")
|
||||
for x, r := range para.TableRows {
|
||||
fmt.Printf("[%d] ", x)
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// Package docxlib is one of the most functional libraries to read and write .docx
|
||||
// package docx is one of the most functional libraries to read and write .docx
|
||||
// (a.k.a. Microsoft Word documents or ECMA-376 Office Open XML) files in Go.
|
||||
package docxlib
|
||||
package docx
|
||||
|
||||
import (
|
||||
"archive/zip"
|
||||
|
||||
2
empty.go
2
empty.go
@@ -18,7 +18,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package docxlib
|
||||
package docx
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
2
fs.go
2
fs.go
@@ -18,7 +18,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package docxlib
|
||||
package docx
|
||||
|
||||
import "embed"
|
||||
|
||||
|
||||
2
go.mod
2
go.mod
@@ -1,4 +1,4 @@
|
||||
module github.com/fumiama/docxlib
|
||||
module github.com/fumiama/go-docx
|
||||
|
||||
go 1.18
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package docxlib
|
||||
package docx
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
2
image.go
2
image.go
@@ -18,7 +18,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package docxlib
|
||||
package docx
|
||||
|
||||
// addImage add image to docx and return its rId
|
||||
func (f *Docx) addImage(m Media) string {
|
||||
|
||||
2
link.go
2
link.go
@@ -18,7 +18,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package docxlib
|
||||
package docx
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
2
media.go
2
media.go
@@ -18,7 +18,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package docxlib
|
||||
package docx
|
||||
|
||||
//nolint:revive,stylecheck
|
||||
const MEDIA_FOLDER = `word/media/`
|
||||
|
||||
2
pack.go
2
pack.go
@@ -18,7 +18,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package docxlib
|
||||
package docx
|
||||
|
||||
import (
|
||||
"archive/zip"
|
||||
|
||||
2
slice.go
2
slice.go
@@ -18,7 +18,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package docxlib
|
||||
package docx
|
||||
|
||||
import "unsafe"
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package docxlib
|
||||
package docx
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package docxlib
|
||||
package docx
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package docxlib
|
||||
package docx
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package docxlib
|
||||
package docx
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package docxlib
|
||||
package docx
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package docxlib
|
||||
package docx
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package docxlib
|
||||
package docx
|
||||
|
||||
//nolint:revive,stylecheck
|
||||
const (
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package docxlib
|
||||
package docx
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package docxlib
|
||||
package docx
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package docxlib
|
||||
package docx
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package docxlib
|
||||
package docx
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package docxlib
|
||||
package docx
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
|
||||
Reference in New Issue
Block a user