richard-scryber / scryber.core

Scryber.Core is a dotnet 6 html to pdf engine written entirely in C# for creating beautiful flowing documents from html templates including css styles, object data binding and svg drawing.
Other
194 stars 31 forks source link

Scryber is not filling the template. #136

Closed Matt-17 closed 5 months ago

Matt-17 commented 6 months ago

Describe the bug I just wanted to get into Scryber, as it seems very promising. But I cannot even get the minimal sample to work.

To Reproduce

Hello World Hello {{author}}!
- Add this code to `Program.cs`

using Scryber.Components;

using var doc = Document.ParseDocument("Test.html"); doc.Params["author"] = "Hello World"; using var stream = new MemoryStream(); doc.SaveAsPDF(stream);

var fileContents = stream.ToArray(); File.WriteAllBytes("Test.pdf", fileContents);


- Start program
- PDF shows "**Hello {{author}}!**"

**Expected behavior**
A PDF saying "**Hello Hello World!**"

**Screenshots**
![grafik](https://github.com/richard-scryber/scryber.core/assets/11333169/a3e0d05a-d1e1-47ec-89a1-d83b9dc0e181)

**Desktop (please complete the following information):**
 - OS: Windows 10

**Additional context**
Is there anything I missed? I used https://scrybercore.readthedocs.io/en/latest/ to create this. 
richard-scryber commented 5 months ago

Hi @Matt-17, sorry for the slow response.

If you haven't managed to sort this, please upgrade to the latest version 6.x.x (beta) - There are a few things we need to sort before really pushing it out and these may affect layout.

Version 5 docs are here, and use the {@:author} notation.

I hope this helps.

Richard

Matt-17 commented 5 months ago

Sorry for my late answer. Thank you for your answer. I tried it out and it worked so far, but I got some issues, that pushed me back to iTextSharp. But I can close this issue, as it's solved by your answer. ;-)

Just to add my problems: I could not get rid of the header/footer margins when adding those to the page. I know it's supposed to be like this, but I could not figure out to create a well looking document. The second issue is the template engine, here I would not implement an own, while there are existing good ones like RazorLight or Handlebars.Net. I haven't figured out yet, if there is the need for an own engine. Just my 2 cents. I am watching this project and hopefully I can use this one in future, as it looks very promising. Thank you!

richard-scryber commented 5 months ago

Hi Matt, I appreciate the feedback - thank you, although slightly saddens me you were not able to get scryber to do what you wanted, especially as I hoped the design and visual side is one of it's core strengths.

Without wishing to try and counter, there are strong implementation reasons for the roll your own engine (css, path binding etc), and a body with padding 0px, and then inner main or section with padding should alleviate your header and footer issues.

If there is anything else you were having issues with I would love to hear about it. This feedback is valuable to me as it comes from someone who is not completely immersed in and tailored to the engine's layout mechanisms.

Richard