当今这个数字化时代,高效办公已经成为了每个企业和个人的追求。为了满足这一需求,我们隆重推出了一款名为"一键转换HTML至PDF"的智能在线转换器,它能够引领您迈向高效办公的新潮流。
首先,我们要进入首助编辑高手主页面,我们要在主页面上方的板块栏里选择“pdf工具箱”
第二步,进入板块之后,我们可以点击“添加文件”在弹出来的文件夹中将html的文件进行导入
第三步,导入完毕之后,我们就可以在表格上方下拉列表选择“html转PDF”即可。
第四步,设置完毕之后,我们就可以在下方选择文件的保存文章了,有两种,第一种是:保存在原位置,第二种是指定位置。小编选择的是第一种方式
第五步,如何指定位置?点击选择新位置,在弹出来的文件夹中选择好一个文件夹做为保存位置即可。
第六步,完毕都设置完毕之后,我们就可以点击开始转换,等状态栏显示转换成功,即可
第七步,在打开文件夹,我们就可以看见原来的html文件已经被一键切换成pdf文件了。
.表格的制作
1、表格元素–<table>
表格中的行–<tr>
表格中的列–<td>
表格中的表头–【居中/加粗】
table标记的边框–border
table标记的宽度–width
table标记的高度–height
table标记的水平对齐方式–align
table标记的表格背景色–bgcolor
table标记的表格边框色–bordercolor
table标记的表格中的内容与边框之间的距离–cellpadding
table标记的表格中的边框与边框之间的距离–cellspacing【默认是1px】
tr标记的align属性–设置当前行的水平对齐方式
tr标记的bgcolor属性–设置当前行的背景色
tr标记的valign属性–设置当前行的垂直对齐方式【top/middle/bottom】
td标记的align属性–设置当前列的水平对齐方式
td标记的bgcolor属性–设置当前列的背景色
td标记的valign属性–设置当前列的垂直对齐方式【top/middle/bottom】
合并单元格
水平方向合并单元格–跨列—colspan
以下是计算器的控制面板代码
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>计算器的控制面板</title>
</head>
<body>
<table border="1" cellspacing="10px" cellpadding="20px"
align="center" bgcolor="aliceblue">
<tr><td colspan="5" height="40px" align="right"><font size="7"><b>0</b></font></td></tr>
<tr align="center">
<td>MC</td>
<td>MR</td>
<td>MS</td>
<td>M+</td>
<td>M-</td>
</tr>
<tr align="center">
<td><-</td>
<td>CE</td>
<td>C</td>
<td>+/-</td>
<td>√</td>
</tr>
<tr align="center">
<td>7</td>
<td>8</td>
<td>9</td>
<td>/</td>
<td>%</td>
</tr>
<tr align="center">
<td>4</td>
<td>5</td>
<td>6</td>
<td>*</td>
<td>1/x</td>
</tr>
<tr align="center">
<td>1</td>
<td>2</td>
<td>3</td>
<td>-</td>
<td rowspan="2" bgcolor="yellow">=
</td>
</tr>
<tr align="center">
<td colspan="2">0</td>
<td>.</td>
<td>+</td>
</tr>
</table>
</body>
</html>
看成品:
2. 列表元素
2.1 有序列表
ol—有序列表
li—列表中的每一项【条目】
默认的标志是有顺序的数字
我们可以通过ol的type属性来修改标志
1–有顺序的数字
a–有顺序的小写字母
A–有顺序的大写字母
i–有顺序的小写罗马数字
I–有顺序的大写罗马数字
start属性设置书顺序的开始值
2.2 无序列表
ul—无序列表
li—列表中的每一项【条目】
默认的标志是实心点
我们可以通过ul的type属性来修改标志
circle–圆形【。】
disc----实心点[默认]
square–正方形
none–没有标志
2.3 自定义列表
dl—自定义列表
dt—自定义列表的头
dd—子项目
以下是有序,无序,和自定义列表
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>列表</title>
</head>
<body>
<ul type="none">
<li>无序列表</li>
<li>无序列表</li>
<li>无序列表</li>
</ul>
<ol type="A">
<li>有序列表</li>
<li>有序列表</li>
<li>有序列表</li>
</ol>
<dl>
<dt>自定义列表</dt>
<dt>自定义列表</dt>
<dt>自定义列表</dt>
</dl>
</body>
</html>
3. 表单<form>
主要负责采集信息的,可以将采集的信息提交。
form的属性
action—指定表单数据的后端处理程序
method----指定表单数据的提交方式【get[默认]/post】
get提交数据会将被处理的数据跟随在请求地址之后
被提交的数据255个字符
https://www.baidu.com/s?&wd=html
post提交数据会将被处理的数据封装到http协议的头
https://www.baidu.com/s
被提交的数据没有限制
通常情况下提交文件只能用post
enctype属性规定在将表单数据发送到服务器之前如何对其进行编码。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<table border="1" align="center" cellpadding="20px" cellspacing="0">
<tr>
<td>application/x-www-form-urlencoded</td>
<td>在发送前对所有字符进行编码(默认)。</td>
</tr>
<tr>
<td>multipart/form-data</td>
<td>不对字符编码。当使用有文件上传控件的表单时,该值是必需的。
</td>
</tr>
<tr>
<td>text/plain</td>
<td>将空格转换为 "+" 符号,但不编码特殊字符。</td>
</tr>
</table>
</body>
</html>
表单元素
input 文本框/密码框/单选按钮/复选框…
seletc 下拉列表
textarea 文本域—富文本编辑器
能转换:R图和统计表转成发表级的Word、PPT、Excel、HTML、Latex、矢量图等
R包export可以轻松的将R绘制的图和统计表输出到 Microsoft Office (Word、PowerPoint和Excel)、HTML和Latex中,其质量可以直接用于发表。
export包可以在Windows、Ubuntu和Mac上跨平台运行。不过有些Mac发行版默认情况下没有安装cairo设备,需要自行安装。如果Mac用户已安装XQuartz,这个问题就解决了,它可以从https://www.xquartz.org/免费获得。
install.packages("export")
install.packages("officer")
install.packages("rvg")
install.packages("openxlsx")
install.packages("ggplot2")
install.packages("flextable")
install.packages("xtable")
install.packages("rgl")
install.packages("stargazer")
install.packages("tikzDevice")
install.packages("xml2")
install.packages("broom")
install.packages("devtools")
devtools::install_github("tomwenseleers/export")
该包主要包括以下几种转换
使用帮助信息如下:
graph2bitmap(x = NULL, file = "Rplot", fun = NULL, type = c("PNG","JPG", "TIF"),
aspectr = NULL, width = NULL, height = NULL, dpi = 300,scaling = 100,
font =ifelse(Sys.info()["sysname"] == "Windows", "Arial",
"Helvetica")[[1]], bg = "white", cairo = TRUE,
tiffcompression = c("lzw", "rle", "jpeg", "zip", "lzw+p", "zip+p"),
jpegquality = 99, ...)
安装完 export包后,先调用该包
library(export)
library(ggplot2)
library(datasets)
x=qplot(Sepal.Length, Petal.Length, data = iris,
color = Species, size = Petal.Width, alpha = I(0.7))
qplot()的意思是快速作图,利用它可以很方便的创建各种复杂的图形,其他系统需要好几行代码才能解决的问题,用qplot只需要一行就能完成。
使用半透明的颜色可以有效减少图形元素重叠的现象,要创建半透明的颜色,可以使用alpha图形属性,其值从0(完全透明)到1(完全不透明)。更多ggplot2绘图见ggplot2高效实用指南 (可视化脚本、工具、套路、配色) (往期教程更有很多生物信息相关的例子)。
鸢尾花(iris)是数据挖掘常用到的一个数据集,包含150个鸢尾花的信息,每50个取自三个鸢尾花种之一(setosa,versicolour或virginica)。每个花的特征用下面的5种属性描述萼片长度(Sepal.Length)、萼片宽度(Sepal.Width)、花瓣长度(Petal.Length)、花瓣宽度(Petal.Width)、类(Species)。
在console里展示数据图 (长宽比自己调节):
# 需运行上面的ggplot2绘图
# Create a file name
# 程序会自动加后缀
filen <- "output_filename" # or
# filen <- paste("YOUR_DIR/ggplot")
# There are 3 ways to use graph2bitmap():
### 1. Pass the plot as an object
graph2png(x=x, file=filen, dpi=400, height = 5, aspectr=4)
graph2tif(x=x, file=filen, dpi=400, height = 5, aspectr=4)
graph2jpg(x=x, file=filen, dpi=400, height = 5, aspectr=4)
### 2. Get the plot from current screen device
# 注意这个x,是运行命令,展示图像
x
graph2png(file=filen, dpi=400, height = 5, aspectr=4)
graph2tif(file=filen, dpi=400, height = 5, aspectr=4)
graph2jpg(file=filen, dpi=400, height = 5, aspectr=4)
### 3. Pass the plot as a functio
plot.fun <- function(){
print(qplot(Sepal.Length, Petal.Length, data = iris,
color = Species, size = Petal.Width, alpha = 0.7))
}
graph2png(file=filen, fun=plot.fun, dpi=400, height = 5, aspectr=4)
graph2tif(file=filen, fun=plot.fun, dpi=400, height = 5, aspectr=4)
graph2jpg(file=filen, fun=plot.fun, dpi=400, height = 5, aspectr=4)
转换后的图形:
大部分图的细节修改都是用代码完成的,不需要后续的修饰;但如果某一些修改比较特异,不具有程序的通用性特征,或实现起来比较困难,就可以考虑后期修改。比如用AI文章用图的修改和排版。熟悉PPT的,也可以用PPT,这时R的图导出PPT,就要用到graph2office系列函数了。
graph2ppt: 将当前R图保存到Microsoft Office PowerPoint/LibreOffice Impress演示文稿中。
graph2doc:将当前的R图保存到Microsoft Office Word/LibreOffice Writer文档中。
函数参数展示和解释
graph2office(x = NULL, file = "Rplot", fun = NULL, type = c("PPT", "DOC"),
append = FALSE, aspectr = NULL, width = NULL, height = NULL,scaling = 100,
paper = "auto", orient = ifelse(type[1] == "PPT","landscape", "auto"),
margins = c(top = 0.5, right = 0.5, bottom = 0.5, left= 0.5),
center = TRUE, offx = 1, offy = 1, upscale = FALSE, vector.graphic = TRUE, ...)
# 需运行上面的ggplot2绘图
# Create a file name
filen <- "output_filename" # or
# filen <- paste("YOUR_DIR/ggplot")
# There are 3 ways to use graph2office():
### 1. Pass the plot as an object
# 导出图形对象
graph2ppt(x=x, file=filen)
graph2doc(x=x, file=filen, aspectr=0.5)
### 2. Get the plot from current screen device
# 导出当前预览窗口呈现的图
x
graph2ppt(file=filen, width=9, aspectr=2, append = TRUE)
graph2doc(file=filen, aspectr=1.7, append =TRUE)
### 3. Pass the plot as a function
# 导出自定义函数输出的一系列图
graph2ppt(fun=plot.fun, file=filen, aspectr=0.5, append = TRUE)
graph2doc(fun=plot.fun, file=filen, aspectr=0.5, append = TRUE)
导出到office(ppt和word)中的图形,是可编辑的:
其它导出到ppt的例子(设置长宽比)
graph2ppt(file="ggplot2_plot.pptx", aspectr=1.7)
增加第二张同样的图,9英寸宽和A4长宽比的幻灯片 (append=T,追加)
graph2ppt(file="ggplot2_plot.pptx", width=9, aspectr=sqrt(2), append=TRUE)
添加相同图形的第三张幻灯片,宽度和高度固定
graph2ppt(file="ggplot2_plot.pptx", width=6, height=5, append=TRUE)
禁用矢量化图像导出
graph2ppt(x=x, file=filen, vector.graphic=FALSE, width=9, aspectr=sqrt(2), append = TRUE)
用图填满幻灯片
graph2ppt(x=x, file=filen, margins=0, upscale=TRUE, append=TRUE)
函数参数解释
graph2vector(x = NULL, file = "Rplot", fun = NULL, type = "SVG",aspectr = NULL,
width = NULL, height = NULL, scaling = 100,
font = ifelse(Sys.info()["sysname"] == "Windows",
"Arial","Helvetica")[[1]], bg = "white", colormodel = "rgb",
cairo = TRUE,fallback_resolution = 600, ...)
#需运行上面的ggplot2绘图
# Create a file name
filen <- "output_filename" # or
# filen <- paste("YOUR_DIR/ggplot")
# There are 3 ways to use graph2vector():
### 1. Pass the plot as an object
# 导出图形对象
graph2svg(x=x, file=filen, aspectr=2, font = "Times New Roman",
height = 5, bg = "white")
graph2pdf(x=x, file=filen, aspectr=2, font = "Arial",
height = 5, bg = "transparent")
graph2eps(x=x, file=filen, aspectr=2, font = "Arial",
height = 5, bg = "transparent")
# 导出当前预览窗口呈现的图
### 2. Get the plot from current screen device
x
graph2svg(file=filen, aspectr=2, font = "Arial",
height = 5, bg = "transparent")
graph2pdf(file=filen, aspectr=2, font = "Times New Roman",
height = 5, bg = "white")
graph2eps(file=filen, aspectr=2, font = "Times New Roman",
height = 5, bg = "white")
# 导出自定义函数输出的一系列图
### 3. Pass the plot as a function
graph2svg(file=filen, fun = plot.fun, aspectr=2, font = "Arial",
height = 5, bg = "transparent")
graph2pdf(file=filen, fun=plot.fun, aspectr=2, font = "Arial",
height = 5, bg = "transparent")
graph2eps(file=filen, fun=plot.fun, aspectr=2, font = "Arial",
height = 5, bg = "transparent")
rgl2png: 将当前的rgl 3D图形保存为PNG格式。
rgl2bitmap(file = "Rplot", type = c("PNG"))
# Create a file name
filen <- tempfile("rgl") # or
# filen <- paste("YOUR_DIR/rgl")
# Generate a 3D plot using 'rgl'
x = y = seq(-10, 10, length = 20)
z = outer(x, y, function(x, y) x^2 + y^2)
rgl::persp3d(x, y, z, col = 'lightblue')
# Save the plot as a png
rgl2png(file = filen)
# Note that omitting 'file' will save in current directory
生成的3D图形:
将生成的3D图形保存为PNG格式:
table2spreadsheet(x = NULL, file = "Rtable", type = c("XLS", "CSV",
"CSV2"), append = FALSE, sheetName = "new sheet", digits = 2,
digitspvals = 2, trim.pval = TRUE, add.rownames = FALSE, ...)
# Create a file name
filen <- "table_aov" # or
# filen <- paste("YOUR_DIR/table_aov")
# Generate ANOVA output
fit=aov(yield ~ block + N * P + K, data = npk) # 'npk' dataset from base 'datasets'
x=summary(fit)
# Save ANOVA table as a CSV
### Option 1: pass output as object
# 输出对象
table2csv(x=x,file=filen, digits = 1, digitspvals = 3, add.rownames=TRUE)
# 屏幕输出导出到文件
### Option 2: get output from console
summary(fit)
table2csv(file=filen, digits = 2, digitspvals = 4, add.rownames=TRUE)
# Save ANOVA table as an Excel
# Without formatting of the worksheet
x
table2excel(file=filen, sheetName="aov_noformatting", digits = 1, digitspvals = 3, add.rownames=TRUE)
# 更多参数
# With formatting of the worksheet
table2excel(x=x,file=filen, sheetName="aov_formated", append = TRUE, add.rownames=TRUE, fontName="Arial", fontSize = 14, fontColour = rgb(0.15,0.3,0.75), border=c("top", "bottom"), fgFill = rgb(0.9,0.9,0.9), halign = "center", valign = "center", textDecoration="italic")
原始数据的表格:
转换格式之后的,在console中的数据:
文件(csv和excel)中表格数据:
table2ppt: 导出统计输出到Microsoft Office PowerPoint/ LibreOffice Impress演示文稿中的表
table2doc: 将统计输出导出到Microsoft Office Word/ LibreOffice Writer文档中的表
table2office(x = NULL, file = "Rtable", type = c("PPT", "DOC"),
append = FALSE, digits = 2, digitspvals = 2, trim.pval = TRUE,
width = NULL, height = NULL, offx = 1, offy = 1,
font = ifelse(Sys.info()["sysname"] == "Windows", "Arial",
"Helvetica")[[1]], pointsize = 12, add.rownames = FALSE)
# Create a file name
filen <- "table_aov"
# filen <- paste("YOUR_DIR/table_aov")
# Generate ANOVA output
fit=aov(yield ~ block + N * P + K, data = npk) # 'npk' dataset from base 'datasets'
# Save ANOVA table as a PPT
### Option 1: pass output as object
x=summary(fit)
table2ppt(x=x,file=filen, digits = 1, digitspvals = 3, add.rownames =TRUE)
### Option 2: get output from console
summary(fit)
table2ppt(x=x,file=filen, width=5, font="Times New Roman", pointsize=14, digits=4, digitspvals=1, append=TRUE, add.rownames =TRUE) # append table to previous slide
# Save ANOVA table as a DOC file
table2doc(x=x,file=filen, digits = 1, digitspvals = 3, add.rownames =TRUE)
summary(fit)
table2doc(file=filen, width=3.5, font="Times New Roman", pointsize=14, digits=4, digitspvals=1, append=TRUE, add.rownames =TRUE) # append table at end of document
将表格数据导出到ppt和word中:
table2html: 导出统计输出到HTML表。
table2tex(x = NULL, file = "Rtable", type = "TEX", digits = 2,
digitspvals = 2, trim.pval = TRUE, summary = FALSE, standAlone = TRUE,
add.rownames = FALSE, ...)
summary:是否汇总数据文件。
standAlone:导出的Latex代码应该是独立可编译的,还是应该粘贴到另一个文档中。
add.rownames:是否应该将行名添加到表中(在第一列之前插入一列)。
# Create a file name
filen <- tempfile(pattern = "table_aov") # or
# filen <- paste("YOUR_DIR/table_aov")
# Generate ANOVA output
fit=aov(yield ~ block + N * P + K, data = npk) # 'npk' dataset from base 'datasets'
x=summary(fit)
# Export to Latex in standAlone format
table2tex(x=x,file=filen,add.rownames = TRUE)
# Export to Latex to paste in tex document
summary(fit) # get output from the console
table2tex(file=filen, standAlone = FALSE,add.rownames = TRUE)
# Export to HTML
table2html(x=x,file=filen) # or
summary(fit) # get output from the console
table2html(file=filen,add.rownames = TRUE)
导出到html或tex中的表格数据:
*请认真填写需求信息,我们会在24小时内与您取得联系。