PDF File Conversion

Just read Javier Rodri­guez’s excellent blog post on PDF File Conversion and DL’ed the full project mentioned.
Copied the HTTPDocConverter class into my project and added the couple of code snippets as suggested in the article.
Ran my project. The code seemed to function as expected. However, when I open the created .pdf file with Preview, Safari, and Firefox I get the markup instead of a readable PDF doc.
“{\rtf1 \ansi \deff0 {\fonttbl {\f0\fnil Arial;}{\f1\fnil Lucida Grande;}{\f2\fnil Courier;}{\f3\fnil
Luminari;}}{\colortbl ;\red0\green0\blue0;\red255\green255\blue255;\red0\green0\blue255;}\margl720
\margr720 \margt720 \…etc”
Any idea what I might be doing wrong?

[quote=372541:@Roger Clary]{\rtf1 \ansi \deff0 {\fonttbl {\f0\fnil Arial;}{\f1\fnil Lucida Grande;}{\f2\fnil Courier;}{\f3\fnil
Luminari;}}{\colortbl ;\red0\green0\blue0;\red255\green255\blue255;\red0\green0\blue255;}\margl720
\margr720 \margt720 \[/quote]
These are rtf text file, not pdf.

Yes, that’s my problem. Why is the converter class not creating PDF files for me?
(and yes, the ext = .pdf)

Hi Roger,

That’s weird… what kind of file are you uploading as source? HTML, Plain text? Please, make sure that you are instantiating the class with the right format constant: HTTPDocConverter.kPDF for getting PDF files.

Dim post As New HTTPDocConverter( HTTPDocConverter.kPDF , f , AddressOf yourCallbackMethod) post.getConvertedFile

Javier

This Docverter looks really interesting. It’s too bad that the local installation is not one-click. Are headers/footers possible?

My own solution at the moment is to load html into a htmlviewer, convert this to pdf with the print to pdf functionality. Then header and footer are added with the MBS plugin. A tiny bit convoluted because the htmlviewer can only be used on the main thread.

I tried with a very nice Javascript library. Unfortunatley, this was slower than my html viewer solution.

Hi Beatrix,

I use my class Markddown Parser to get the HTML + CSS… and I think that CSS allows the header/footer thing. Then, I just need to use the HTMLDocConverter class to get the PDF to push (download)/save or preview.

Javier

Javier. I was feeding an rtf doc to the converter. Does it only work when fed a plain text file? If so, I don’t really see the point of the class. If I can’t feed it styled text for the PDF, then I might as well just distribute the plain text file itself.

Roger,

You can send styled text with HTML file format as source… and getting very convenient PDF, ePUB, MOBI, RTF or DOCX files as output.

As for the input, in addition to the above mentioned HTML, it is possible to send Markdown, textile, rst, docbook (DocBook XML) or latex (LaTeX) file formats… BTW: I realized now that it’s necessary a minor change in the class for setting the source format in the post header, so I’ll publish that minor change along the day.

@Javier Menéndez : I’m pushing GBs of data to PDF with confidential data. Using an online service is not possible.

@Beatrix Willius then… maybe you could be interested in wkhtmltopdf Adds a bunch of MBs to the deployment, but is local and no third-parties services involved. That’s what I’m using in Snippery.

Javier. Thanks for the clarification.

[quote=372553:@Beatrix Willius]This Docverter looks really interesting. It’s too bad that the local installation is not one-click. Are headers/footers possible?

My own solution at the moment is to load html into a htmlviewer, convert this to pdf with the print to pdf functionality. Then header and footer are added with the MBS plugin. A tiny bit convoluted because the htmlviewer can only be used on the main thread.

I tried with a very nice Javascript library. Unfortunatley, this was slower than my html viewer solution.[/quote]

i have been using wkhtmltopdf for the last few years for my application. work really well and you can have header and footer… even with footer on the last page

MBs???

@Richard Duke MBs = MegaBytes, sorry!

That is interesting , which version you use for that ? as I just read on the page that the latest one has a regression for the resolution or the dpi I guess.

Thanks.

Hi @Aurelian Negrea Snippery uses the 0.12.3 version.

i am using the one out in 20 Jan 2016… is it the 0.12.3??

well that would be the stable version, I guess I will have to reinstall it .

Any idea how to remove the title + date from the top and the document url from the bottom ?

Thanks.

[quote=372620:@Aurelian Negrea]well that would be the stable version, I guess I will have to reinstall it .

Any idea how to remove the title + date from the top and the document url from the bottom ?

Thanks.[/quote]

if u use wkhtmltopdf, i don’t think it is included.

@Richard Duke you can get the version from a Terminal session with: wkhtmltopdf -V