Solved

Shell function and wkhtmltopdf in vb

Posted on 2011-03-12
2
1,299 Views
Last Modified: 2012-05-11
I need to to convert html files into pdf. I found this program, wkhtmltopdf, that seems to meet my needs. It runs from a command line, which I call by means of the shell function. I succeed doing basic conversion, but as soon as I try to customize it using some options, the program does nothing. I must missuse either the shell function or wkhtmltopdf itself, but I don't know what I'm doing wrong. I tryed with other basic options but none seems to work.

In the code attached Com0  works fine (there is no option), but Com1 fails. The latter uses an option I'm interested in (disabling the smart shrinking propoerty)
Dim Com1 As String, Com0 As String
    Dim path As String
    Dim Id As Double
    Dim File As String, File1 As String


    path = "C:\Documents and Settings\Francesc\Mis documentos\E-Gestion\wkhtmltopdf\wkhtmltopdf.exe"
    File = "file:///C:/Documents and Settings/FFFF/A.html"
    File = Replace(File, "\", "/")
    File = Replace(File, " ", "%20")
    
    File1 = "C:\Documents and Settings\FFFF\A.pdf"
    Com0 = path & " " & File & " " & Chr(34) & File1 & Chr(34)
    Com1 = path & " " & File & " " & Chr(34) & File1 & Chr(34) & " --disable-smart-shrinking"

   
    Call Shell(Com)

Open in new window

0
Comment
Question by:Pakhu1
2 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 35116736
Try putting quotes around all the files/paths:

    Com1 = Chr(34) & path & Chr(34) & " " & Chr(34) & File & Chr(34) & " " & Chr(34) & File1 & Chr(34) & " --disable-smart-shrinking"
0
 

Author Comment

by:Pakhu1
ID: 35119318
Thanks:

Again the same result: it works without option but not when adding that or any other option
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question