Giter Site home page Giter Site logo

Multiple pages about dinktopdf HOT 6 CLOSED

rdvojmoc avatar rdvojmoc commented on June 9, 2024 1
Multiple pages

from dinktopdf.

Comments (6)

rdvojmoc avatar rdvojmoc commented on June 9, 2024 16

Here is an example of what you can do:

// set up the document
HtmlToPdfDocument doc = new HtmlToPdfDocument()
{
       GlobalSettings = {
              PaperSize = PaperKind.A4,
              Orientation = Orientation.Portrait,
              Margins = new MarginSettings() { Top = 10, Left = 10, Right = 10 },
           },
};

// add object settings to the document
foreach (var item in items)
{
      var page = new ObjectSettings()
       {
               PagesCount = true,
               WebSettings = { DefaultEncoding = "utf-8" },
               HtmlContent = item
       };
       doc.Objects.Add(page);
}

//convert
var pdf = _converter.Convert(doc);

This covers your use case?

from dinktopdf.

rdvojmoc avatar rdvojmoc commented on June 9, 2024

Can you provide more details what you want to achieve - maybe an example.

from dinktopdf.

deniscesar avatar deniscesar commented on June 9, 2024

Example: set list ObjectSettings to Objects - create multiple pages dynamic

List<ObjectSettings> pages = new List<ObjectSettings>();
foreach (var item in items)
{
	var page = new ObjectSettings() {
		PagesCount = true,
		WebSettings = { DefaultEncoding = "utf-8" },
		HtmlContent = @"<h5>item.Name</h5>"
    };
    pages.Add(page);
}

var doc = new HtmlToPdfDocument()
{
    GlobalSettings = {
        PaperSize = PaperKind.A4,
        Orientation = Orientation.Portrait,
        Margins = new MarginSettings() { Top = 10, Left = 10, Right = 10 },
    },                    
    Objects = pages;
    
};

byte[] pdf = _converter.Convert(doc);

from dinktopdf.

deniscesar avatar deniscesar commented on June 9, 2024

Thank you!

from dinktopdf.

tgyuner avatar tgyuner commented on June 9, 2024

Thank you, God Bless!

from dinktopdf.

anishagrwl avatar anishagrwl commented on June 9, 2024

HI @rdvojmoc , I am trying to add multiple pages, but after the first page, subsequent pages are printed blank. Any idea how can this be solved?

from dinktopdf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.