Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print PDF from HTML string #31

Open
yasin-96 opened this issue Sep 5, 2023 · 1 comment
Open

Print PDF from HTML string #31

yasin-96 opened this issue Sep 5, 2023 · 1 comment

Comments

@yasin-96
Copy link

yasin-96 commented Sep 5, 2023

Hey` guys,

I am trying to figure out why my code is not working as expected.
I have markdown source code, which I am converting with: https://github.com/gomarkdown/markdown
It is giving me some html string, which I am trying to print to a PDF, but when I print it to a PDF the HTML tags are ignored and just plaintext is printed.

My code:

_, lineHt := pdf.GetFontSize()
html := pdf.HTMLBasicNew()
convertedHTML := convertMarkdown(subchapter.Content)
println(string(convertedHTML))
html.Write(lineHt, string(convertedHTML))
err := pdf.OutputFileAndClose(fmt.Sprintf("%s.pdf", course.Name))
func convertMarkdown(subchapterContent string) []byte {
	extensions := parser.CommonExtensions | parser.OrderedListStart | parser.NoEmptyLineBeforeBlock
	p := parser.NewWithExtensions(extensions)
	doc := p.Parse([]byte(subchapterContent))

	htmlFlags := html.CommonFlags | html.HrefTargetBlank
	opts := html.RendererOptions{Flags: htmlFlags}
	renderer := html.NewRenderer(opts)

	return markdown.Render(doc, renderer)
}

The convert returns me this string

<h2>Chapter outcomes</h2>

<p>At the end of this page you should be able to:</p>

<ul>
<li>Explain how the Cloud Native Computing Foundation (CNCF) defines the Cloud Native terms and their core characteristics.</li>
<li>Describe monolith vs. microservices architecture approaches with examples as well as the benefits and drawbacks of both approaches.</li>
<li>Describe different autoscaling options in Cloud Native environments.</li>
<li>Describe the concept and benefits of serverless computing.</li>
<li>Explain community and governance</li>
<li>Explain the roles and personas that exist within Cloud Native environments and their corresponding tasks?</li>
<li>Describe which open standards are available in Cloud Native world and what they are used for?</li>
</ul>
@yasin-96
Copy link
Author

yasin-96 commented Sep 9, 2023

Can anybody help with this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant