-1

I am trying to implement an API which can convert URLs into PDF using PDFsharp. PDFsharp website doesn't have any info whether it has that functionality or not. Anybody used PDFsharp to create PDF from URL?

I have played with PDFsharp code, I did not find way to implement it. In Google also I did not find much info.

  • 1
    To clarify: do you mean a _website_, or a _URL_? Note that the latter includes everything, even my database connection string: `mongodb://localhost:27017`. – ProgrammingLlama Aug 28 '19 at 05:04
  • By the way, if you do mean a _website_, it seems that there's a tool called "html2pdf" which might do this for you, although I've never used it and can't vouch for it. – ProgrammingLlama Aug 28 '19 at 05:11
  • 1
    Here is a way to convert Word or HTML to PDF with C# that is free of charge: https://stackoverflow.com/questions/46580718/convert-word-doc-and-docx-format-to-pdf-in-net-core-without-microsoft-office-in – Jeremy Thompson Aug 28 '19 at 05:14
  • I have used [pdfreactor](https://www.pdfreactor.com) which you can provide a url to create pdf – huMpty duMpty Aug 28 '19 at 09:07

2 Answers2

2

The answer is no, nowhere does it say it can convert HTML to PDF.

  • Creates PDF documents on the fly from any .NET language
  • Easy to understand object model to compose documents
  • One source code for drawing on a PDF page as well as in a window or on the printer
  • Modify, merge, and split existing PDF files
  • Images with transparency (color mask, monochrome mask, alpha mask)
  • Newly designed from scratch and written entirely in C#
  • The graphical classes go well with .NET

Yes, there are libraries that do this (with varying success), consider JavaScript and CSS and all the shenanigans that can appear on a web-page, it's rife with problems. However, you will need to research these yourself.

halfer
  • 19,824
  • 17
  • 99
  • 186
TheGeneral
  • 79,002
  • 9
  • 103
  • 141
1

Maybe you ask the wrong question.

If you want to convert HTML to PDF then you can find the answer in the FAQ list on the site:

Can I use PDFsharp to convert HTML or RTF to PDF?
No, not "out of the box", and we do not plan to write such a converter in the near future.

Yes, PDFsharp with some extra code can do it. But we do not supply that extra code. On NuGet and other sources you can find a third party library "HTML Renderer for PDF using PdfSharp" that converts HTML to PDF. And there may be other libraries for the same or similar purposes, too. Maybe they work for you, maybe they get you started.

http://www.pdfsharp.net/wiki/PDFsharpFAQ.ashx#Can_I_use_PDFsharp_to_convert_HTML_or_RTF_to_PDF_10