Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSS not included in converted document #50

Open
brysonreece opened this issue Dec 22, 2016 · 4 comments
Open

CSS not included in converted document #50

brysonreece opened this issue Dec 22, 2016 · 4 comments

Comments

@brysonreece
Copy link

brysonreece commented Dec 22, 2016

I'm currently accessing the Docverter API via cURL to convert some documents, like so:

$url = 'http://c.docverter.com/convert';
$fields = array(
	'from' => $_POST["inputButton"],
	'to' => $_POST["outputButton"],
	'input_files[]' => "@/" . $uploadedFilePath,
	'other_files[]' => "@retro.css"
);

//open connection
$ch = curl_init();

//set options
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-type: multipart/form-data"));
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //needed so that the $result=curl_exec() output is the file and isn't just true/false

//execute POST
$result = curl_exec($ch);

//close connection
curl_close($ch);

//write to file
$convertedFile = fopen($convertedFilePath, 'w');
fwrite($convertedFile, $result);
fclose($convertedFile);

Note: retro.css is located in the same directory as this page and to/from values are determined from the POST values of two separate buttons.

However, no matter what formats I try to convert from/to, the CSS contents of retro.css are never included in the converted document.

@peterkeen
Copy link
Collaborator

peterkeen commented Dec 23, 2016 via email

@brysonreece
Copy link
Author

brysonreece commented Dec 23, 2016

Changing my $fields array to

$fields = array(
	'from' => $_POST["inputButton"],
	'to' => $_POST["outputButton"],
	'css' => "retro.css", // or @retro.css
	'input_files[]' => "@/" . $uploadedFilePath,
	'other_files[]' => "@retro.css"
);

still fails for HTML -> PDF. My documents gets converted, however no CSS styling is included.

@peterkeen
Copy link
Collaborator

peterkeen commented Dec 23, 2016 via email

@brysonreece
Copy link
Author

Like so?

$fields = array(
	'from' => $_POST["inputButton"],
	'to' => $_POST["outputButton"],
	'input_files[]' => "@/" . $uploadedFilePath,
	'other_files[]' => "@retro.css",
	'stylesheet' => "retro.css"
);

My second example seemed to work when converting Markdown -> PDF, however this example is returning an error when going from Markdown -> PDF and still not including styling when going from HTML -> PDF.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants