【问题标题】:JavaFX WebView displays HTML difference to Libre Office WriterJavaFX WebView 向 Libre Office Writer 显示 HTML 差异
【发布时间】:2016-10-15 01:49:15
【问题描述】:

我使用 SceneBuilder 2 创建了一个 Dialog 来托管一个 WebView,我打算用它来显示帮助 (HTML) 文档。

然后我在 Libre Office Writer 中创建了一个 HTML 文档。

“Help.html”文件已加载,但 WebView 中的行距与我在 Libre 中看到的不同。

我想在 WebView 中看到我在 Libre 中看到的内容。

我需要设置一些 Style 属性吗?段落中的文本正确换行,就是 CR/LF 后的间距过大。

Controller的初始化方法:

public void initialize(URL url, ResourceBundle rb) 
{           
    WebEngine webEngine = webView.getEngine();

    // Load HTML Content
    webEngine.load(getClass().getResource("/SampleHelp.html").toExternalForm());
}

HTML 格式的 SampleHelp.html 文件。

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <title></title>
    <meta name="generator" content="LibreOffice 4.2.8.2 (Linux)">
    <meta name="created" content="20161014;0">
    <meta name="changed" content="20161015;90732380852526">
    <style type="text/css">
    <!--
        @page { margin-left: 1cm; margin-right: 1cm }
        p { color: #000000 }
    -->
    </style>
</head>
<body lang="en-AU" text="#000000" dir="ltr" style="background: transparent">
<p align="center" style="margin-bottom: 0cm"><font size="1" style="font-size: 8pt"><u><b>Load
File</b></u></font></p>
<p style="margin-bottom: 0cm; page-break-before: auto; page-break-after: auto">
<font size="1" style="font-size: 8pt"><u>Purpose</u>: To load files
provided by a Service Provider, that holds all relevant information
about a given event.</font></p>
<p style="margin-bottom: 0cm"><br>
</p>
<p style="margin-bottom: 0cm"><font size="1" style="font-size: 8pt">For
this reason file loading is considered to be 'Automatic', and
requires minimal input. </font>
</p>
<p style="margin-bottom: 0cm"><br>
</p>
<p style="margin-bottom: 0cm"><font size="1" style="font-size: 8pt"><u><b>Load
File – Saleyard</b></u></font></p>
<p style="margin-bottom: 0cm"><font size="1" style="font-size: 8pt">The
operator needs to:</font></p>
<p style="margin-bottom: 0cm"><font size="1" style="font-size: 8pt">(1)
Choose a Saleyard </font>
</p>
<p style="margin-bottom: 0cm"><font size="1" style="font-size: 8pt">The
first dialog opens to show a list of all Saleyards registered in the
system.</font></p>
<p style="margin-bottom: 0cm"><font size="1" style="font-size: 8pt">Select
one and press the 'OK' button to accept the selection, or 'Cancel' to
stop the process.</font></p>
<p style="margin-bottom: 0cm"><br>
</p>
<p style="margin-bottom: 0cm"><font size="1" style="font-size: 8pt">(2)
Choose a file.</font></p>
<p style="margin-bottom: 0cm"><font size="1" style="font-size: 8pt">A
FileChooser Dialog opens in the Saleyards directory ( home/Livestock
Manager/Source/Saleyards), which shows a sub-directory for each
registered Saleyard.</font></p>
<p style="margin-bottom: 0cm"><font size="1" style="font-size: 8pt">Open
the relevant provider's directory, and choose the relevant event file
(.xml). </font>
</p>
<p style="margin-bottom: 0cm"><br>
</p>
<p style="margin-bottom: 0cm"><font size="1" style="font-size: 8pt">The
system will then:</font></p>
<ul>
    <p style="margin-bottom: 0cm"><font size="1" style="font-size: 8pt">-
    check to see that the file is from the nominated Saleyard</font></p>
    <p style="margin-bottom: 0cm"><font size="1" style="font-size: 8pt">-
    check to ensure this event ( provider + event date) has not been
    loaded before</font></p>
    <p style="margin-bottom: 0cm"><font size="1" style="font-size: 8pt">-
    load the relevant data</font></p>
</ul>
<p style="margin-bottom: 0cm"><br>
</p>
<p style="margin-bottom: 0cm"><font size="1" style="font-size: 8pt"><b>Recommended</b></font></p>
<p style="margin-bottom: 0cm"><a name="__DdeLink__16_440979877"></a><font size="1" style="font-size: 8pt">Once
loaded, it is recommended that you view ( see menu option View / Edit
– Saleyard ) the results, to verify the number of head bought and
sold, and the cost. The quality of data supplied varies according to
provider. So, this also provides an opportunity to improve the data
by updates to Breed, Sex, and Has Calf as appropriate.</font></p>
<p style="margin-bottom: 0cm"><br>
</p>
<p style="margin-bottom: 0cm"><br>
</p>
<p style="margin-bottom: 0cm"><br>
</p>
</body>
</html>

WebView(和 Mozilla FireFox)中显示的 SampleHelp.html:

加载文件

目的:加载由服务提供商提供的文件,其中包含有关给定事件的所有相关信息。

因此,文件加载被认为是“自动”的,需要最少的输入。

加载文件 - Saleyard

运营商需要:

(1) 选择销售场

第一个对话框打开,显示系统中注册的所有 Saleyards 的列表。

选择一个并按“确定”按钮接受选择,或按“取消”停止该过程。

(2) 选择一个文件。

FileChooser 对话框在 Saleyards 目录 (home/Livestock Manager/Source/Saleyards) 中打开,其中显示每个已注册 Saleyard 的子目录。

打开相关提供者的目录,选择相关事件文件(.xml)。

然后系统会:

- check to see that the file is from the nominated Saleyard

- check to ensure this event ( provider + event date) has not been loaded before

- load the relevant data

推荐

加载后,建议您查看(请参阅菜单选项查看/编辑 - Saleyard )结果,以验证购买和出售的人头数量以及成本。提供的数据质量因提供商而异。因此,这也提供了一个机会,可以通过适当更新 Breed、Sex 和 Has Calf 来改进数据。

在 Libre Office Writer 中:(如果我在这里剪切并过去,它也不能正确地描述这一点。)WebView 显示是正确的,它只是段落之间的间距(在 CR/LF 之后)这就是问题所在。

例如标题“Load File - Saleyard”和接下来的四行应该是连续的,即它们之间没有空格。然后下一个标题“(2)选择一个文件”的空格,接下来的3行应该是连续的。 然后在下一个标题“The system will then:”处留一个空格,接下来的 3 行是连续的。

加载文件 目的:加载由服务提供商提供的文件,其中包含有关给定事件的所有相关信息。

因此,文件加载被认为是“自动”的,并且需要最少的输入。

加载文件 – Saleyard 运营商需要: (1) 选择销售场 第一个对话框打开,显示系统中注册的所有 Saleyards 的列表。 选择一个并按“确定”按钮接受选择,或按“取消”停止该过程。

(2) 选择一个文件。 在 Saleyards 目录 (home/Livestock Manager/Source/Saleyards) 中打开一个 FileChooser 对话框,其中显示每个已注册 Saleyard 的子目录。 打开相关提供者的目录,并选择相关事件文件 (.xml)。

然后系统将: - 检查文件是否来自指定的 Saleyard - 检查以确保之前未加载此事件(提供者 + 事件日期) - 加载相关数据

推荐 加载后,建议您查看(参见菜单选项查看/编辑 - Saleyard)结果,以验证购买和出售的人头数量以及成本。提供的数据质量因提供商而异。因此,这也提供了一个机会,可以通过适当更新 Breed、Sex 和 Has Calf 来改进数据。

【问题讨论】:

  • 对我来说,短期内的答案在于使用不同的 HTML 编辑器。我怀疑 Libre Office Writer 中生成的 HTML 有问题导致行间距问题。
  • 我确实希望 Libre 能够以所见即所得的方式工作,但显然不是。这是一个已知的错误,还是我遗漏了什么?

标签: html css javafx webview libreoffice


【解决方案1】:

目前,我已决定使用使用最少标签和格式的 BlueFish HTML 编辑器。

我仍然想知道为什么用 Libre Office Writee 编写并保存为 HTML 的文档在浏览器中的外观与您编写时的外观不同?

HTML 是:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
    <meta name="generator" content="Bluefish 2.2.5" >
    <meta name="created" content="20161014;0">
    <meta name="changed" content="20161015;74147709157253">
<title></title>
</head>
<body>
<span style="text-decoration: underline;">Purpose:</span> To load files provided by a Service Provider, that holds all relevant information about an event.<br>
<br>
For this reason file loading is considered to be 'Automatic', and requires minimal input.<br>
<br>
<b><span style="text-decoration: underline;">Load File - Saleyard</span></b><br>
The operator needs to:<br>
(1) <span style="text-decoration: underline;">Choose a Saleyard</span><br>
The first dialog opens to show a list of all Saleyards registered in the system.<br>
Select one and click on the 'OK' button to accept the selection, or 'Cancel' to stop the process.<br>
<br>
(2) <span style="text-decoration: underline;">Choose a File</span><br>
A FileChooser dialog opens in the Saleyards directory (home/Livestock Manager/Source/Saleyards), which shows a sub-directory for each registered Saleyard.<br>
Open the relevant Saleyard directory, and choose the relevant event file (.xml).<br>
<br>
The system will then :<br>
- check to see that the file  is from the nominated Saleyard<br>
- check to ensure this event (provider + event date) has not been loaded before<br>
- load the relevant data<br>
<br>
<b>Recommended</b><br>
Once loaded, you show view the results (see menu option View / Edit - Saleyard) to verify the numbers of head bought and sold, and the cost.<br>
The quality of data supplied varies between providers. So, this provides an opportunity to improve the data, via updates to Breed, Sex and Has Calf as appropriate.<br>
<br>
<br>
<b><span style="text-decoration: underline;">Load File - KillSheet</span></b><br>
This process is similar for consistency.
However, at present each registered Abattoir provides it's own file type and structure. Since most Livestock are slaughtered at JBS Dinmore, this is the only file loaded automatically.<br>
<br>
The operator needs to:<br>
(1) Choose an Abattoir<br>
The first dialog opens to show a list of all Abattoirs (where the entry type is 'Automatic') registered in the system.<br>
Select one and click on the 'OK' button to accept the selection, or 'Cancel' to stop the process.<br>
</body>
</html>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-08-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多