forked from johnfercher/maroto
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request johnfercher#149 from sanderaido/feature/custom-pag…
…e-size Feature/custom page size
- Loading branch information
Showing
6 changed files
with
180 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"github.com/johnfercher/maroto/pkg/consts" | ||
"github.com/johnfercher/maroto/pkg/pdf" | ||
"github.com/johnfercher/maroto/pkg/props" | ||
"os" | ||
"time" | ||
) | ||
|
||
func main() { | ||
begin := time.Now() | ||
m := pdf.NewMarotoCustomSize(consts.Landscape, "C6", "mm", 114.0, 162.0) | ||
m.SetPageMargins(5, 5, 5) | ||
// m.SetBorder(true) | ||
|
||
m.Row(40, func() { | ||
m.Col(4, func() { | ||
_ = m.FileImage("internal/assets/images/biplane.jpg", props.Rect{ | ||
Center: true, | ||
Percent: 50, | ||
}) | ||
}) | ||
m.Col(4, func() { | ||
m.Text("Gopher International Shipping, Inc.", props.Text{ | ||
Top: 12, | ||
Size: 12, | ||
Extrapolate: true, | ||
}) | ||
}) | ||
m.ColSpace(4) | ||
}) | ||
|
||
m.Line(10) | ||
|
||
m.Row(30, func() { | ||
m.Col(12, func() { | ||
m.Text("João Sant'Ana 100 Main Street", props.Text{ | ||
Size: 10, | ||
Align: consts.Right, | ||
}) | ||
m.Text("Springfield TN 39021", props.Text{ | ||
Size: 10, | ||
Align: consts.Right, | ||
Top: 10, | ||
}) | ||
m.Text("United States (USA)", props.Text{ | ||
Size: 10, | ||
Align: consts.Right, | ||
Top: 20, | ||
}) | ||
}) | ||
}) | ||
|
||
err := m.OutputFileAndClose("internal/examples/pdfs/customsize.pdf") | ||
if err != nil { | ||
fmt.Println("Could not save PDF:", err) | ||
os.Exit(1) | ||
} | ||
|
||
end := time.Now() | ||
fmt.Println(end.Sub(begin)) | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters