Getting java.lang.UnsupportedOperationException at org.apache.pdfbox.pdmodel.graphics.color.PDPattern.toRGB - html

I am using pdfbox-2.0.9 in my java application to convert a PDF file to html. But I am getting
java.lang.UnsupportedOperationException
at org.apache.pdfbox.pdmodel.graphics.color.PDPattern.toRGB(PDPattern.java:95)
at org.fit.pdfdom.PathDrawer.pdfColorToColor(PathDrawer.java:133)
at org.fit.pdfdom.PathDrawer.clearPathGraphics(PathDrawer.java:79)
at org.fit.pdfdom.PathDrawer.drawPath(PathDrawer.java:59)
at org.fit.pdfdom.PDFDomTree.createPathImage(PDFDomTree.java:403)
at org.fit.pdfdom.PDFDomTree.renderPath(PDFDomTree.java:251)
at org.fit.pdfdom.PDFBoxTree.processOperator(PDFBoxTree.java:499)
at org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:503)
at org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:477)
at org.apache.pdfbox.contentstream.PDFStreamEngine.showForm(PDFStreamEngine.java:181)
at org.apache.pdfbox.contentstream.operator.DrawObject.process(DrawObject.java:65)
at org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:848)
at org.fit.pdfdom.PDFBoxTree.processOperator(PDFBoxTree.java:542)
at org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:503)
at org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:477)
at org.apache.pdfbox.contentstream.PDFStreamEngine.processPage(PDFStreamEngine.java:150)
at org.apache.pdfbox.text.LegacyPDFStreamEngine.processPage(LegacyPDFStreamEngine.java:139)
at org.apache.pdfbox.text.PDFTextStripper.processPage(PDFTextStripper.java:391)
at org.fit.pdfdom.PDFBoxTree.processPage(PDFBoxTree.java:208)
at org.apache.pdfbox.text.PDFTextStripper.processPages(PDFTextStripper.java:319)
at org.apache.pdfbox.text.PDFTextStripper.writeText(PDFTextStripper.java:266)
at org.fit.pdfdom.PDFDomTree.createDOM(PDFDomTree.java:218)
at com.demo.pdf.converter.PdfProcessor.convertToHtml(PdfProcessor.java:87)
The pdf I am trying to convert can be accessed from here.

This issue is resolved in PDF2Dom v1.9. I tried the pdf you provided with this version and it's getting converted appropriately. No exceptions thrown.
Please confirm by updating PDF2Dom to v1.9
You can find latest dependency here .

Related

Laravel - Json Encode Works Fine But Returns Malformed UTF-8 Error Regardless

Problem
The JSON is returned correctly encoded but json_last_error equates to 5 thus Laravel throws this exception on response creation in JsonResponse->setData().
Related References
A resolved bug report for symfony and PHP 7.3: https://github.com/symfony/symfony/issues/31447 mentions this exact issue. That is:
If a json_encode()/json_decode() without JSON_THROW_ON_ERROR encoding option set throws an error, any subsequent call to the same with that flag set will not reset the error of the previous call.
The JSON_THROW_ON_ERROR RFC mentions this behavior as by design: https://wiki.php.net/rfc/json_throw_on_error
Unfortunately Laravel's code uses the flag but does not cater for this behavior and throws exception if json_last_error() returns a non zero value. Which in this case should have been ignored as it will always reference the previous error. Perhaps a version check should be added.
Investigation
I have also searched the bowls of my application and haven't found the misbehaving json_encode/json_decode without JSON_THROW_ON_ERROR set so I am sure it is internal to Laravel before Middleware calls.
Additional Context
This suddenly started happening today in our server. It happens when users connect to the server through the web app from select systems. Even though system kind should not affect server side response generation but still web app always generates this error for specific PCs/Mobiles.
Proposed Hack
After sifting through the Symfony bug report, the easiest workaround I have found is to just clear the error through an inconsequential json_encode('1') call. Which effectively resets the error code to 0 and the later JSON methods work fine.
Fortunately we have our own response generation class so just adding this before the hand-off to Laravel works fine.
Still this is a hack. I am more interested in a better solution or any bug fix available.

ManifestChildren throwing InvalidArgumentException in Forge PHP SDK

My file is not being translated due to an exception:
Invalid value for 'role', must be one of '2d', '3d', 'graphics', 'manifest', 'thumbnail','Autodesk.CloudPlatform.PropertyDatabase','viewable', 'ifc'
I debugged the SDK and the role that is causing the exception is Autodesk.AEC.ModelData.
The file that I am trying to translate is the same I am used to translate in my application, so I think it is a problem in Forge PHP SDK.
Yes, this is most likely an issue with the PHP SDK for Forge being out-of-date. I see that you already submitted a PR to the codebase - I will contact the dev team to make sure the new role type is recognized properly.

Appcelerator message = "JSON Parse error: Unexpected identifier \"undefined\"";

I am adding new features to an app I wrote last years and is working now ... I just port the code from Appcelerator (3.2...) to the Appcelerator Studio 5.2.0.GA SDK ... and I have spent 2 days trying to figure out why code that currently works on an app in the app store is not working in the SDK 5.2.0 environment
I keep getting the above error .. I am positive the url is correct and working
This line of code works now in the app in the store and in 3.1... but is not working in 5.2.0
var jsonObject = JSON.parse(this.responseText);
It gives the above error
"JSON Parse error: Unexpected identifier \"undefined\"";
I have read their site and searched for a solution ... Thanks
entire Block
Try one thing:
Open this site and put your response data in which you are getting error https://jsonformatter.curiousconcept.com
After parsing the same data on the above site, you can check whether the problem is really in your Titanium code or in your data.
Also check whether you are really getting any response data or not.
If it does not help, then please share some necessary source code
Thanks

