GithubHelp home page GithubHelp logo

Comments (3)

cderv avatar cderv commented on June 13, 2024

Are you using a pagedown format for R Markdown ? Or are you just using chrome_print() directly on the HTML file ?

If I open you document in a browser, and run Chrome print on it, it won't apply. Not an issue with pagedown - just your document does not work to print in browser like you expect, even without the package.

I believe rules like @top-left or @bottom-right-corner still requires Paged.js and not just a print to PDF using Chrome (which chome_print() does). margin and size are more native so works.

For context, this is the whole point of Paged.js (https://pagedjs.org/about/)

Paged.js follows the Paged Media standards published by the W3C (ie the Paged Media Module, and the Generated Content for Paged Media Module). In effect Paged.js acts as a polyfill for the CSS modules to print content using features that are not yet natively supported by browsers.

pagedown is allowing to use Paged.js in HTML output document so that they can be printed paginated. If I put your CSS in a custom.css

h1 {
  color:blue;
}
h2 {
  color:red;
}
@page {
  size: 8.5in 11in;
  margin: 10%;
  @top-left{
    content: "Please Write something";
    border: solid green;
  }
}
p {
  color: green;
}

and they, add it to a pagedown::html_paged format then it works as expected

---
title: test
output: 
  pagedown::html_paged:
    css: ["custom.css", "default-fonts", "default-page", "default"]
---

# My First Heading

## My Second Heading

My first paragraph.
  • Paginated view of your document
    image

This will print accordingly, but could require some tweaking regarding margin elements size. Docs for paged.js margin processing: https://pagedjs.org/documentation/7-generated-content-in-margin-boxes/. More doc at https://pagedjs.org/documentation/

So overall, you may need to use paged.js more directly. Either using this R package or another way.

Hope it helps.

If I misunderstood your question, please do share more details

from pagedown.

JaydenCole-55 avatar JaydenCole-55 commented on June 13, 2024

This is great, thank you. I am using Quarto (the "next generation of R Markdown") to produce reports. Although most R Markdown files can be rendered through Quarto without modification, from what I understand, the pagedown output format is not possible in Quarto files ( yet ;) ). Let me know if I am incorrect.

In short, I will look for a way to integrate the paged.js script more directly into Quarto documents.

Thank you for the great help.

from pagedown.

cderv avatar cderv commented on June 13, 2024

You can still use pagedjs-cli tool to print any HTML document using Paged.js
https://pagedjs.org/documentation/2-getting-started-with-paged.js/#command-line-version

So you can

  • Render with Quarto to HTML
  • Print a paginated version using Paged.js CLI tool.

But yes there is no specific paged.js integration with Quarto HTML yet. So maybe some stuff won't be correctly formated or printed. You should try.

from pagedown.

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.