PDF conversion

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
6/25/2011 6:58:33 AM
Gravatar
Total Posts 537
feet planted firmly on the ground

PDF conversion

I'm trying to use the PDF conversion as described here http://www.mojoportal.com/adding-a-save-to-pdf-feature-using-an-external-service.aspx

but I end up with mangled text and even the wrong page being converted (not the one I was looking at when I clicked the button).

I'm wondering whether this could be integrated more tightly into mojoPortal using something like this:

http://code.google.com/p/wkhtmltopdf/

which has a c# wrapper here

https://github.com/pruiz/WkHtmlToXSharp

This can be referenced in .Net and you just pass any page to it and it creates the PDF which you can then open in a new window. No 3rd-party web site or advertising etc.

An example (passing in URL and filename):

...

Dim fullfilepath As String = ConfigurationManager.AppSettings("HtmlToPdfStorageDirectory") + "\\" + outputFilename + ".pdf"
  If a Is Nothing Then
   a = New WkHtmlToXSharp.MultiplexingConverter()
  End If
  a.GlobalSettings.Margin.Top = "20mm"
  a.GlobalSettings.Margin.Bottom = "15mm"
  a.GlobalSettings.Margin.Left = "20mm"
  a.GlobalSettings.Margin.Right = "20mm"
  a.GlobalSettings.Orientation = WkHtmlToXSharp.PdfOrientation.Portrait
  a.ObjectSettings.Page = Url
  a.ObjectSettings.Web.EnableJavascript = True
  a.ObjectSettings.Web.Background = True
  a.ObjectSettings.Web.LoadImages = True

  Dim res As Byte() = a.Convert()
  File.WriteAllBytes(fullfilepath, res)

etc

yours

Crispin

 

 

 

6/27/2011 7:36:18 AM
Gravatar
Total Posts 18439

Re: PDF conversion

Sorry but that is not something I would ever include in mojoPortal. Even the author of the C# wrapper explains that it is not safe for a multi threaded environment like a web application, he processes the files by a windows service.

Also P/Invoking against a native dll will not work in medium trust hosting.

So it is the kind of thing where you would only use the web to manage a queue of urls to be processed into pdf and then the windows service could generate the pdf and put it somewhere so it was available for download in the web app. One could do that kind of thing as a custom feature and a custom windows service if you had full control of the server, but its not a candidate for inclusion in mojoPortal.

Best,

Joe

6/27/2011 2:39:16 PM
Gravatar
Total Posts 537
feet planted firmly on the ground

Re: PDF conversion

Ah OK - a poor solution, though we might run with it as a custom feature using a Win service as you suggest.

Problem is the http://www.web2pdfconvert.com service creates an unusable result (even from the mojoPortal documentation page); the page heading text is all mixed up.

So just wondering if there's anything better coming along?

cheers

Crispin

6/28/2011 6:16:57 AM
Gravatar
Total Posts 18439

Re: PDF conversion

The article on our site was written by the guy who made the pdf service at web2pdfconvert.com

It is not a feature of mojoPortal and I'm not at all involved with it, the integration is just markup so it isn't anything specific to mojoPortal. The guy asked if he could write a tutorial and it seemed like it might be useful to some users of mojoPortal so I said ok.

I would suggest share your feedback with the folks who manage that site or google for alternate services that do the same thing maybe you can find a better one.

Best,

Joe

You must sign in to post in the forums. This thread is closed to new posts.