Elasticsearch does not return jsonp

im trying to connect my polymer element to my own elasticsearch-server.
My first problem was, that they are on two different ports, so it had to choose JSONP because of Cross-Domain problems.
So I found out, that I just have to add
http.jsonp.enable: true
in the elasticsearch.yml.
Im starting the server simply by executing the "elasticsearch.bat".
I've indexed data.
If I try to load the API via iron-jsonp-library, im always getting an unexpected token error.
<iron-jsonp-library id="libraryLoader"
library-url="http://127.0.0.1:9200/data/_search?pretty%%callback%%"
notify-event="api-load"
callbackName="jsonpCallback">
</iron-jsonp-library>
In Google Chrome, I'm getting following result from elasticsearch
{"took":2,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":5,"max_score":1.0,"hits":[{"_index":"data","_type":"data","_id":"5","_score":1.0,"_source":{"id":5,"name":"Meyr","manufacturer":"Meyr","weight":1.0,"price":1.0000,"popularity":1,"instock":true,"includes":"Meyr"}},{"_index":"data","_type":"data","_id":"2","_score":1.0,"_source":{"id":2,"name":"Meier","manufacturer":"Meier","weight":1.0,"price":1.0000,"popularity":1,"instock":true,"includes":"Meier"}},{"_index":"data","_type":"data","_id":"4","_score":1.0,"_source":{"id":4,"name":"Mair","manufacturer":"Mair","weight":1.0,"price":1.0000,"popularity":1,"instock":true,"includes":"Mair"}},{"_index":"data","_type":"data","_id":"1","_score":1.0,"_source":{"id":1,"name":"Maier","manufacturer":"Maier","weight":1.0,"price":1.0000,"popularity":1,"instock":true,"includes":"Maier"}},{"_index":"data","_type":"data","_id":"3","_score":1.0,"_source":{"id":3,"name":"Mayr","manufacturer":"Mayr","weight":1.0,"price":1.0000,"popularity":1,"instock":true,"includes":"Mayr"}}]}}
Due to some internet knowledge of JSONP, its not jsonp.
Why is my elasticsearch server, not formatting right?
Are you prior to v2.0? Looks like they removed jsonp in 2.0 (elastic.co/guide/en/elasticsearch/reference/2.2/…).
Alsopretty%%callback%% doesn't look right, the %%callback%% macro usually needs to be the value of name (like onload=%%callback%%). The element replaces %%callback%% with the name of a global function that is generated for you.

unable to run activeX control in IE

Im trying to embed some application in IE by creating activeX control. I've got xyz.dll. Normally if I register this dll through command prompt(batch file), the embedding is successful. But if i use the cab file methodolgy, only the first snapshot of application loads in IE(embedded application fails to run) inspite of the fact that registration of dll is taking place.
xyz.cab file contains, xyz.dll and xyz.inf.
The xyz.inf is as following:
[version]
signature="$CHICAGO$"
AdvancedINF=2.0
[Add.Code]
xyz.dll=xyz.dll
[Deployment]
InstallScope=user|machine
[xyz.dll]
file-win32-x86=thiscab
clsid={HJI9D4D39-K9F5-489B-8032-CCHB1B189J10}
FileVersion=1,0,0,0
RegisterServer=yes
RedirectToHKCU=yes
HRESULT IEInstallScope(LPDWORD pwdScope);
I'm making cab file through makecab.exe and im signing cab file too with signtool.exe and makecert technique and finally the excerpt from the html is as following:
...
CLASSID="clsid:HJI9D4D39-K9F5-489B-8032-CCHB1B189J10"
CODEBASE="C:\xyz\13\plugins\ie\xyz.cab#Version="1,0,0,0"
...
So i dont know why Im facing this problem.The reason may be because thers something Im mistaking inside inf file or I dont know the exact usage of "HRESULT IEInstallScope(LPDWORD pwdScope); "or is it associated with dll????
please help me!!!!!!
EDIT:::well this worked out for me, but i still dont know why registerserver=yes fails to embedd activex perfectly::
new inf file is as following:
[version]
signature="$CHICAGO$"
AdvancedINF=2.0
[Add.Code]
xyz.dll=xyz.dll
[Deployment]
InstallScope=user|machine
[Setup Hooks]
xcxc=xcxc
xcxc1=xcxc1
[xyz.dll]
file-win32-x86=thiscab
clsid={HJI9D4D39-K9F5-489B-8032-CCHB1B189J10}
FileVersion=13,0,0,0
RegisterServer=yes
RedirectToHKCU=yes
HRESULT IEInstallScope(LPDWORD pwdScope);
[regDll]
hook=xcxc
[xcxc]
run=C:\Windows\System32\regsvr32.exe "C:\xyz\13\plugins\ie\xyz.dll"
[abcDll]
hook=xcxc1
[xcxc1]
run=C:\Windows\syswow64\regsvr32.exe /u /s "C:\xyz\13\plugins\ie\xyz.dll"