I know this is an old thread but the error that I get relates to this library (or my ignorance). I have taken your script from your example.html in the /Files folder and created a string lateral with it. Then used your library method to pass the string literal to your library to create the PDF. The sub looks as follows and creates the PDF successfully that can be opened with and of the PDF viewers that I have on my device:
[CODE lang="b4x" title="Creates an openable PDF"]Sub Print
'Works only on devices with SDK >= 21
Dim rr As RuntimePermissions
rr.CheckAndRequest(rr.PERMISSION_WRITE_EXTERNAL_STORAGE)
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
Activity.LoadLayout("0")
phtmltopdf.Initialize("phtmltopdf")
'You can't use a file from the assets folder
' File.Copy(File.DirAssets,"example.html",File.DirInternal,"example.html")
'You can create the pdf directly from an html file
Dim ssl As String = $"
<html>
<!-- Text between angle brackets is an HTML tag and is not displayed.
Most tags, such as the HTML and /HTML tags that surround the contents of
a page, come in pairs; some tags, like HR, for a horizontal rule, stand
alone. Comments, such as the text you're reading, are not displayed when
the Web page is shown. The information between the HEAD and /HEAD tags is
not displayed. The information between the BODY and /BODY tags is displayed.-->
<head>
<title>Enter a title, displayed at the top of the window.</title>
</head>
<!-- The information between the BODY and /BODY tags is displayed.-->
<body>
<h1>Enter the main heading, usually the same as the title.</h1>
<p>Be <b>bold</b> in stating your key points. Put them in a list: </p>
<ul>
<li>The first item in your list</li>
<li>The second item; <i>italicize</i> key words</li>
</ul>
<p>Improve your image by including an image. </p>
<p><img src="https://alternative.me/icons/basic4android.png" alt="A Great HTML Resource"></p>
<p>Add a link to your favorite <a href="https://www.dummies.com/">Web site</a>.
Break up your page with a horizontal rule or two. </p>
<hr>
</body>
</html>"$
phtmltopdf.ConvertFromString(ssl,File.DirRootExternal,"example.pdf")
End Sub[/CODE]
When I remove the last 4 lines of script the PDF created will not open:
B4X:
Sub Print
'Works only on devices with SDK >= 21
Dim rr As RuntimePermissions
rr.CheckAndRequest(rr.PERMISSION_WRITE_EXTERNAL_STORAGE)
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
Activity.LoadLayout("0")
phtmltopdf.Initialize("phtmltopdf")
'You can't use a file from the assets folder
' File.Copy(File.DirAssets,"example.html",File.DirInternal,"example.html")
'You can create the pdf directly from an html file
Dim ssl As String = $"
<html>
<!-- Text between angle brackets is an HTML tag and is not displayed.
Most tags, such as the HTML and /HTML tags that surround the contents of
a page, come in pairs; some tags, like HR, for a horizontal rule, stand
alone. Comments, such as the text you're reading, are not displayed when
the Web page is shown. The information between the HEAD and /HEAD tags is
not displayed. The information between the BODY and /BODY tags is displayed.-->
<head>
<title>Enter a title, displayed at the top of the window.</title>
</head>
<!-- The information between the BODY and /BODY tags is displayed.-->
<body>
<h1>Enter the main heading, usually the same as the title.</h1>
<p>Be <b>bold</b> in stating your key points. Put them in a list: </p>
<ul>
<li>The first item in your list</li>
<li>The second item; <i>italicize</i> key words</li>
</ul>
<hr>
</body>
</html>"$
phtmltopdf.ConvertFromString(ssl,File.DirRootExternal,"example.pdf")
End Sub
Why wont the PDF be openable?