I started using html2Canvas. I'm trying to convert the below donut chart into a pdf using html2canvas and jspdf.
The result is as follows:
We can make out that text gets cropped.
Then I tried to change the text next to donut chart to this :
The result is so peculiar:
Why do only specific text nodes getting converted by html2Canvas? Why is the rest of it cropped? What is the programmatic workaround. Any help would be appreciated.
Related
Using double-backticks around a block of text in my restructuredtext sphinx document causes the HTML output to display the text in red with a frame around it. I would like to have my latexpdf output look the same. The pdf shows the text in a mono font in black and with no frame. At a minimum, I would like the text to be in a red color.
My .tx file shows that it uses \sphinxcode{\sphinxupquote{my text}}. Do I need to somehow override sphinxupquote or is there another way?
How can we add header and footer same for all pages through out pdf using jsPDF. And apart from this please let me know that what are all ways to create pdf using jspdf like using HTML content or a string or some HTML template so please help me out on both query
Although jsPDF does not have a dedicated header or footer functions, you may use
var doc = new jsPDF();
doc.text("Header or footer text", x, y);
Where x is margin from left of the page and y is from the top.
You may have to position it as per your page dimensions require.
And about your second query, jsPDF has addHTML and addImage (Older versions of jsPDF) functions to help you generate PDF.
addHTML take in raw HTML code as input while addImage takes image as input which can be positioned on the PDF page.
addImage requires additional libraries such as html2canvas for image generation.
I'm looking for a free iOS component that allows me to draw a doughnut chart with text in the center. So far I've only used Code Plot, but that is a full pie chart.
I'm attaching an example of the requirement.
Any help will be much appreciated.
I suggest searching on cocoacontrols.com. They have lots of open source controls for iOS and Mac. I didn't se any specifically called "doughnut chart" but some of the pie charts controls might offer that option.
In fact, it seems that this one does include what you're calling a doughnut chart. It doesn't look like it has built-in support for a label in the middle, but it does create a ring-shaped chart like you want.
You could also always create a pie chart and then put a view on top of it that is transparent except for a white circle in the middle, and then put a label on top of that.
Getting a little more complex you could modify the CorePlot control and add a filled CAShapeLayer to it.
Another option is to create svg chart and use UIWebView to display it. With svg chart, you get much more flexibility with libraries like highcharts and d3js. Here's an example with donut chart:
http://vida.io/documents/Byh8tTakzB59oGa9f
You can embed the link or save svg and display in UIWebView. Saving svg works offline.
I have a pdf which I would like to use as a template to create a new pdf. The goal is to place an image inside a particular placeholder rectangle in the original pdf. The creation of the original pdf is under my control but the placeholder rectangle/bounds might be anywhere in the pdf. I am thinking of using a dummy image(of same dimensions) as the placeholder rectangle in the original pdf.
The Prawn gem supports placing an image at a given absolute/relative position within a page.
The trouble is that since the rectangle or dummy-image could be anywhere in the original pdf, I don't know what values to use for the following
pdf.image "/path/to/image", :at => [x,y] prawn call
Is there a way to get the coordinates of an image in the original pdf. My primitive understanding tells me that one would have to render the entire pdf to know this. Is that right ? If yes, what would be a good way to render pdf in memory (headless) and get the co-ordinates of various pdf objects(like bounding rectangles, images, etc).
I am not limited by language/runtime here as long as I can trigger it programmatically.
What could be other approaches to this problem ?
Not an answer (e.g. I don't know the Ruby language), but in lieu of any others, and because I can't post a comment yet, here's what I think.
If conditions stated above are true (placeholder and replacement images are exactly same size + same color model e.g. RGB 24 bps) and you control template creation (therefore you can store placeholder inside PDF uncompressed), it can be as quick and dirty as raw replacement in a file treated as byte string. E.g. placeholder filled with red, then you search for pattern (0xFF0000) x W*H and replace it with raw image data. Which, of course, you can get any way you like, e.g.:
convert my_image.jpg RGB:- | ...
If this solution is too dirty or conditions not exact, then parse page content stream for construct like
width 0 0 height x y cm
/name Do
It's not cleanest, either, but for vast number of simple page descriptions x and y are the coordinates you are looking for.
Further, if you control template creation, why don't you store additional information inside pdf as e.g. custom keys in Info dictionary, and then read them back when using the template.
I have a working pie chart that uses data from a HTML table. I trying to get the corresponding label to show on the chart. Current it shows "slice" on all slices. Here is a jsFiddle link www.jsfiddle.net/codedecks/YJsSg/. Thanks in advance.
Did some more searching and found a couple of sample that was was able to use. In case any one else is looking for the same thing here is the link to the jsFiddle www.jsfiddle.net/codedecks/KB6Zy/.