I have a project in vuejs and I have to use vue-html2pdf.
When I write text the in tag: <section>something</section>, my PDF is generated.
But when I write in tag: <section><p>something</p></section>, my browser is crashes.
Here my code in vuejs:
<vue-html2pdf
:show-layout="false"
:preview-modal="true"
:paginate-elements-by-height="10"
:filename="test"
:pdf-quality="2"
:pdf-format="size"
:ref="ref"
>
<section slot="pdf-content">
<section class="pdf-item">
<img :src=url>
</section>
</section>
</vue-html2pdf>
And my function to download PDF:
function generateReport() {
this.$refs.html2Pdf.generatePdf();
}
vue-html2pdf npm module does not work properly. Rather than you can try html2pdf module for convert html to pdf in vuejs.
Package link: https://www.npmjs.com/package/html2pdf.js/v/0.9.1
Codesandbox Example: https://codesandbox.io/s/xlnzq7y28q
Hope that, your problem will be solved. Thanks.
I just saw this, I am the developer of vue-html2pdf, and I tested your code on version 1.3.6, it worked perfectly on Chrome Version 81.0.4044.138, Microsoft Edge 44.18362.449.0 and Firefox 76.0.1.
you also have a typo on <img :src=url> it should be <img :src="url">
and if you can, can you please provide the values of the variables test, size, and ref, you assigned to the props.
and the prop :paginate-elements-by-height="10" I think the value should be higher, try 1300.
After losing my day I found the problem !
Here 2 sources of error :
-If you use a "component" inside the "vue-html2pdf", the page break couldn't work.
To solve this problem, use "vue-fragment" library <3
-If you use a too small value for "paginate-elements-by-height" attribute, the "vue-html2pdf will bug and then you can just kill the process. By default it's 1300 or 1400, try with 1600 or more and your problem will solved.
fixed this problem: Impossible to convert html code to pdf with vue-html2pdf
the first of all i have set packages in the such following sequence
1. npm i jspdf#1.5.2
2. npm i html2pdf.js#0.9.1
3. npm i vue-html2pdf#1.8.0
On time the passing some steps to create pdf file i got mistake
`TypeError: str.charAt(...) is not a function`.
or on another configuration for vue-html2pdf i am getting the console messages:
- Dom Has Rendered
- 0ms html2canvas: html2canvas $npm_package_version
- 926ms html2canvas: Document cloned, using computed rendering
- 926ms html2canvas: Starting node parsing
- 947ms html2canvas: Finished parsing node tree
- 948ms html2canvas: Finished loading 0 images Array(0)
- 949ms html2canvas: Starting renderer
- 950ms html2canvas: Canvas renderer initialized (816x18 at 312,63) with scale 2
- 959ms html2canvas: Render completed
but pdf file no created
I fixed this problem:
when i looked at "node_modules\html2pdf.js\package.json"
and i have seen
"dependencies": {
"es6-promise": "^4.2.5",
"html2canvas": "^1.0.0-alpha.12",
"jspdf": "^1.4.1"
}
then from "myproject\package.json" -
I have replaced
"dependencies": {
from "jspdf: ^1.5.2" to "jspdf: ^1.4.1"
so need to set
1. npm i jspdf#1.4.1
2. npm i html2pdf.js#0.9.1
3. npm i vue-html2pdf#1.8.0
so you should look at *jspdf version* into "node_modules\html2pdf.js\package.json"
Related
So, I am trying to follow a number of the file pond example and each of them include some form of CSS import (I get it, there is a lot that comes with beauty). However, no matter what I try, Filepond or Pintura (formerly Doka), I get this error in some form:
Compiled with problems:
ERROR in ./node_modules/filepond-plugin-image-preview/dist/filepond-plugin-image-preview.min.css
Module build failed (from ./node_modules/style-loader/dist/cjs.js):
ValidationError: Invalid options object. Style Loader has been initialized using an options object that does not match the API schema.
- options should be an object:
object { injectType?, attributes?, insert?, base?, esModule?, modules? }
at validate (/Users/ryanolson/github/realkinkmen/node_modules/style-loader/node_modules/schema-utils/dist/validate.js:105:11)
at Object.loader (/Users/ryanolson/github/realkinkmen/node_modules/style-loader/dist/index.js:25:29)
ERROR in ./node_modules/filepond/dist/filepond.min.css
Module build failed (from ./node_modules/style-loader/dist/cjs.js):
ValidationError: Invalid options object. Style Loader has been initialized using an options object that does not match the API schema.
- options should be an object:
object { injectType?, attributes?, insert?, base?, esModule?, modules? }
at validate (/Users/ryanolson/github/realkinkmen/node_modules/style-loader/node_modules/schema-utils/dist/validate.js:105:11)
at Object.loader (/Users/ryanolson/github/realkinkmen/node_modules/style-loader/dist/index.js:25:29)
I have NO IDEA how to fix this as I am not experienced enough with what would be going on. I am guessing it has to do with Webpack and build but no idea what I need to do to fix it. Any help?
I also want to mention this is a Laravel/VueJS/Tailwind stack
The solution is to add the CSS files to the app.css file under /resources/css/app.css
#import 'filepond/dist/filepond.min.css';
#import "filepond-plugin-image-preview/dist/filepond-plugin-image-preview.min.css";
I have been trying to use publicRuntimeConfig / privateRuntimeConfig
On nuxt 2.4.1, I have defined my runtime config as follows on nuxt.config.js
publicRuntimeConfig: {
DATA_API_HOST_URL: process.env.VUE_APP_DATA_API_HOST_URL,
},
privateRuntimeConfig: {
AUTH_APP_CLIENT_SECRET: process.env.VUE_APP_AUTH_APP_CLIENT_SECRET,
},
and calling it as follows on my login.vue
asyncData( ctx ) {
console.log(ctx.$config.DATA_API_HOST_URL)
//some activity
}
The keys are showing up on $config inside asyncData. I debugged on chrome dev tools. But value is not read from process.env.VUE_APP_DATA_API_HOST_URL. The value is showing up as undefined. However, process.env.VUE_APP_DATA_API_HOST_URL is showing the value OK. The whole point is to move away from process.env.
this.$config.DATA_API_HOST_URL also does not access the values.
'${DATA_API_HOST_URL}' is shown in examples but I believe it is only for explicit param declarations at asyncData like asyncData( { $config : {DATA_API_HOST_URL}).
When I pass values as it is using DATA_API_HOST_URL: process.env.VUE_APP_DATA_API_HOST_URL || 'https://test.api.com', it seems to copy the value fine using ctx.$config.DATA_API_HOST_URL!
Looking to me like copying process.env to *RuntimeConfig has a problem!
What is the recommended way of importing and using runtime configurations?
As per documentation in the Nuxt blog post you marked, the feature your are trying to use is released in 2.13 (you´re using 2.4 if i not misunderstood). That could be the reason behind the behaviour you're seeing.
I'd recommend update your project dependencies or trying another approach.
I think you should use Docker to set dynamic runtime config like link below:
https://dev.to/frontendfoxes/dockerise-your-nuxt-ssr-app-like-a-boss-a-true-vue-vixens-story-4mm6
I have done a fresh install of bootstrap version 4.1.1
I created a custom.scss file and put the following in it (straight from bootstrap4 online docs)
// Your variable overrides
$body-bg: #000;
$body-color: #111;
// Bootstrap and its default variables
#import "node_modules/bootstrap/scss/bootstrap";
When I run npm run dis, i'm receiving the following error:
scss/custom.scss
2:1 × Expected !default flag for "$body-bg" scss/dollar-variable-default
3:1 × Expected !default flag for "$body-color" scss/dollar-variable-default
According to bootstraps documentation you must remove the "!default" but the error specifies you must have the "!default".
I'm assuming I'm overlooking something but I can't seem to figure out what it is.
So, the default installation of bootstrap has a file called .stylelintrc. This is the configuration file for stylelint.
For some reason, the example given on bootstraps website is not in alignment to the default configuration of the .stylelintrc file.
You need to change the line
"scss/dollar-variable-default": [false, { "ignore": "local" }]
to
"scss/dollar-variable-default":null
In order to get their example working.
I'm writing a Bootstrap 3 theme using Harp.js / jade / less
When I try to dynamically change the background color using less.modifyVar() function, the stylesheet is correctly reloaded but nothing happens ...
Less code (variables.less) :
#green : #59B75F;
#blue : #0081C5;
#base-color : #green;
Less code (custom.less) :
#import "variables.less";
.some_class {
background-color: #base-color;
}
Jade code :
link(href="css/custom.css", rel="stylesheet/less", type="text/css")
script(src="bower_components/less/dist/less.min.js")
....
a(href="#", onclick="javascript:switchColor('#0081C5');") Blue
....
Javascript switchColor() function :
var switchColor = function(color) {
less.modifyVars({'#base-color':color});
less.refreshStyles();
};
Any help would be appreciated. C.
sorry for any confusion. Harp v0.15.2 is the latest version, and is still running LESS v1.x. We have just been working on updating to LESS 2.5.0 this weekend and it landed in Terraform, Harp’s preprocessing engine.
A new release of Harp will be out very soon that will include that update. (We’ll post it on Twitter if you’d like a notification.)
Edit Harp v0.17.0 is now the latest version, upgrading should fix this problem:
npm install --global harp
I have been attempting to implement a custom dojo build to replace the dojo version that comes with spring roo 1.1.5.
I followed the instructions at
http://sagittech.blogspot.com/2011/08/asdadsad-qwasdace-aavvrv-place-holder.html
as well as
http://www.qc4blog.com/?p=1001
I have been able to create the builds.
My problem is that when I place the new build into the project like
WEB-INF\classes\META-INF\web-resources\dojo-1.6.2\
(FYI: I renamed the version from 1.6.1 to 1.6.2 to avoid conflict with same version as in
Roo.)
When I load my web page I get
syntax error
http://localhost:8080/app-1.0.0/resources/dojo-1.6.2/dojo/dojo.js
Line 14
also
missing ) after argument list
http://localhost:8080/app-1.0.0/
Line 3
dojo is not defined
http://localhost:8080/app-1.0.0/resources/spring/Spring-Dojo.js
Line 16
So, the question is:
What is the proper way to integrate a new custom dojo build with Spring Roo?
Is there a special way to build dojo to make this happen?
Are there additional steps required to make a custom build work with Roo?
Update:
Below is my profile file to create the new dojo.js
dependencies = {
optimize:"shrinksafe",
stripConsole: "normal",
cssOptimize: "comments",
layers:
[
{
name: "dojo.js",
layerDependencies:
[
"dojo.js",
],
dependencies:
[
"dijit.Dialog",
"dijit.Tooltip",
"dijit.form.DateTextBox",
"dijit.form.CheckBox",
"dijit.form.CurrencyTextBox",
"dojox.widget.Standby",
"dijit.form.ComboBox",
"dijit.form.FilteringSelect",
"dojox.form.PasswordValidator",
"dojo.parser",
"dijit.form.Form",
"dojox.grid.EnhancedGrid",
"dojo.data.ItemFileWriteStore",
"dijit.TitlePane",
"dijit.layout.LayoutContainer",
"dijit.layout.BorderContainer",
"dijit.form.SimpleTextarea",
"dijit.form.Textarea",
"dojo.date.locale",
"dojo.data.ItemFileReadStore",
"dojox.grid.cells.dijit",
"dojox.grid.DataGrid",
"dijit.form.Button",
"dijit.form.ValidationTextBox",
"dijit.Dialog",
"dijit.form.NumberSpinner",
"dojox.grid.enhanced.plugins.Menu",
"dojox.grid.enhanced.plugins.NestedSorting",
"dojox.grid.enhanced.plugins.IndirectSelection",
"dijit.MenuItem",
"dijit.MenuSeparator",
"dijit.PopupMenuItem",
"dijit.Menu",
"dojox.form.Uploader",
"dojox.form.uploader.FileList",
"dojox.form.uploader.plugins.Flash",
"dijit.form.Select"
]
}
],
prefixes: [
["dijit", "../dijit"],
["dojox", "../dojox"]
]
}
After making sure that I made the new optimized file the same as dojo.js to insure that dojo was found I now get the following error:
failed loading /app-1.0.0/resources/dojo-1.6.2/dojo/./parser.js with error: SyntaxError: syntax error
http://localhost:8080/app-1.0.0/resources/dojo-1.6.2/dojo/dojo.js
Line 14
I solved this in part by an answer given at
http://forum.springsource.org/showthread.php?118073-javascript-files-not-loading
I made sure that I had
<script type="text/javascript">dojo.require("dojo.parser");<!-- required for FF3 and Opera --></script>
Also, I had to verify that
<c:set var="dojo_baseline">/resources/dojo-1.6.2/</c:set>
pointed to the correct folder. Previously I had it at 1.6.1
also, that
webmvc-config.xml
looked like
<mvc:resources location="/, classpath:/META-INF/web-resources/" mapping="/resources/**"/>