I'm using jspdf library for generating PDF file from html. It is really nice one. But I have an issue with last line on each page of the pdf.
Here is a DEMO and my javascript:
var pdf = new jsPDF();
$('#generatePdfBtn').click(function () {
pdf.fromHTML($('#printableContent').html(), 15, 15, {
'width': 400
});
pdf.save('myPdf.pdf');
});
When you generate a pdf by clicking on a button, you will see that at the end of the first page we have "pararaph 30" and normally on next page of pdf we should see next "pararaph 31" paragraph. But I don't see it and instead see "pararaph 32". Why last line is being lost? Any ideas please?
Try this:
Open your jspdf.js or jspdf.debug.js local file and modify this:
this.pdf.internal.getVerticalCoordinateString(this.y), style.color, "Td");
Erasing style.color and save as:
this.pdf.internal.getVerticalCoordinateString(this.y), "Td");
Then it runs correctly on firefox and chrome. At least that worked for me and this is a solution until they fix that failure.
Well there is a trick, If you can determine, where you need to put the page break, then you can simply place a "" there to force it. In this way you can avoid the text from being chopped off.
Working DEMO: http://jsfiddle.net/nq361uoz/4/
Unfortunately, this is a known bug in jsPDF which is still in open status in the GitHub repository.
More info here: https://github.com/MrRio/jsPDF/issues/555
Hope this helps!
My guess it cut's the line as it is written not within the margins. Most simple way is to make a loop, that every 31th row is duplicated. Not the best solution, but the quickest.
Related
I am editing a javascript file for the first time and was wondering if someone could help point me in the right direction.
h&&""!=g&&(k+='<strong>Get Directions:</strong> '+g+"<br>"),
The code above is just a snippet from a larger file but is what I am trying to edit. I have added 'Get Directions' but now I want to remove the URL being shown in the middle of the link so that it reads "Click Here".
The +g+ is outputting an office URL.
I am unsure of how to edit the line as everything I do breaks the module.
E.g. example that does not work....
h&&""!=g&&(k+='<strong>Get Directions:</strong> 'Click Here"<br>"),
It's confusing because you are using ' and " on the same line to enclose strings. The "Click Here" text should be inside the string like this:
Click Here<br>')
Does this work?
h&&""!=g&&(k+='<strong>Get Directions:</strong> Click here<br>'),
I know you shouldn't put anything after the closing 'html' tag. Tell SharePoint about it...
[...]
</body>
</html><!-- Rendered using cache profile:Public Internet (Purely Anonymous) at: 2013-06-06T12:57:10 -->
This is what the SharePoint output caching debug information looks like. I want this hidden comment to be visible on every page. Switching to source view and going to the end of the file makes me tired.
In an effort to not reinvent the wheel I figured it would be the smartest choice to add a piece of javascript code to my masterpage which copies the comment to a location (within the page) of my choosing.
Any idea on how I get hold of the comment via javascript? jquery is ok.
You can get the nodeValue of the Comment Object and append it to Body Element:
$(document).ready(function() {
var comment = $('html').prop('nextSibling').nodeValue;
$('<div/>').html(comment).appendTo('body');
});
http://jsbin.com/arodiz/2/edit
Simply document.lastChild.nodeValue will do the trick.
(Assuming you run it after the DOM is ready)
edit
I took the liberty of modifying the code from undefined's answer :)
$(function(){
$('body').append(document.lastChild.nodeValue);
});
http://jsbin.com/arodiz/3/edit
I set up a slideshow for my webpage with the following script, but can't find it out how can I make it repeat. I mean I want when it go to the last photo, it will repeat to the first one again. Any one can help please:
open this link and view the code source please:
http://www.xuanyinwen.com/test2.html
Many thanks
Wayne
you can either set the number of cycles in displaymode: {type:'auto', pause:2500, cycles:[here], wraparound:false}, you should also try changing persist: true
as it will remember the last viewed slide and recall it.
HI Neo, could you have another look for my script again, its working now: http://www.xuanyinwen.com/test2.html
not sure what script should I overrided by your line: setting.playtimer=setTimeout(function(){slideshow.showslide('next')}, 2500)
thanks
this isn't even working as you say it is. However if it was you could add following line manually to override anything:
setting.playtimer=setTimeout(function(){slideshow.showslide('next')}, 2500)
I'm working on a Javascript-based replacement for a Flash applet. The site is having rendering problems only in IE, where it exhibits a behavior that has me at wit's end.
http://janetalasher.com/new/content/portfolio/artcloth/ (This is the page)
What does IE do that's so strange (in this case only)? If you look in Firefox, you'll see a table of images on the right which has the thumbnails. IE6 and IE7 don't show this... unless you are in print preview. It's not a CSS glitch - I've disabled all stylesheets and the error still occurs. I'd provide more relevant source code, but I don't even know where the problem is. The .js files that I suspect (if it's any help) are:
/common/gallery/display.js
/common/gallery/loader.js
Okay - update: It is definitely rendering properly in print preview mode only. Can someone please explain to me in what world this happens? The div is present in the normal mode, but the table won't render. Using the IE developer toolbar confirms it and all the cells are present.
Try adding semi-colons here:
function loadGallery(xml)
{
thumbpath = $(xml).find("thumbpath").attr('dir') // add here
imagepath = $(xml).find("imagepath").attr('dir') // here
detailpath = $(xml).find("detailpath").attr('dir') // and here
cSheet = contactSheet(xml);
$('.contactSheet')[0].appendChild(cSheet);
display($(cSheet).find('img')[0]);
}
Also, on this line:
jQuery.get('/new/content/portfolio/artcloth/gallery.xml' , 'xml' , function(data) { loadGallery(data); } ) // missing one here too
Actually, your Javascript files are missing semi-colons on the end too. Make sure you go through each file and add one to the end of each line.
Javascript does not actually require them, but for the sake of sanity and knowing exactly what your code is going it is a good idea to put them in. For example:
return
1
Can become:
return;
1;
Which returns nothing at all, not exactly the desired effect.
According to Microsoft Script Editor, there's an error inside jQuery caused by this line:
$('#lower').css('padding-left' , paddingLeft - (lowerRightProtrusion < 0 ? 0 : lowerRightProtrusion) + "px");
Since lowerRightProtrusion is NaN, and NaN < 0 calculates to false, you're actually setting padding-left to "NaNpx". Does not compute ;)
See my previous answer for info about MS Script Editor:
Using the IE8 'Developer Tools' to debug earlier IE versions
It would seem that IE is not picking up the styles. If I open the page in chrome, the "float:left" style appears on the description div. however, in IE this is not the case.
You currently have your includes in a div in the body of the document. If it is possible try moving these into the head. I'm talking about the link and script tags directly descendant of div id="pageHead".
(I am using IE6 and the developer toolbar to get this information)
In /common/css/generic.css:
div#information
{
margin-left:188px;
m\argin-left:94px; <------ not sure if that would cause this, but thought i would point it out
}
Good evening everyone,
I am using a JavaScript to load/override content from an HTML-File into specified divs.
You can watch a demo.
The javascript that does the load job looks like the following:
function loadScreenie(elementSelector, sourceURL) {
$(""+elementSelector+"").load("img/screenies/"+sourceURL+"");
}
and gets invoked by a hyperlink looking like this:
mibmib
( i have also tried the same with onclick="")
This is the content of screenie2.htm
hello world<br />
<img src="screenie2.png" />
The problem is that images are not displayed. The behaviour is like this:
- you click the link and the javascript is executed.
- the text in screenie2.htm is displayed correctly in the correct div
- the image is not displayed. there also isnt any broken image symbol or an empty space.
Do you have an idea what could cause this error?
Thanks a lot in advance,
-- benny
Ok. Let me conclude to you what is happening here.
When link is clicked, jQuery loads "img/screenies/screenie2.htm
The image-tag <img src="screenie2.png" /> is inserted into the DOM.
So, we have an image linking to a supposed image at ./screenie2.png, where you would believe it should be linking to *./**img/screenies/**screenie2.png*.
You need to use absolute URLs in your load():ed content.
If you're testing with IE, the problem might be that Jquery uses innerHTML instead of creating individual dom elements with the load command. IE can be very finicky about that.