mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-11-22 06:21:45 +03:00
improve error returns from pdf save API
This commit is contained in:
parent
7ec49463da
commit
dd14807c8c
@ -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 */
|
||||
|
@ -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*/
|
||||
|
Loading…
Reference in New Issue
Block a user