How can chrome handle PDFs better than Firefox or ImageMagick - google-chrome

In my application I import a variety of images into my database, but before storing them I convert them all to PNG using ImageMagick's convert script.
Every once in a while I encounter PDFs that can not be converted properly although they render fine in Chrome. Some of these PDFs render fine in Firefox, but mostly all of them render fine in Chrome.
The error I get when converting them using ImageMagick is:
Last OS error: 2
GPL Ghostscript 8.70: Unrecoverable error, exit code 1
convert: Postscript delegate failed `email.pdf': No such file or directory # pdf.c/ReadPDFImage/611.
convert: missing an image filename `/tmp/reza%d.png' # convert.c/ConvertImageCommand/2800.
What are my alternatives to this problem?
Thanks a bunch

Related

Is there a good alternative for embedding a PDF with HTML next to using a local file path, online file path or data source as base64-string?

I am building a web app and I would like to show PDF files to my users. My files are mainly stored as byte arrays in the database as they are generated in the backend. I am using the embed element and have found three ways to display a PDF:
Local file path in src attribute: Works, but I need to generate a file from the database byte array, which is not desirable as I have to manage routines to delete them once they are not needed anymore.
Online file path in src attribute: Not possible since my files may not be hosted anywhere but on the server. Also has the same issues as the previous method anyway.
Data as base64 string in src attribute: Current method, but I ran into a problem for larger files (>2MB). Edge and Chrome will not display a PDF when I covert a PDF of this size to a base64 string (no error but the docs reveal that there is a limit for the data in the src attribute). It works on Firefox but I cannot have my users be restricted to Firefox.
Is there any other way to transmit valid PDF data from a byte array out of the database without generating a file locally?
You have made the common mistake of thinking of URLs and file paths as the same thing; but a URL is just a string that's sent to the server, and some content is sent back. Just as you wouldn't save an HTML file to disk for every dynamic page on the site, you don't have to write to the file system to display a dynamic PDF.
So the solution to this is to have a script on your server that takes the identifier of a PDF in your system, maybe does some access checking, and outputs it to the browser.
For example, if you were using PHP, you might write the HTML with <embed src="/loadpdf.php?id=42"> and then in loadpdf.php would write something like this:
$pdfContent = load_pdf_from_database((int)$_GET['id']);
header('Content-Type: application/pdf');
echo $pdfContent;
Loading /loadpdf.php?id=42 directly in the browser would then render the PDF just the same as if it was a "real" file, and embedding it should work the same way too.

Log message: org.geotools.renderer.style: null input stream, could not load the font

Currently I am migrating a project to Java 11. In this project, we are using GeoTools to create a PDF file with geometries inside. For this PDF file we use a special font which is not available in the system. Since Java 11 we store this font in the resources and load it at runtime. Since the migration to Java 11, the following message appears in the log:
org.geotools.renderer.style: null input stream, could not load the font
However, the PDF file is created without any problems. The font is loaded via Spring Boot using #Value as resource. The font is created as follows:
PDFont fontSourceSansProBold = PDTrueTypeFont.load(doc, ressourceSourceSansProBold.getInputStream(), WinAnsiEncoding.INSTANCE);
Has anyone had similar problems before? What was the solution, if any?
Thank you!

Get IFC schema version

Opening an *.ifc file we can find "File_Schema" in the Header, for example:
HEADER;
...
FILE_SCHEMA (('IFC4'));
ENDSEC;
We are downloading IFC stream file and it would be nice to know the file schema version for it.
Is it somehow possible to get this information via DataManagement API?
This is already an old post, but just to mention that for those who download the file before any other operation: once downloaded, the following command can be used (on a Unix-like environment) to get exactly the IFC schema (e.g. "IFC2X3", "IFC4"):
grep "^FILE_SCHEMA" file.ifc | cut -d"'" -f2
Of course this command can be integrated in a program written in Node.js for example (using childProcess.exec), or any other programming language. Note that this is usually faster than streaming the file and searching in it, or even using a language-specific library to "grep" the file, especially for big IFC files.

HTML5 Application Cache - binary download

Application Cache works well when using it to save front-end resources such as images, fonts, CSS files, JS files, etc....
I'm trying to use it to save other files, such as PDF and XLS files...
And that is where things get complicated...
I can retrieve PDF files from the App Cache with no problems, but the retrieval of XLS/XLSX files behaves in weird manners across browsers:
Firefox 36 OSX: XLS/XLSX files can be retrieved
Chrome 40 OSX: XLS/XLSX files can be retrieved
Chrome 39 iOS: An error page with code 100 is displayed
Safari 8 OSX & Safari 8.1.3 iOS: XLS/XLSX data is shown as ugly plain ASCII
Safari 7.1.2 iOS: A popup alert is displayed saying "Safari cannot open the page because the address is invalid"
Tests are done with Python's SimpleHTTPServer module, and every resource are valid and can be retrieved from NETWORK successfully.
It seems like RTF, DOC/DOCX and ZIP files behaves like XLS/XLSX files.
I don't understand why the binary data in a PDF file can be downloaded successfully but the others listed above can't...
Any help is welcome!
s.

insecure string pickle error when uploading and downloading to MKS Integrity

I am getting the exception "ValueError: insecure string pickle" when attempting to run my program after creating a sandbox from MKS.
Hopefully you are still interested in helping if you are still reading this, so here's the full story.
I created an application in Python that analyzes data. When saving specific data from my program, I pickle the file. I correctly read and write it in binary and everything is working correctly on my computer.
I then used py2exe to wrap everything into an .exe. However, in order to get the pickled files to continue to work, I have to physically copy them into the the folder that py2exe. So my pickle is inside of the .exe folder and everything is working correctly when I run the .exe.
Next, I upload everything to MKS (an ALM, here is the Wikipedia page http://en.wikipedia.org/wiki/MKS_Integrity).
When I proceed to create a sandbox of my files and run the program, I get the dreaded "insecure string pickle" error. In other words, I am wondering if MKS screwed something up or added an end of line character to my pickle files. When I compare the contents of the MKS pickle file and the one I created before I uploaded the program to MKS, there are no differences.
I hope this is enough detail to describe my problem.
Please help!
Thanks
Have you tried adding your pickled files to your Integrity sandbox as binaries and not text?
When adding the file, on the Create Archive interface, select the options button, and change data type to "Binary" from "Auto". This will maintain any non-text formatting within the file.