-
Notifications
You must be signed in to change notification settings - Fork 510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question / Comment: How to view insertPDF progress #640
Comments
This a C function, so that one would have to be modified. |
where can i find the c function file. |
You have to modify |
What is your system config? |
I am using archlinux. I tried to change the void JM_merge_range(fz_context *ctx, pdf_document *doc_des, pdf_document *doc_src, int spage, int epage, int apage, int rotate, int links, int annots)
{
int page, afterpage;
pdf_graft_map *graft_map;
afterpage = apage;
graft_map = pdf_new_graft_map(ctx, doc_des);
fz_try(ctx) {
if (spage < epage) {
for (page = spage; page <= epage; page++, afterpage++)
page_merge(ctx, doc_des, doc_src, page, afterpage, rotate, links, annots, graft_map);
// CODE ADDED
if( page % 500 == 0){
printf("CURRENT PAGES %d / %d",page,epage);
fflush(stdout);
}
} else {
for (page = spage; page >= epage; page--, afterpage++)
page_merge(ctx, doc_des, doc_src, page, afterpage, rotate, links, annots, graft_map);
// CODE ADDED
if( page % 500 == 0){
printf("CURRENT PAGES %d / %d",page,epage);
fflush(stdout);
}
}
} This is from the PyMupdf-1.17.5 (https://files.pythonhosted.org/packages/source/P/PyMuPDF/PyMuPDF-1.17.5.tar.gz) Now i run the below python script
I am expecting the printf command to be shown from the c library. Why its not working |
You found the right place to modify! void JM_merge_range(fz_context *ctx, pdf_document *doc_des, pdf_document *doc_src, int spage, int epage, int apage, int rotate, int links, int annots, int show_progress)
{
int page, afterpage;
pdf_graft_map *graft_map;
afterpage = apage;
graft_map = pdf_new_graft_map(ctx, doc_des);
int counter = 0; // copied page counter
int total = fz_absi(epage - spage) + 1; // total pages to copy
fz_try(ctx) {
if (spage < epage) {
for (page = spage; page <= epage; page++, afterpage++) {
page_merge(ctx, doc_des, doc_src, page, afterpage, rotate, links, annots, graft_map);
counter ++;
if (show_progress > 0 && counter % show_progress == 0) {
PySys_WriteStdout("Inserted %i of %i pages.\n", counter, total);
}
}
} else {
for (page = spage; page >= epage; page--, afterpage++) {
page_merge(ctx, doc_des, doc_src, page, afterpage, rotate, links, annots, graft_map);
counter ++;
if (show_progress > 0 && counter % show_progress == 0) {
PySys_WriteStdout("Inserted %i of %i pages.\n", counter, total);
}
}
}
}
fz_always(ctx) {
pdf_drop_graft_map(ctx, graft_map);
}
fz_catch(ctx) {
fz_rethrow(ctx);
}
} |
Thank you. Also can i show the src filename and also destination filename eg:
With the c code changes no it looks like this
Can we show file name here like
|
The next version will also show file information.
|
But this will print only once. and will be lost in the print statements. in
I tried
how to show in this function. |
There is no way to do that currently. |
New version 1.17.7 is currently being uploaded. |
I saw the code inside
insertPDF
infitz.py
it uses_fitz.Document_insertPDF(self, docsrc, from_page, to_page, start_at, rotate, links, annots)
I have very large documents of 100,000 pages. I want to see somprogress if possible after inserting every
1000/5000 pages
How can i send some logging messages to the python code from
_fitz.Document_insertPDF
function after every1000/5000
pages of insertion.Anything i can change in the source code and then recompile it.
Else the option is keep inserting 5000 pages at a time by mentioning the start and and page
The text was updated successfully, but these errors were encountered: