0

My Code

var path = Path.Combine(Directory.GetCurrentDirectory(), "Untitled-1.html");
        string htmlString = File.ReadAllText(path);
        Document document = null;
        using (var stream = new MemoryStream())
        {
            using (var pdfWriter = new PdfWriter(stream))

            using (var pdfDocument = new PdfDocument(pdfWriter))
            {

                ConverterProperties converterProperties = new ConverterProperties();
                pdfDocument.SetDefaultPageSize(PageSize.A4);
                pdfDocument.SetDefaultPageSize(PageSize.A4.Rotate());

                document = HtmlConverter.ConvertToDocument(htmlString, pdfDocument, converterProperties);
                document.SetMargins(0, 0, 0, 0);

            }

            File.WriteAllBytes("output.pdf", stream.ToArray());
        }

My setting is invalid. How should I set it? I need help, thank you very much!

enter image description here

This is my achievement, I want them to be completely attached to the top left corner

I need help, please post the corresponding code error

Gerhardh
  • 11,688
  • 4
  • 17
  • 39

0 Answers0