wkhtmltopdf breaking line with negative values - django

I am using wkhtmltopdf on a Ubuntu server. The problem I have been facing is that negative big numbers break lines. I saw this thread: Prevent Breaking of Negative Numbers. My values are read directly from the database, and differently from this guy I don't add a hyphen.
Negative numbers:
Positive:
This is after I upgraded to version wkhtmltopdf 0.12.2.1 (with patched qt). On version 0.9.9, which I had been using I had no problem with PDF generation. I upgraded because in Django, Views which inherited the PDF class from django-wkhtmltopdf would give an error code 1, not generating PDF.
PDFs are generated through command line:
command = 'xvfb-run wkhtmltopdf --footer-right "[page]/[topage]" {s} {o}'.format(
s=html_file.name,
o=target.name
)
I tried to add --zoom 0.5 as a parameter to that command, but only made the PDF worse. Half of the text got cut out off the page and can't be read.

Try with replacing minus sign with − html entity.

I had the same issue. After much time of investigation, I discovered that you can solve the issue if you put min-width (css) in the column (td).
You must be sure that the min-width is enought for the value of td.
After that all work like a charm!
Good Look!

Just create a CSS rule, that says, the text should not wrap.
td.no-wrap {
white-space: nowrap;
}

Related

Adding preamble.tex and/or modifying css

Thanks for making papaja. It's really terrific!
I just submitted my first journal article using it and ran into problems. The layout staff don't know what to do with the code chunks and listings that are fine in single-column, full page format, but not in their 2-column format. I'm trying use the class 'jou' option to make 2 columns, but I can't figure out how to control the size of code and listing fonts (possibly by modifying the css, as recommended here), or how to using the latex package 'listings' to set listings to wrap (as recommended here).
I'd be grateful for any advice, and my apologies if I've missed how one might do this in the documentation.
If it's only about getting the listings package to work, you can modify the YAML header that it looks similar to the following:
documentclass : "apa6"
classoption : "jou"
output :
papaja::apa6_pdf:
pandoc_args: --listings
header-includes:
- \lstset{breaklines=true}
However, note that using automatic line breaks will most likely break the code at some points. Therefore, it is worthwhile to consider alternatives: For instance, you could try to use a code style that uses more line breaks. The styler package and add-in might be helpful accomplishing this: https://styler.r-lib.org/

content empty when using scrapy

Thanks for everyone in advance.
I encountered a problem when using Scrapy on Python 2.7.
The webpage I tried to crawl is a discussion board for Chinese stock market.
When I tried to get the first number "42177" just under the banner of this page (the number you see on that webpage may not be the number you see in the picture shown here, because it represents the number of times this article has been read and is updated realtime...), I always get an empty content. I am aware that this might be the dynamic content issue, but yet don't have a clue how to crawl it properly.
The code I used is:
item["read"] = info.xpath("div[#id='zwmbti']/div[#id='zwmbtilr']/span[#class='tc1']/text()").extract()
I think the xpath is set correctly and I have checked the return value of this response and it indeed told me that there is nothing under this directory. Results shown here:'read': [u'<div id="zwmbtilr"></div>']
If it has something, there should be something between <div id="zwmbtilr"> and </div>.
Really appreciated if you guys share any thoughts on this!
I just opened your link in Firefox with NoScript enabled. There nothing inside the <div #id='zwmbtilr'></div>. If I enable the javascripts, I can see the content you want. So, as you already new, it is a dynamic content issue.
Your first option is try to identify the request generated by javascript. If you can do that, you can send the same request from scrapy. If you can't do it, the next option is usually to use some package with javascript/browser emulation or someting like that. Something like ScrapyJS or Scrapy + Selenium.

Possible bug in Blade templating system with html special characters

I'm not necessarily sure about this but it seems there's something strange going on with umlauts, accented characters and such on Blade templates with Laravel 5.1.
I was banging my head on the wall with a string that ended in an ä-letter which I really, really couldn't get decoded with html_entity_decode no matter what I tried.
Here's what I had in my Blade template file as I was going mad:
{{ html_entity_decode('just-another-string-ä') }}
Now, when I render the template in a browser window I obviously get:
just-another-string-ä
But in the source I have the following:
just-another-string-äauml;
Which in my understanding does not stand for the string that I had given in the blade template.
...several minutes pass by...
After a while I changed the string to:
just-another-string-ä-test
And as a source-code result I get:
just-another-string-ä-test
Which indeed is much easily decoded than the "almost-double-auml" I got with the first string. In addition to the final letter/word replace I also noticed that things work as expected when I enter a line break in the Blade template after the line.
{{ html_entity_decode('just-another-string-ä') }}
{{-- erase this comment --}}
And everything is in order in the source code:
just-another-string-ä
Have I completely missed something here or does this smell like a bug?
Okay I've found the problem, though not really much of a solution.
After looking into this I found that it's not a Blade issue. Neither is it PHP or Apache - it's your browser.
For example, just create yourself an HTML file with the following contents:
this-is-a-string-ä
For me (at least in Chrome, I haven't tested other browsers), this will produce the same issues as you are seeing. If you have no trailing newline, view source will break, but if you do have one, it's fine.
So the solution is simple, enable the "blank newline at end of file" setting in your text editor. You should really have this turned on anyway, for example diffs work a touch better with a blank line at the end of a file (they don't see a difference where there is none), which means, by extension, version control systems like Git handle them a bit better. And it doesn't really hurt to have this enabled that I've ever found.
I would imagine that this is almost certainly a known issue, but I haven't looked into Chrome issue tracker or anything. Feel free to do so though, if you do want to get to the bottom of it. I'd be interested to know :)

How do I change TOC location in wkhtmltopdf output?

I need the TOC to be on the 3rd page. Apparently, if there is a way to control this, it has to be through the XSL stylesheet. All my search attempts didn't give me a clue though. Is it possible at all?
I can't use cover option since I need the header to show on both first and second pages.
OK I've found a way to do it using wkhtmltopdf 0.11. I've extracted the first two pages into a separate HTML document and then run it like this
wkhtmltopdf [options] page cover.html toc --xsl-style-sheet ... input_file.html out.pdf
Unfortunately it took a lot more effort than I expected, since I'm using it in a Rails application through wicked_pdf, and it doesn't play nice with the new options format, so I had to fork it and make the necessary changes as well.
The command line generated by wicked_pdf looks like this (long paths omitted):
"c:/program files (x86)/wkhtmltopdf/wkhtmltopdf.exe"
--header-html "file:///path/to/header" --footer-html "file:///path/to/footer"
--margin-top 20 --margin-bottom 15 --margin-left 5 --margin-right 40 page "file:///path/to/cover/page" --disable-javascript toc --xsl-style-sheet "path/to/style/sheet" - -

Problem with DEVMODE.dmCopies field

I'm writing a printing application and i having trouble with dmCopies field of DEVMODE structure. This field specifies number of document copies printed. When i print multipage document (two pages and more) - setting up dmCopies works fine, but when one-page document printed dmFields ignored. First i think that problem in my application, but in standard microsoft example (http://code.msdn.microsoft.com/WindowsPrintSample) it present too. What ways for workaround of that ? Thanks.
The problem is probably specific to your printer (assuming Microsoft code is not buggy (no ?))
Maybe this page can help you:
http://support.microsoft.com/kb/197393
The end of the report speaks about some workarounds to dmcopies.