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

XmlPullParserException in pdf2htmlEX-Android v0.18.20 #83

Closed
jackyhieu1211 opened this issue Dec 28, 2023 · 14 comments
Closed

XmlPullParserException in pdf2htmlEX-Android v0.18.20 #83

jackyhieu1211 opened this issue Dec 28, 2023 · 14 comments

Comments

@jackyhieu1211
Copy link

W/System.err: org.xmlpull.v1.XmlPullParserException: expected: END_TAG {null}family (position:END_TAG </axis tag='ital' stylevalue='0'>@28:45 in java.io.InputStreamReader@80377c5) 
W/System.err:     at com.android.org.kxml2.io.KXmlParser.require(KXmlParser.java:2067)
W/System.err:     at com.viliussutkus89.android.fontconfigtranslator.FontconfigTranslator$FontFamily.<init>(FontconfigTranslator.java:245)
W/System.err:     at com.viliussutkus89.android.fontconfigtranslator.FontconfigTranslator.translate(FontconfigTranslator.java:104)
W/System.err:     at com.viliussutkus89.android.pdf2htmlex.FontconfigAndroid.init(FontconfigAndroid.java:27)
W/System.err:     at com.viliussutkus89.android.pdf2htmlex.pdf2htmlEX.<init>(pdf2htmlEX.java:119)

It working on version v0.18.19. But I use version v0.18.20. It got error above.

This is my config

 val outputFile =
            pdf2htmlEX(context)
                .setInputPDF(inputPdf)
                .setOwnerPassword(password)
                .setUserPassword(password)
                .setOutputHtml(outputPath)
                .setEmbedCSS(true)
                .setEmbedImage(true)
                .setEmbedJavascript(true)
                .setOptimizeText(true)
                .setSqueezeWideGlyph(true)
                .setStretchNarrowGlyph(true)
                .setProcessAnnotation(true)
                .setDRM(true)
                .convert()

You can check this file

pdf_file.pdf

@ViliusSutkus89
Copy link
Collaborator

Hi,

If it works on 0.18.19, it should work on 0.18.20, because the exception happens in the library that I haven't updated in between these two releases.

Anyways, lets see what we can do.
Could you download /system/etc/fonts.xml file from your device? It's a device config file that contains info about available fonts.

@jackyhieu1211
Copy link
Author

@ViliusSutkus89
Hi

This is my fonts.xml
Can you check. thank you

fonts.xml.zip

@ViliusSutkus89
Copy link
Collaborator

Thank you, @jackyhieu1211 . Could you also check if 0.18.21 works for you? I've added a try-catch for Fontconfig translator, there may be some issues with fonts, but the pdf conversion should work

@jackyhieu1211
Copy link
Author

@ViliusSutkus89
Thank you. I will check now. !

@jackyhieu1211
Copy link
Author

@ViliusSutkus89
Hi.
I tried version v0.18.21. But I got error same

20:23:09.338  W  org.xmlpull.v1.XmlPullParserException: expected: END_TAG {null}family (position:END_TAG </axis tag='ital' stylevalue='0'>@28:45 in java.io.InputStreamReader@7561e31) 
20:23:09.338  W  	at com.android.org.kxml2.io.KXmlParser.require(KXmlParser.java:2067)
20:23:09.338  W  	at com.viliussutkus89.android.fontconfigtranslator.FontconfigTranslator$FontFamily.<init>(FontconfigTranslator.java:245)
20:23:09.338  W  	at com.viliussutkus89.android.fontconfigtranslator.FontconfigTranslator.translate(FontconfigTranslator.java:104)
20:23:09.338  W  	at com.viliussutkus89.android.pdf2htmlex.FontconfigAndroid.init(FontconfigAndroid.java:29)
20:23:09.338  W  	at com.viliussutkus89.android.pdf2htmlex.pdf2htmlEX.<init>(pdf2htmlEX.java:119)
Screen Shot 2023-12-28 at 20 27 56

@ViliusSutkus89
Copy link
Collaborator

Error is still there, because it's printed out in the line 31, but the conversion process should still continue, is it not doing anything?

@jackyhieu1211
Copy link
Author

@ViliusSutkus89

the conversion stopped shortly after. I cannot convert successfully!

@ViliusSutkus89
Copy link
Collaborator

It shouldn't have stopped. Could you post more output from logcat?

@jackyhieu1211
Copy link
Author

@ViliusSutkus89
After checking logcat again.
I noticed that the conversion continues after init Font failed.

I don't see any other logcat. except for the line below

Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid 28684 (RxCachedThreadS), pid 26451

It seems like the error occurred in the C library. So logcat cannot show the C library error.
I tried sending error to firebase crashlytic. and I only get logcat like the photo below

Screen Shot 2023-12-28 at 20 51 37

@ViliusSutkus89
Copy link
Collaborator

The error is not in libc, libc only raises segmentation fault, because there's an error in our code somewhere.

So this is a separate error from the XmlPullParserException, I've reproduced it on my end, will see how can I solve it, but the fix won't be today

@ViliusSutkus89
Copy link
Collaborator

OK, so your PDF has a font embedded with a name "BGDGBW弫Roboto-Bold".
FontForge isn't happy about non ASCII characters in font names and is trying to print out an error, but fails, because iconv is failing. I've patched FontForge to handle iconv failure ( ViliusSutkus89/ndkports@fd0b11e ).

Will later look into why iconv fails, because iconv may be used in other places too, without proper error handling.

That error message: "The PostScript font name "BGDGBW弫Roboto-Bold" is invalid.\nIt should be printable ASCII,\nmust not contain (){}[]<>%/ or space\nand must be shorter than 63 characters"

Also, please tell me that Google Translate is translating that symbol wrong and it doesn't mean "Kill Roboto Bold".

@ViliusSutkus89
Copy link
Collaborator

ViliusSutkus89 commented Dec 29, 2023

@jackyhieu1211, can you confirm is the issue is fixed for you in 0.18.22 ?

@jackyhieu1211
Copy link
Author

@ViliusSutkus89
Sorry for the late reply.
I tested. It worked.

By the way. Can you callback the conversion progress?
Ex: 0%, 1%, 2% .... 100%
Thank you very much.

@ViliusSutkus89
Copy link
Collaborator

Yeah, conversion progress would be useful. Let me quote myself from more than three years ago in Issue #20:

Totally reasonable expectation. Will get around to that someday

Haven't got around to it yet

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