How to Generate PDF from Markdown Using Pure Ruby

NodeJS - Compile markdown into pdf (from a string in memory) and download it on web page

For such a thing, I recommend building your .pdf file first a HTML file, so you could edit it easily (hardcoded or dynamicaly)
then convert your html file to .pdf file.
there is alot of packages to do this

have a closer look on this package
https://www.npmjs.com/package/html-pdf-node

Dynamically Generate Editable PDF

Prince doesn't mention forms in the documentation, and renders forms as static drawings, so I doubt it.

pdfTeX can do it with the hyperref package. Here's a tutorial.

Example:

\usepackage{hyperref}
\begin{Form}
\TextField[backgroundcolor={1 1 0},value=can do forms]{hyperref}
\end{Form}

It looks like this:

screenshot http://grab.by/23nP

(Of course, then you're using TeX instead of whatever reports library you like. I'm sure there's an alternative.)

Markdown to create pages and table of contents?

MultiMarkdown Composer does seem to generate a table of contents to assist while editing.

There might also be the one or the other library, who can generate TOCs: see Python Markdown TOC Extension.

Generating PDF files with JavaScript

I've just written a library called jsPDF which generates PDFs using Javascript alone. It's still very young, and I'll be adding features and bug fixes soon. Also got a few ideas for workarounds in browsers that do not support Data URIs. It's licensed under a liberal MIT license.

I came across this question before I started writing it and thought I'd come back and let you know :)

Generate PDFs in Javascript

Example create a "Hello World" PDF file.

// Default export is a4 paper, portrait, using milimeters for unitsvar doc = new jsPDF()
doc.text('Hello world!', 10, 10)doc.save('a4.pdf')
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.5/jspdf.debug.js"></script>

PDFizer: how to inset picture in generated pdf document?

After some testing, this is what you need to do:

  • Create a Folder in which you will have all of your Images.
  • If you already have an instance of Pdfizer.HtmlToPdfConverter change the ImagePath Attribute to point to the folder where your images reside.
  • Include the <img> tags in your html code.
  • Make sure the images are in the folder.

Note: I tried adding Png files and got a conversion error. Here is an example I took from the site you provided, plus my modifications:

System.Text.StringBuilder sbHtml = new System.Text.StringBuilder();
sbHtml.Append("<html>");
sbHtml.Append("<body>");
sbHtml.Append("<font size='14'>My Document Title Line</font>");
sbHtml.Append("<img src='trollface.jpg' />");
sbHtml.Append("<br />");
sbHtml.Append("This is my document text");
sbHtml.Append("</body>");
sbHtml.Append("</html>");

//create file stream to PDF file to write to
using (System.IO.Stream stream = new System.IO.FileStream

(sPathToWritePdfTo, System.IO.FileMode.OpenOrCreate))
{
// create new instance of Pdfizer
Pdfizer.HtmlToPdfConverter htmlToPdf = new Pdfizer.HtmlToPdfConverter();
// open stream to write Pdf to to
htmlToPdf.Open(stream);
htmlToPdf.ImagePath = Server.MapPath(ResolveUrl("~/Images"));

// write the HTML to the component
htmlToPdf.Run(sbHtml.ToString());
// close the write operation and complete the PDF file
htmlToPdf.Close();
}
}

Good luck!



Related Topics



Leave a reply



Submit