gmanny / Pechkin

.NET Wrapper for WkHtmlToPdf static DLL. Allows you to utilize full power of the library.
401 stars 128 forks source link

Adding Bookmarks #28

Open junaid-anwar opened 11 years ago

junaid-anwar commented 11 years ago

Thanks for giving us this helpful tool to create PDF so easily.

Im using this tool in my Asp.Net Website and I have following questions:

1) How can i create PDF page by page by passing HTML to every page of PDF separately. 2) I want to add bookmarks to every page. 3) Is there a way to make PDF document Password protected?

How can i do these things. Please help me as im badly stuck on some task.

Thanks once again

gmanny commented 11 years ago

Hello, thank you.

The first question has already been asked, and unfortunately wkhtmltopdf doesn't support such scenario. (Or I didn't research it enough.)

The second question I didn't understand, could you explain, what do you mean by bookmarking a page?

junaid-anwar commented 11 years ago

thanks for your reply. Actually i want to add bookmarks to jump to that specific content on the pdf. Here is an example screenshot attached

bookmarks

junaid-anwar commented 11 years ago

My last question was Can we make the PDF Password protected. I mean the pdf should ask for Password if someone tries to open it.

gmanny commented 11 years ago

To add to the answer of the first question, you can generate separate PDFs ffrom each page and then join them with other tools or methods, which are easily discoverable.

For the second question, use ObjectConfig.SetIncludeInOutline(true) to embed an outline into the PDF. Based on the quote from wkhtmltopdf docs

The outlines are generated based on the <h?> tags

So, you don't have much control of them.

gmanny commented 11 years ago

Password-protecting PDFs is, again, not possible, as stated in the support question on wkhtmltopdf:

There is no way to encrypt the pdf from wkhtmltopdf currently, nor do I think there will be in the feature. Please use another tool afterwards to encrypt the pdf (pdftk).

junaid-anwar commented 11 years ago

Thanks alot for your response.Thats so nice of you.

mattki commented 11 years ago

For anyone wondering, I think the bookmarks are generated from h1 and possibly h2 tags throughout the HTML document. In the footer and header text [section] and [subsection] placeholders correspond to the first h1 or h2 tag content on the current page.