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 */
|
/** 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 ) {
|
if (option_enable_PDF_password && owner_pass != NULL ) {
|
||||||
HPDF_SetPassword(pdf_doc, owner_pass, user_pass);
|
HPDF_SetPassword(pdf_doc, owner_pass, user_pass);
|
||||||
@ -796,17 +796,16 @@ void save_pdf(const char *path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (path != NULL) {
|
if (path != NULL) {
|
||||||
if (HPDF_SaveToFile(pdf_doc, path) != HPDF_OK)
|
if (HPDF_SaveToFile(pdf_doc, path) != HPDF_OK) {
|
||||||
remove(path);
|
remove(path);
|
||||||
else
|
res = NSERROR_SAVE_FAILED;
|
||||||
success = true;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!success)
|
|
||||||
warn_user("Unable to save PDF file.", 0);
|
|
||||||
|
|
||||||
HPDF_Free(pdf_doc);
|
HPDF_Free(pdf_doc);
|
||||||
pdf_doc = NULL;
|
pdf_doc = NULL;
|
||||||
|
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -982,7 +981,8 @@ void pdfw_gs_dash(HPDF_Page page, DashPattern_e dash)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
void save_pdf(const char *path)
|
nserror save_pdf(const char *path)
|
||||||
{
|
{
|
||||||
|
return NSERROR_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
#endif /* WITH_PDF_EXPORT */
|
#endif /* WITH_PDF_EXPORT */
|
||||||
|
@ -36,6 +36,6 @@ bool pdf_next_page(void);
|
|||||||
/**Close pdf document and save changes to file*/
|
/**Close pdf document and save changes to file*/
|
||||||
void pdf_end(void);
|
void pdf_end(void);
|
||||||
|
|
||||||
void save_pdf(const char *path);
|
nserror save_pdf(const char *path);
|
||||||
|
|
||||||
#endif /*NETSURF_PDF_PLOTTERS_H*/
|
#endif /*NETSURF_PDF_PLOTTERS_H*/
|
||||||
|
Loading…
Reference in New Issue
Block a user