summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2016-04-26 11:02:17 +0100
committerVincent Sanders <vince@kyllikki.org>2016-04-26 11:02:17 +0100
commitdd14807c8cdff2f486f5da832490ff958c87ba62 (patch)
tree7504ec8d662e6fcd7e2be2ff466fa2b2b79fd44b
parent7ec49463dafc20f915ce68c789f36458579783c3 (diff)
downloadnetsurf-dd14807c8cdff2f486f5da832490ff958c87ba62.tar.gz
netsurf-dd14807c8cdff2f486f5da832490ff958c87ba62.tar.bz2
improve error returns from pdf save API
-rw-r--r--desktop/save_pdf.c18
-rw-r--r--desktop/save_pdf.h2
2 files changed, 10 insertions, 10 deletions
diff --git a/desktop/save_pdf.c b/desktop/save_pdf.c
index c54421cdc..8fd67959f 100644
--- a/desktop/save_pdf.c
+++ b/desktop/save_pdf.c
@@ -784,9 +784,9 @@ void pdf_end(void)
}
/** saves the pdf with optional encryption */
-void save_pdf(const char *path)
+nserror save_pdf(const char *path)
{
- bool success = false;
+ nserror res = NSERROR_OK;
if (option_enable_PDF_password && owner_pass != NULL ) {
HPDF_SetPassword(pdf_doc, owner_pass, user_pass);
@@ -796,17 +796,16 @@ void save_pdf(const char *path)
}
if (path != NULL) {
- if (HPDF_SaveToFile(pdf_doc, path) != HPDF_OK)
+ if (HPDF_SaveToFile(pdf_doc, path) != HPDF_OK) {
remove(path);
- else
- success = true;
+ res = NSERROR_SAVE_FAILED;
+ }
}
- if (!success)
- warn_user("Unable to save PDF file.", 0);
-
HPDF_Free(pdf_doc);
pdf_doc = NULL;
+
+ return res;
}
@@ -982,7 +981,8 @@ void pdfw_gs_dash(HPDF_Page page, DashPattern_e dash)
}
#else
-void save_pdf(const char *path)
+nserror save_pdf(const char *path)
{
+ return NSERROR_NOT_IMPLEMENTED;
}
#endif /* WITH_PDF_EXPORT */
diff --git a/desktop/save_pdf.h b/desktop/save_pdf.h
index d02c356e8..b90c5a969 100644
--- a/desktop/save_pdf.h
+++ b/desktop/save_pdf.h
@@ -36,6 +36,6 @@ bool pdf_next_page(void);
/**Close pdf document and save changes to file*/
void pdf_end(void);
-void save_pdf(const char *path);
+nserror save_pdf(const char *path);
#endif /*NETSURF_PDF_PLOTTERS_H*/