wkhtmltopdf does not convert to pdf - html

Hi ,
I just changed my server and from what i understand i have installed all the dependencies required for this. But still i am unable to view my PDF instead a distorted code is shown and what's more annoying is that i have a bunch of projects in CODEIGNITOR Framework that are working fine but this project is developed in laarvel 5.
Is there any additional dependency for laravel or am i doing it wrong at some place.
I just joined a new team and don't know their whole programming structure yet.

The image-content you posted looks like a valid PDF - looking at it by a text viewer.
Did you try to open it with a pdf viewer?

Related

Getting exception "Unknown Error" after bundling the application(exe)

We are using the evaluation version of JXBrowser for some charting application. We wanted to showcase a demo to our client just to check the overall performance of charts with JXBrowser. But we encountered some unexpected issue while we were trying to build an "EXE".
The issue:
We created a build and the passed the URL from the classpath(webView.getBrowser().loadURL(getClass().getResource("/chartiq/stx-advanced.html").toExternalForm());); the build successfully generated and if we run the build we are getting exception "Unknown Error" but its working fine in the IDE(Eclipse).
Afterwards, we tried to host the html pages at some server and we were able to get the html rendered in the application.
Question:
1. Is the aforementioned issue related to evaluation version?
2. If above question is not the case, is there any fix for that? As we have crawled the web and find nothing related to this.
For the reference I attached the screen shot showing the full exception stacktrace.
Any help will be appreciated.
Thanks,
Nikhil
The reason of this issue is that JxBrowser doesn't support loading resources from JAR files. Chromium engine used in JxBrowser cannot load the /chartiq/stx-advanced.html file located inside JAR archive. You need to extract the file and load the extracted file.
FYI: we have already started working on the functionality that allows loading HTML files and other resources from JAR archives. An updated build with this functionality will be available in December.

wkhtmltopdf generates from PDF format on Ubuntu without X Server

