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
2022-01-12 09:03:14 -0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
954ad44f16f8ad9cc045335ce0899ca4b2867751
954ad44f
1 parent
5b7d956e
Lint and update changelog
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
52 additions
and
45 deletions
pdf/lib/src/widgets/annotations.dart
printing/CHANGELOG.md
printing/lib/printing_web.dart
printing/linux/print_job.cc
printing/linux/print_job.h
printing/pubspec.yaml
printing/windows/print_job.cpp
printing/windows/print_job.h
printing/windows/printing.cpp
printing/windows/printing.h
printing/windows/printing_plugin.cpp
pdf/lib/src/widgets/annotations.dart
View file @
954ad44
...
...
@@ -628,7 +628,7 @@ class Outline extends Anchor {
final
root
=
context
.
document
.
outline
;
// find the most recently added outline
var
actualLevel
=
-
1
;
var
actualLevel
=
-
1
;
var
candidate
=
root
;
while
(
candidate
.
outlines
.
isNotEmpty
)
{
candidate
=
candidate
.
outlines
.
last
;
...
...
printing/CHANGELOG.md
View file @
954ad44
# Changelog
## 5.
6.7
## 5.
7.0
-
Fix imports for Dart 2.15
-
Fix print dialog crash on Linux
...
...
@@ -10,6 +10,7 @@
-
Update Google Fonts
-
Add a default theme initializer
-
Use RENDER_MODE_FOR_DISPLAY on Android
-
Enable usage of printer's settings on Windows
[
Alban Lecuivre
]
## 5.6.6
...
...
printing/lib/printing_web.dart
View file @
954ad44
...
...
@@ -65,6 +65,7 @@ class PrintingPlugin extends PrintingPlatform {
String
name
,
PdfPageFormat
format
,
bool
dynamicLayout
,
bool
usePrinterSettings
,
)
async
{
late
Uint8List
result
;
try
{
...
...
printing/linux/print_job.cc
View file @
954ad44
...
...
@@ -202,7 +202,7 @@ bool print_job::print_pdf(const gchar* name,
void
print_job
::
write_job
(
const
uint8_t
data
[],
size_t
size
)
{
auto
fd
=
memfd_create
(
"printing"
,
0
);
size_t
offset
=
0
;
size_t
n
;
s
s
ize_t
n
;
while
((
n
=
write
(
fd
,
data
+
offset
,
size
-
offset
))
>=
0
&&
size
-
offset
>
0
)
{
offset
+=
n
;
...
...
@@ -249,8 +249,8 @@ void print_job::raster_pdf(const uint8_t data[],
double
scale
)
{
FPDF_LIBRARY_CONFIG
config
;
config
.
version
=
2
;
config
.
m_pUserFontPaths
=
NULL
;
config
.
m_pIsolate
=
NULL
;
config
.
m_pUserFontPaths
=
nullptr
;
config
.
m_pIsolate
=
nullptr
;
config
.
m_v8EmbedderSlot
=
0
;
FPDF_InitLibraryWithConfig
(
&
config
);
...
...
printing/linux/print_job.h
View file @
954ad44
...
...
@@ -33,7 +33,7 @@ class print_job {
public
:
GtkPrintUnixDialog
*
dialog
=
nullptr
;
print_job
(
int
index
);
explicit
print_job
(
int
index
);
~
print_job
();
...
...
printing/pubspec.yaml
View file @
954ad44
...
...
@@ -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.7
version
:
5.
7.0
environment
:
sdk
:
"
>=2.12.0
<3.0.0"
...
...
printing/windows/print_job.cpp
View file @
954ad44
...
...
@@ -33,11 +33,12 @@ namespace nfet {
const
auto
pdfDpi
=
72
;
std
::
string
toUtf8
(
std
::
wstring
wstr
)
{
int
cbMultiByte
=
WideCharToMultiByte
(
CP_UTF8
,
0
,
wstr
.
c_str
(),
-
1
,
NULL
,
0
,
NULL
,
NULL
);
int
cbMultiByte
=
WideCharToMultiByte
(
CP_UTF8
,
0
,
wstr
.
c_str
(),
-
1
,
nullptr
,
0
,
nullptr
,
nullptr
);
LPSTR
lpMultiByteStr
=
(
LPSTR
)
malloc
(
cbMultiByte
);
cbMultiByte
=
WideCharToMultiByte
(
CP_UTF8
,
0
,
wstr
.
c_str
(),
-
1
,
lpMultiByteStr
,
cbMultiByte
,
NULL
,
NULL
);
cbMultiByte
=
WideCharToMultiByte
(
CP_UTF8
,
0
,
wstr
.
c_str
(),
-
1
,
lpMultiByteStr
,
cbMultiByte
,
nullptr
,
nullptr
);
std
::
string
ret
=
lpMultiByteStr
;
free
(
lpMultiByteStr
);
return
ret
;
...
...
@@ -73,7 +74,7 @@ std::wstring fromUtf8(std::string str) {
PrintJob
::
PrintJob
(
Printing
*
printing
,
int
index
)
:
printing
{
printing
},
index
{
index
}
{}
bool
PrintJob
::
printPdf
(
std
::
string
name
,
bool
PrintJob
::
printPdf
(
const
std
::
string
&
name
,
std
::
string
printer
,
double
width
,
double
height
,
...
...
@@ -81,13 +82,14 @@ bool PrintJob::printPdf(std::string name,
documentName
=
name
;
auto
dm
=
static_cast
<
DEVMODE
*>
(
GlobalAlloc
(
0
,
sizeof
(
DEVMODE
)));
if
(
usePrinterSettings
){
dm
=
NULL
;
// to use default driver config
if
(
usePrinterSettings
)
{
dm
=
nullptr
;
// to use default driver config
}
else
{
ZeroMemory
(
dm
,
sizeof
(
DEVMODE
));
dm
->
dmSize
=
sizeof
(
DEVMODE
);
dm
->
dmFields
=
DM_ORIENTATION
|
DM_PAPERSIZE
|
DM_PAPERLENGTH
|
DM_PAPERWIDTH
;
dm
->
dmFields
=
DM_ORIENTATION
|
DM_PAPERSIZE
|
DM_PAPERLENGTH
|
DM_PAPERWIDTH
;
dm
->
dmPaperSize
=
0
;
if
(
width
>
height
)
{
dm
->
dmOrientation
=
DMORIENT_LANDSCAPE
;
...
...
@@ -99,7 +101,6 @@ bool PrintJob::printPdf(std::string name,
dm
->
dmPaperLength
=
static_cast
<
short
>
(
round
(
height
*
254
/
72
));
}
}
if
(
printer
.
empty
())
{
PRINTDLG
pd
;
...
...
@@ -136,7 +137,7 @@ bool PrintJob::printPdf(std::string name,
hDevNames
=
pd
.
hDevNames
;
}
else
{
hDC
=
CreateDC
(
TEXT
(
"WINSPOOL"
),
fromUtf8
(
printer
).
c_str
(),
NULL
,
dm
);
hDC
=
CreateDC
(
TEXT
(
"WINSPOOL"
),
fromUtf8
(
printer
).
c_str
(),
nullptr
,
dm
);
if
(
!
hDC
)
{
return
false
;
}
...
...
@@ -227,8 +228,8 @@ void PrintJob::writeJob(std::vector<uint8_t> data) {
FPDF_LIBRARY_CONFIG
config
;
config
.
version
=
2
;
config
.
m_pUserFontPaths
=
NULL
;
config
.
m_pIsolate
=
NULL
;
config
.
m_pUserFontPaths
=
nullptr
;
config
.
m_pIsolate
=
nullptr
;
config
.
m_v8EmbedderSlot
=
0
;
FPDF_InitLibraryWithConfig
(
&
config
);
...
...
@@ -243,7 +244,7 @@ void PrintJob::writeJob(std::vector<uint8_t> data) {
auto
marginTop
=
GetDeviceCaps
(
hDC
,
PHYSICALOFFSETY
);
for
(
auto
pageNum
=
0
;
pageNum
<
pages
;
pageNum
++
)
{
r
=
StartPage
(
hDC
);
StartPage
(
hDC
);
auto
page
=
FPDF_LoadPage
(
doc
,
pageNum
);
if
(
!
page
)
{
...
...
@@ -266,7 +267,7 @@ void PrintJob::writeJob(std::vector<uint8_t> data) {
FPDF_CloseDocument
(
doc
);
FPDF_DestroyLibrary
();
r
=
EndDoc
(
hDC
);
EndDoc
(
hDC
);
DeleteDC
(
hDC
);
GlobalFree
(
hDevNames
);
...
...
@@ -275,9 +276,9 @@ void PrintJob::writeJob(std::vector<uint8_t> data) {
printing
->
onCompleted
(
this
,
true
,
""
);
}
void
PrintJob
::
cancelJob
(
std
::
string
error
)
{}
void
PrintJob
::
cancelJob
(
const
std
::
string
&
error
)
{}
bool
PrintJob
::
sharePdf
(
std
::
vector
<
uint8_t
>
data
,
std
::
string
name
)
{
bool
PrintJob
::
sharePdf
(
std
::
vector
<
uint8_t
>
data
,
const
std
::
string
&
name
)
{
TCHAR
lpTempPathBuffer
[
MAX_PATH
];
auto
ret
=
GetTempPath
(
MAX_PATH
,
lpTempPathBuffer
);
...
...
@@ -294,14 +295,14 @@ bool PrintJob::sharePdf(std::vector<uint8_t> data, std::string name) {
SHELLEXECUTEINFO
ShExecInfo
;
ShExecInfo
.
cbSize
=
sizeof
(
SHELLEXECUTEINFO
);
ShExecInfo
.
fMask
=
NULL
;
ShExecInfo
.
hwnd
=
NULL
;
ShExecInfo
.
fMask
=
0
;
ShExecInfo
.
hwnd
=
nullptr
;
ShExecInfo
.
lpVerb
=
TEXT
(
"open"
);
ShExecInfo
.
lpFile
=
filename
.
c_str
();
ShExecInfo
.
lpParameters
=
NULL
;
ShExecInfo
.
lpDirectory
=
NULL
;
ShExecInfo
.
lpParameters
=
nullptr
;
ShExecInfo
.
lpDirectory
=
nullptr
;
ShExecInfo
.
nShow
=
SW_SHOWDEFAULT
;
ShExecInfo
.
hInstApp
=
NULL
;
ShExecInfo
.
hInstApp
=
nullptr
;
ret
=
ShellExecuteEx
(
&
ShExecInfo
);
...
...
@@ -315,8 +316,8 @@ void PrintJob::rasterPdf(std::vector<uint8_t> data,
double
scale
)
{
FPDF_LIBRARY_CONFIG
config
;
config
.
version
=
2
;
config
.
m_pUserFontPaths
=
NULL
;
config
.
m_pIsolate
=
NULL
;
config
.
m_pUserFontPaths
=
nullptr
;
config
.
m_pIsolate
=
nullptr
;
config
.
m_v8EmbedderSlot
=
0
;
FPDF_InitLibraryWithConfig
(
&
config
);
...
...
printing/windows/print_job.h
View file @
954ad44
...
...
@@ -39,11 +39,11 @@ struct Printer {
const
bool
default
;
const
bool
available
;
Printer
(
std
::
string
name
,
std
::
string
url
,
std
::
string
model
,
std
::
string
location
,
std
::
string
comment
,
Printer
(
const
std
::
string
&
name
,
const
std
::
string
&
url
,
const
std
::
string
&
model
,
const
std
::
string
&
location
,
const
std
::
string
&
comment
,
bool
default
,
bool
available
)
:
name
(
name
),
...
...
@@ -71,7 +71,7 @@ class PrintJob {
std
::
vector
<
Printer
>
listPrinters
();
bool
printPdf
(
std
::
string
name
,
bool
printPdf
(
const
std
::
string
&
name
,
std
::
string
printer
,
double
width
,
double
height
,
...
...
@@ -79,9 +79,9 @@ class PrintJob {
void
writeJob
(
std
::
vector
<
uint8_t
>
data
);
void
cancelJob
(
std
::
string
error
);
void
cancelJob
(
const
std
::
string
&
error
);
bool
sharePdf
(
std
::
vector
<
uint8_t
>
data
,
std
::
string
name
);
bool
sharePdf
(
std
::
vector
<
uint8_t
>
data
,
const
std
::
string
&
name
);
void
pickPrinter
(
void
*
result
);
...
...
printing/windows/printing.cpp
View file @
954ad44
...
...
@@ -44,7 +44,7 @@ void Printing::onPageRasterized(std::vector<uint8_t> data,
})));
}
void
Printing
::
onPageRasterEnd
(
PrintJob
*
job
,
const
std
::
string
error
)
{
void
Printing
::
onPageRasterEnd
(
PrintJob
*
job
,
const
std
::
string
&
error
)
{
auto
map
=
flutter
::
EncodableMap
{
{
flutter
::
EncodableValue
(
"job"
),
flutter
::
EncodableValue
(
job
->
id
())},
};
...
...
@@ -111,7 +111,9 @@ void Printing::onLayout(PrintJob* job,
}
// send completion status to flutter
void
Printing
::
onCompleted
(
PrintJob
*
job
,
bool
completed
,
std
::
string
error
)
{
void
Printing
::
onCompleted
(
PrintJob
*
job
,
bool
completed
,
const
std
::
string
&
error
)
{
auto
map
=
flutter
::
EncodableMap
{
{
flutter
::
EncodableValue
(
"job"
),
flutter
::
EncodableValue
(
job
->
id
())},
{
flutter
::
EncodableValue
(
"completed"
),
...
...
printing/windows/printing.h
View file @
954ad44
...
...
@@ -40,7 +40,7 @@ class Printing {
int
height
,
PrintJob
*
job
);
void
onPageRasterEnd
(
PrintJob
*
job
,
const
std
::
string
error
);
void
onPageRasterEnd
(
PrintJob
*
job
,
const
std
::
string
&
error
);
void
onLayout
(
PrintJob
*
job
,
double
pageWidth
,
...
...
@@ -52,7 +52,7 @@ class Printing {
void
Printing
::
onCompleted
(
PrintJob
*
job
,
bool
completed
,
const
std
::
string
error
);
const
std
::
string
&
error
);
};
}
// namespace nfet
...
...
printing/windows/printing_plugin.cpp
View file @
954ad44
...
...
@@ -79,11 +79,13 @@ class PrintingPlugin : public flutter::Plugin {
auto
height
=
std
::
get
<
double
>
(
arguments
->
find
(
flutter
::
EncodableValue
(
"height"
))
->
second
);
auto
usePrinterSettings
=
std
::
get
<
bool
>
(
arguments
->
find
(
flutter
::
EncodableValue
(
"usePrinterSettings"
))
->
second
);
arguments
->
find
(
flutter
::
EncodableValue
(
"usePrinterSettings"
))
->
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
,
width
,
height
,
usePrinterSettings
);
auto
res
=
job
->
printPdf
(
name
,
printer
,
width
,
height
,
usePrinterSettings
);
if
(
!
res
)
{
delete
job
;
}
...
...
Please
register
or
login
to post a comment