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
Added support for a cover page when generating a PDF (#2004) #4342
Conversation
Usually (for us) a cover page does not contain a lot of text but is more of a page with special layout, e.g. A big title centered in the middle, a smaller subtitle, a company logo, no footers no headers, maybe a date and copyright notice in a small special font. So the markdown is not really the problem. The bigger problem is: How can I define that special layout for the cover page alone? How can I have footers or headers with page numbering on all of my pages but not on the cover page (and the ToC pages)? Does this PR make those things easier or even possible? |
Hi @bitbonk. I think footers, headers, page numbers, and having the ability to provide a different layout for different pages are different issues. |
I think one point from @bitbonk is that is is not flexible to use a Markdown file to define a cover page. IMO, a cover page is like some title in the middle of a page, but we can only get an upper-left H1 header by a Markdown input. With this, I'd prefer a Of course I rarely use this PDF feature, so I'd like to here your thoughts. @bitbonk @icnocop |
@bitbonk mentioned
I understood that as "Markdown is fine." Was I mistaken? In any case, markdown is flexible enough so we're not limited to only an upper-left H1 header. For example, this markdown file will generate a page with "Cover Page Title" in the middle of the page:
With these changes, if you name the file Requiring a PDF file as the cover page doesn't seem very flexible or document-author-friendly to me. |
In regards to changing page margins, I think I agree with @PhilterPaper's comment here: wkhtmltopdf/wkhtmltopdf#3635 (comment)
In that way, each page could have it's own margins defined from within the page itself. We may want to also think about that approach for overriding the headers and footers in specific pages for example. Instead of HTML comments, it may be better if they were "markdown comments". So basically, instead of littering |
Another approach other than using "markdown comments" is to have an accompanying JSON or YAML file for each markdown file that contains these properties. For example cover.md.json:
Those options would correspond to wkhtmltopdf's page, header, and footer options. However, wkhtmltopdf doesn't currently support setting different margins and orientation for different pages. |
@icnocop Thank you for your thoughts. It convinced me that PDF is not an ideal cover input. My other concern is whether we need Inspired by your example, I think I still have no ideas about the margin issue. I agree this could be another separate topic. |
I think I would like it better if I just could provide a cover.html (that uses the styles of my PDF DocFX template) or even a cover.pdf instead of cover.md. There wouldn’t be much text I‘d add to a cover page, hence the cover.md is not very useful. In my use cases, the cover page is more about layouting and less about (text)content. |
I think it should be recommended that In this way, the generated
If you start from scratch, using the default PDF template, and want to create an HTML file for the cover page, you don't have access to the CSS styles as part of the template; you'll have to extract the default pdf template first in order to use the CSS styles which are part of the template in order to create a cover page in HTML. Using a This is more in-line with how other conceptual documentation files are processed through the pipeline - using a markdown file. If you want to use HTML files as a type of input, it seems like that HTML file should be part of the template, where other HTML and CSS files exist as part of the pipeline. |
Agree to make this as a convention. You are right that we need not care about site or manifest things here.
👍 I like this idea. The detailed design in DocFX template system could be:
With the default cover page template, user can define cover page easily. If user has many custom style needs as @bitbonk mentinoed, go to custom |
@superyyrrzz , thank you very much for your detailed review. I have resolve your review comments in the latest commits as part of this PR. I also added support for using For now, the template simply renders the text as in your sample However, I didn't understand what you meant by:
Can you clarify that for me please? Thank you! |
@icnocop Thank you for the updates! I will review soon.
This just means use the HtmlToPdfConverter to generate PDF, as what your PR already did. Run |
src/Microsoft.DocAsCode.HtmlToPdf/CoverPage/CoverPageProcessor.cs
Outdated
Show resolved
Hide resolved
Added {{{conceptual}}} to cover HTML template Removed unneeded cover page processor
Thanks again for your guidance! 💯 I've pushed another commit with the changes as you've suggested. |
…ontents" Using FilePathComparer.OSPlatformSensitiveRelativePathComparer to compare directory names Require cover.md to be in the same directory as toc.yml
@icnocop Thank you for contribution for this amazing feature! |
You're welcome. Thank you @superyyrrzz for the quick feedback! 🎉 |
No description provided.