Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
dart_pdf
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
David PHAM-VAN
2021-11-22 22:44:53 -0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
68447c438a4f1b21b9c44bb019a6d0fb6ab3b5d1
68447c43
1 parent
a0925437
Fix Windows initial page format
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
35 additions
and
10 deletions
printing/CHANGELOG.md
printing/pubspec.yaml
printing/windows/print_job.cpp
printing/windows/print_job.h
printing/windows/printing_plugin.cpp
printing/CHANGELOG.md
View file @
68447c4
# Changelog
## 5.6.4
-
Fix Windows initial page format
## 5.6.3
-
Fix Windows string encoding
...
...
printing/pubspec.yaml
View file @
68447c4
...
...
@@ -6,7 +6,7 @@ description: >
homepage
:
https://github.com/DavBfr/dart_pdf/tree/master/printing
repository
:
https://github.com/DavBfr/dart_pdf
issue_tracker
:
https://github.com/DavBfr/dart_pdf/issues
version
:
5.6.
3
version
:
5.6.
4
environment
:
sdk
:
"
>=2.12.0
<3.0.0"
...
...
printing/windows/print_job.cpp
View file @
68447c4
...
...
@@ -73,15 +73,29 @@ std::wstring fromUtf8(std::string str) {
PrintJob
::
PrintJob
(
Printing
*
printing
,
int
index
)
:
printing
{
printing
},
index
{
index
}
{}
bool
PrintJob
::
printPdf
(
std
::
string
name
,
std
::
string
printer
)
{
bool
PrintJob
::
printPdf
(
std
::
string
name
,
std
::
string
printer
,
double
width
,
double
height
)
{
documentName
=
name
;
auto
dm
=
static_cast
<
DEVMODE
*>
(
GlobalAlloc
(
0
,
sizeof
(
DEVMODE
)));
ZeroMemory
(
dm
,
sizeof
(
DEVMODE
));
dm
->
dmSize
=
sizeof
(
DEVMODE
);
dm
->
dmFields
=
DM_ORIENTATION
|
DM_PAPERSIZE
|
DM_PAPERLENGTH
|
DM_PAPERWIDTH
;
dm
->
dmPaperSize
=
0
;
if
(
width
>
height
)
{
dm
->
dmOrientation
=
DMORIENT_LANDSCAPE
;
dm
->
dmPaperWidth
=
static_cast
<
short
>
(
round
(
height
*
254
/
72
));
dm
->
dmPaperLength
=
static_cast
<
short
>
(
round
(
width
*
254
/
72
));
}
else
{
dm
->
dmOrientation
=
DMORIENT_PORTRAIT
;
dm
->
dmPaperWidth
=
static_cast
<
short
>
(
round
(
width
*
254
/
72
));
dm
->
dmPaperLength
=
static_cast
<
short
>
(
round
(
height
*
254
/
72
));
}
if
(
printer
.
empty
())
{
PRINTDLG
pd
;
DEVMODE
*
dm
=
static_cast
<
DEVMODE
*>
(
GlobalAlloc
(
0
,
sizeof
(
DEVMODE
)));
ZeroMemory
(
dm
,
sizeof
(
DEVMODE
));
dm
->
dmFields
=
DM_ORIENTATION
;
dm
->
dmOrientation
=
2
;
// Initialize PRINTDLG
ZeroMemory
(
&
pd
,
sizeof
(
pd
));
...
...
@@ -115,11 +129,11 @@ bool PrintJob::printPdf(std::string name, std::string printer) {
hDevNames
=
pd
.
hDevNames
;
}
else
{
hDC
=
CreateDC
(
TEXT
(
"WINSPOOL"
),
fromUtf8
(
printer
).
c_str
(),
NULL
,
NULL
);
hDC
=
CreateDC
(
TEXT
(
"WINSPOOL"
),
fromUtf8
(
printer
).
c_str
(),
NULL
,
dm
);
if
(
!
hDC
)
{
return
false
;
}
hDevMode
=
nullptr
;
hDevMode
=
dm
;
hDevNames
=
nullptr
;
}
...
...
printing/windows/print_job.h
View file @
68447c4
...
...
@@ -71,7 +71,10 @@ class PrintJob {
std
::
vector
<
Printer
>
listPrinters
();
bool
printPdf
(
std
::
string
name
,
std
::
string
printer
);
bool
printPdf
(
std
::
string
name
,
std
::
string
printer
,
double
width
,
double
height
);
void
writeJob
(
std
::
vector
<
uint8_t
>
data
);
...
...
printing/windows/printing_plugin.cpp
View file @
68447c4
...
...
@@ -74,10 +74,14 @@ class PrintingPlugin : public flutter::Plugin {
auto
printer
=
vPrinter
!=
arguments
->
end
()
?
std
::
get
<
std
::
string
>
(
vPrinter
->
second
)
:
std
::
string
{};
auto
width
=
std
::
get
<
double
>
(
arguments
->
find
(
flutter
::
EncodableValue
(
"width"
))
->
second
);
auto
height
=
std
::
get
<
double
>
(
arguments
->
find
(
flutter
::
EncodableValue
(
"height"
))
->
second
);
auto
vJob
=
arguments
->
find
(
flutter
::
EncodableValue
(
"job"
));
auto
jobNum
=
vJob
!=
arguments
->
end
()
?
std
::
get
<
int
>
(
vJob
->
second
)
:
-
1
;
auto
job
=
new
PrintJob
{
&
printing
,
jobNum
};
auto
res
=
job
->
printPdf
(
name
,
printer
);
auto
res
=
job
->
printPdf
(
name
,
printer
,
width
,
height
);
if
(
!
res
)
{
delete
job
;
}
...
...
Please
register
or
login
to post a comment