canvas.loadFromJSON() showing text bulry for google fonts - jspdf

I am facing this problem for a long time. I am generating the flipbook from the canvas using Fabricjs. I am changing the text content color and fonts on the fly. Everything is working fine but when I am trying to use google fonts so in that case text shows blurred and ugly.
Once the image is generated from JSON using canvas and converted the canvas to blob type of images and then I am converting HTML to flipbook.
Sample code Demo
<script async src="//jsfiddle.net/kantsverma/6yanokf1/5/embed/"></script>

Are you stretching the canvas. ie setting a canvas width of 500px then using css to make width 100%. this effectively renders at the lower resolution then stretches the final rendered image.

Related

Gramex CaptureHandler not capturing opacity of elements

I am using a capture handler to download a PNG image for a selector. URL is working fine when loaded individually, but the image downloaded is not showing the opacity of some of the elements in it, even when the dpi is given as 192. Am using bootstrap opacity classes("opacity-8")
Tried to debug using debug parameter, but It didn't work. Is there a way that I can debug it more closely or a way to see the exact application page used while capturing?
Tried to overlay a div with faded color, but it is not working too.

PDFJS to fixed width with higher resolution/image quality

I'm looking to use PDFJS to embed PDFs into a webpage. I'd like to render them into a fixed-width canvas (and have them scaled appropriately so they fit into the canvas), while having similar resolution/image quality as the original PDF.
If I use a viewport generated like this:
var viewport =
page.getViewport(page.getViewport(canvas.width/page.getViewport(1.0).width);
I get very low-quality image rendering for small-ish canvases. Is there a way to specify both the scale at which a PDF should be rendered and a suggestion for resolution/image quality?
I'm assuming some method of using/resizing a wrapper div may be the solution, but my attempts thus far have not been successful in scaling the contents of the canvas.
(Also, I know this is related to this other post, but that post doesn't mention a way to specify a higher quality pdf rendering for small canvases).

Rotativa - How to fit div's width with pdf page's width

I have a HTML document like this:
My problem is: When I use rotativa to export this HTML document to PDF, the body doesn't resize automatically to correspond with the PDF's page size. For example, when I choose A5 size and portrait, the content doesn't zoom out, so a part of the body is cut off.
What I want: Export this document to PDF and it should be able to auto resize to correspond with the PDF's page size and orientation. I mean it should zoom in or zoom out to fit 100% width of page size. Moreover, It should looks like how it appears on the browser exactly. Please note that my body must has fixed size because all inside elements have absolute position.

Does iOS support SVG Tiny?

I try to use svg file as some element's background image. When I save image as SVG 1.0/1.1 in Adobe Illustrator, it displays correct in my app. If I save image as SVG Tiny 1.1/1.1+/1.2 it doesn't displays in app.
I use next css:
background-image: url(img.svg);
Does iOS support SVG Tiny? Or what I must to do, that my SVG Tiny image will display in app as background image?
Yes, iOS and pretty much any browser/device that supports SVG also supports SVG Tiny. However, SVG Tiny is a subset of SVG intended for devices with poor performance, it will discard gradients, opacity, embedded fonts and filters. What is probably happening is that the features you are using in your file are being discarded by the Tiny format. SVG Tiny does nothing to save on file size.
In summary, just use SVG 1.1.

Blurry Images when rendering to PDF using UIKit/Coregraphics

Everything seems pretty standard I downloaded PDF GENERATION SAMPLE and used my own assets at normal resolutions and my images look a little off.
Here's the asset
Here's what it looks like in app
And this is what it looks like in the PDF at 100% zoom
The code in the drawImage function is as simple as it gets
UIImage * demoImage = [UIImage imageNamed:#"icon_map_project.png"];
[demoImage drawInRect:CGRectMake( (pageSize.width - demoImage.size.width)/2,
350,
demoImage.size.width,
demoImage.size.height)];
Nothing fancy at all. I do admit that my familiarity with the details of how PDF work, DPI, and things like that are beyond me at this point.
I've looked at LibHaru and think it's a great system but I'd rather keep this within the confines of UIKit/CoreGraphics.
You'll notice a strange jaggedness on the right side, even shrinking the image down by 50% doesn't seem to help.
Here's a zoomed up image using Digital Color Meter with the PDF at 100% and then the app
As you can see the image simply does not render correctly into the PDF and I'm struggling to find a solution for this.
Thanks for any advice.
You draw the image in the PDF in a rectangle that matches the image size. This results in a 72dpi for the image. Because the viewer application use 96dpi or a higher value as reference for 100% zoom, when the file is displayed at 100% your image will be rendered 100% * 96/72 scale. If you enlarge the bitmap at that scale with an imaging tool you'll see a similar jaggedness. The solution is to use a larger image drawn in a 37x36pt rectangle so that the resulting image dpi is higher.
If you zoom your PDF file to 75% the image size displayed on the page should match the image size in your application (this assumption is based on a 96 dpi screen).

Resources