Open fabiangehring opened 8 years ago
If there is no quick fix, is there a "logic" what dimensions (and margin) there will be, when generating a pdf. i.e. 1.5 times viewport or similar. This would make it easier to cut the image afterwards?
I'm not sure offhand exactly what the problem is. It might have something to do with this: https://vnese.wordpress.com/2013/07/31/casperjs-captures-pdf-of-a-page-with-media-print/
When I open the .pdf file in Chrome and hit Ctrl-P, it also wants to print two pages, even though it uses a completely different rendering engine from PhantomJS. I wonder if there are some hidden elements that are making plotly graphs want a second page when printed. If so, it may be fixable with @media print
of the plot's CSS, but the fix would have to be in plotly. cc @cpsievert
Sorry, I won't be much help here, but @timelyportfolio might know more, or could suggest a way to take advantage of the native plotlyjs snapshot support
hi, I just came accross this issue again. Unfortunately this does not seem to be a plotly issue. It seems to happen with pdf-outputs in general.
The following mre shows 1) margins and 2) does not seem to respect the selector
data <- data.frame(a = 1:9, b = c(5, 2, 3, 9, 4, 3, 1, 5, 3))
table <- datatable(data)
htmlwidgets::saveWidget(widget = table, file = "table.html")
webshot("table.html", file = "table.pdf", selector = "#DataTables_Table_0", expand = 10, zoom = 2)
Screenshot:
If this could be fixed that'd be great.
Bump. I just came by this issue, and it seems to persist. Any chance this could be resolved?
Thanks!
I also got this problem in my work. Can it be resolved? Thank You.
Use the new orca()
function. Note the height
/width
is in pixels, but you can convert to inches by multiplying by 96 (assuming you're using a typical display)
I am also having this problem. I have tried to specify
vwidth = 8.25 * 96,
vheight = 11.75 * 96,
and either cliprect = "viewport"
or cliprect = c(0, 0, 8.25 * 96, 11.75 * 96)
but I am unable to get webshot to generate a PDF with pages of the correct size. They always end up very tall with lots of blank space at the bottom.
I have chosen these numbers to produce a PDF with A4 pages at 96dpi.
Is there some way to force webshot to not create PDF pages larger than a certain size?
When using webshot to generate a pdf from a plotly (using latest CRAN 3.6.0) diagram I get a margin right and at the bottom and a second empty page. I don't get the margin nor the empty page when creating a png. A pdf is preferred since it's vectorised. This has direct implications when using knitr reports. The margin makes it difficult to size the diagram within the report. Png is no alternative here because of worse quality.
I wasn't able to suppress the margin with current dev. If there are possibilities, I'd glad to know. If there's none it would help a lot if this could be implemented.