Is it possible to set format of PDF to generate in wkhtmltopdf?
From my PC wkhtmltopdf generates format "PDF-1.4"
But remote Ubuntu 14.04 server that is generating pdf with a 'virtual' X server using xvfb giving format PDF-0:
The only problem is opening generated pdf file in Chrome :)
Chrome cannot open PDF-0.
Thanks
It looks like the resulting PDF from xvfb might not be 100% correct. There are some problems with the meta data. It's missing the creator for example. Also PDF-0 does not appear to be a valid PDF version. There might be other problems with the document. This would be a possible reason why the generated file does not appear in Chrome.
A good way to examine the document would be using Acrobat's preflight tool. It will inspect the document for potential problems, and that could give provide a clue on what's going on. The tool is located under "Print Production" in Acrobat. The profile to run is called "Report PDF syntax issues". I'm sure there are other tools out there that can also explain what is wrong with the document.
This section should provide a resolution to the problem. As mentioned in the comments below, updating the QT version from 4.8.6 to something newer should resolve the issue. The working setup appears to be running 5.3.2, while the non working one is under QT 4.8.6.
May i recommend phantomjs as an alternative (headless tool, no server x needed at all) to xkhtmltopdf.
HTML to PDF rendering is very straight forward (e.g. http://phantomjs.org/screen-capture.html )
Bounty answer:
Apparently QT 4 and QT 5 behave differently when printing to a PDF. Thus, your problem can be solved by upgrading the QT libs on your server.
You may consider filing a bug against wkhtmltopdf since your described behavior obviously renders it incompatible with QT 4.
See also original comment here.

PDF Annotator with JSON layers

I am attempting to create a pdf annotator using PDF.js and a HTML5 drawing app to create a JSON file.
Using this: https://github.com/mozilla/pdf.js/blob/master/examples/learning/prevnext.html
Maybe this: http://codecanyon.net/item/html5-drawing-tools/8869338?WT.oss_phrase=&WT.oss_rank=2&WT.z_author=appsandsites&WT.ac=search_thumb
to create a JSON like http://www.html5rocks.com/en/tutorials/canvas/integrating/#web
Any thoughts or suggestions on how to do this? Do you think I could use PHP to create and place the file on my server?
Direction on the best way to do this is appreciated.. what version of JSON, how to use canvas to create a file and edit it, etc
Update, I want to lay this over PDF.js:
https://github.com/trsanders/responsive-sketchpad
and then in PHP create a JSON file that stores the url of a PDF and the URL to the generated json/image.
Update 2/23
I found a document browser in Perl with flexpaper which lays aframework foundation for what I want to do, but does not add in drawing support. What I was thinking is the above image.
http://eric-blue.com/2010/02/12/example-document-browser-code/
Hypothes.is supports text annotation of PDFs (via PDF.js and Annotator). The plan at The Hypothesis Project (a non-profit...also where I work, fwiw) is to upstream the PDF related features that have been made to its customized Annotator, so they'll be available to more developers.
Here's an example of Hypothes.is loaded on a PDF via a proxy. The same functionality is provided without the proxy by using a bookmarklet in Firefox or the Hypothes.is Chrome extension.
Additionally (if you're wanting shape drawing on top of PDF.js rendered PDFs), you might check out the Annotorious polygon preview. Similar to what you've described, plus annotation, plus storage...though I don't believe it works on PDFs...just images.
There is also ongoing work being done at the W3C to build an interoperable annotation data model. Checkout the Annotation Working Group for more information.
Lastly, PDF.js is also getting work done to it now to support PDF-level annotations. Eventually, it should give PDF.js a strong foundation for exposing annotations loaded from other sources.
Hopefully that's enough to get you started. :)

Trying to get tcpdf installed on my laravel website?

I will refer to the account as user in this post.
So I put the tcpdf directory in /home/user/laravel/
I then tried to do this in a page:
{{ HTML::link('/tcpdf/examples/example_001.php') }}
and I get the 404 requested page that I setup
any ideas why this is happening or why its not working?
Do I need to do a route maybe?
Any information on this would be great.
If you are really trying to work with TCPDF within your Laravel app, you will most likely want to include it as you would other packages using composer. Please see this answer on how to add TCPDF to composer.json in order to have composer automatically download it into your vendor area: Download tcpdf manually without using composer in Laravel 4 (Ignore the post title - it does talk about including TCPDF with composer.)
What you are achieving with the code sample above is to simply render a link to a certain URI off your URL base. Whether or not that will work will depend on how your local web server is configured and potentially how Laravel and Laravel routing is configured.
Having said all that, I think you are headed down the wrong path with that solution. Ultimately, I believe that what you will want to do is drag TCPDF in using composer, then create a PDF file with code like:
$pdf = new TCPDF();
$pdf->AddPage();
$pdf-> ... other stuff according to the TCPDF API...
$pdf->Output( 'test.pdf', 'I' );
The TCPDF API can be found here: http://www.tcpdf.org/doc/code/classTCPDF.html
You could put some code like that into a controller method to play around and get things working, but later you would probably want to move it elsewhere.

TypeScript source map files don't work with Chrome

I'm trying to get TypeScript source debugging working in Chrome, but I'm running into two specific and perhaps related problems.
The first is that the comment generated by the TypeScript/WebEssentials compiler that's supposed to identify the location of the source map file looks like this:
//sourceMappingUrl=MySourceFile.js.map
But Chrome won't read that file. It seems expect that the comment will look like this:
//# sourceMappingUrl=MySourceFile.js.map
If I manually change the comment to that, and refresh my page, then magically the references to all the .ts files show up as sources in the Chrome Developer Tools.
However, that leads to my second problem, as the files don't actually get loaded. The .ts source file that Chrome should be trying to download is http://localhost/MySourceFile.ts, but the one that it's actually trying to download is http://localhost/C:/source/web/MySourceFile.ts. That sort of makes sense, as the opening attributes of MySourceFile.js.map look like this:
{"version":3,"file":"tmp1523.tmp","sources":["C:/source/web/MySourceFile.ts"
But that obviously doesn't work with Chrome, as it interprets the source-map location to be entirely relative, and IIS (quite correctly) won't serve up any URL looking like http://localhost/C:/source/web/MySourceFile.ts.
So, with respect to these two problems, is it Chrome or the TypeScript source-map feature that's doing it wrong? And what's the recommended way of doing this?
I'm using Chrome 25.0.1323.1 dev-m, with TypeScript 0.8.1 and WebEssentials 1.8.5.
This is an issue with version 1.8.5 of Web Essentials (the version currently available from the Visual Studio Gallery). The latest nightly build (at time of writing http://madskristensen.net/custom/webessentials2012.vsix) fixes the problem and generates the map linkage correctly.