Skip to content
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

一个无法转的CAJ格式样本,PyPDF2似乎有bug #49

Open
jsbyysheng opened this issue Jun 27, 2020 · 8 comments
Open

一个无法转的CAJ格式样本,PyPDF2似乎有bug #49

jsbyysheng opened this issue Jun 27, 2020 · 8 comments

Comments

@jsbyysheng
Copy link

PyPDF2似乎有bug,样本(度盘)及提取码: qvbm

@jsbyysheng
Copy link
Author

I am sure this problem is associated with PyPDF2. I have tried the c rewrite version produced by @austerios in #45 and it worked well.

@HinTak
Copy link
Contributor

HinTak commented Dec 20, 2020

@jsbyysheng Cannot download the caj file (please use the attach feature of the issue tracker, zip it up if needed), and the code for the c-rewrite is gone too - anybody has a clone to push it? Or just zip it up and put it here too?

@jsbyysheng
Copy link
Author

jsbyysheng commented Dec 21, 2020

@austerios's repo was in gitlab before and currently in here. Unfortunately, this repo cannot be compiled in the newest macOS directly. Minor changes should be applied. My caj sample is here.

@HinTak
Copy link
Contributor

HinTak commented Dec 21, 2020

The software builds on linux but crashes on trying to run. caj2pdf seems to mostly got it done except adding the outline. Anyway, it is probably simple enough for somebody else to fix (sort of busy on jbig if I am spending time on caj2pdf at all...)

@HinTak
Copy link
Contributor

HinTak commented Jan 8, 2021

@austerios the current code still crashes, and there are a few other portability problems too. Anyway, here is the portability diff ( my compiler no longer take -flto=thin, and -lconv is only needed on MacOS X or BSD variants, and not needed nor provided on linux at all). The rest is better debugging (-g for finding wherethe exact location of crash is, with a debugger) and removing optimization that's really not needed (this code doesn't need to be any faster, really...).

diff --git a/src/Makefile b/src/Makefile
index f8c1e34..f96aebd 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -15,8 +15,8 @@ obj = ${src:.c=.o}
 
 PREFIX = /usr/local
 
-CFLAGS = -O3 -march=native -pipe -flto=thin -Wall
-LDFLAGS = -Wl,-O3 -lcrypto -liconv -lz -Wl,--as-needed
+CFLAGS = -g -O2 -pipe -Wall
+LDFLAGS = -lcrypto -lz
 
 CFLAGS += -I/usr/local/include
 LDFLAGS += -L/usr/local/lib

here is the crash work-around ( I call it a work-around, as the proper fix is probably finding out why it is pointing at wrong memory there).

diff --git a/src/pdf.c b/src/pdf.c
index 202b6d2..7f5c9d5 100644
--- a/src/pdf.c
+++ b/src/pdf.c
@@ -58,7 +58,7 @@ pdf_obj_destroy(pdf_object_t **pdf)
                *pdf = (*pdf)->next;
                free(ptr->object);
                free(ptr->dictionary);
-               free(ptr->stream);
+               //free(ptr->stream);
                free(ptr);
        }
 }

I am posting these just in case he is watching this space (and he seems to be quite active on his repo even as recent as 8 days ago).

I have a converted outcome from melon now, so I can compare that with caj2pdf and see what works.

@HinTak HinTak mentioned this issue Jan 8, 2021
@jsbyysheng
Copy link
Author

I am sorry that I cannot help you find out the problem because I am busy with my research recently. Below is the command I used to compile melon successfully in macOS. Wish it can help you!

cc -L/usr/local/opt/openssl/lib -L/usr/local/opt/libiconv/lib -I/usr/local/opt/openssl/include -I/usr/local/opt/libiconv/include -lcrypto -liconv -o melon melon.c cnki.c cnki_caj.c cnki_kdh.c cnki_nh.c cnki_outline_tree.c cnki_pdf.c cnki_xml.c pdf.c pdf_cnki.c pdf_get.c pdf_parser.c pdf_writer.c iconv.c

@HinTak
Copy link
Contributor

HinTak commented Jan 9, 2021

That's fine @jsbyysheng - the message was mostly for https://git.noema.org/melon/ . So you are a mac os x user too?

Openssl on linux is at the system location, and iconv's functionality is built-in to the system (GNU) C library. So on linux, none of the Openssl switches, nor the iconv switches, are needed.

@HinTak
Copy link
Contributor

HinTak commented Jul 7, 2022

Still a problem with current.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants