asciidoctor-pdf cover page image size to fill the page - asciidoc

I'm attempting to have the book-cover.png fill the entire first page of an ebook, but with the settings below it still leaves a small margin of white on both sides. What's the best image size to fill the cover and are there any options that would fill the page and not leave white margins? Thanks!
= Book Title
Author
Version 1.0, 2020-03-12
:front-cover-image: image::book-cover.png[Front Cover,1050,1600]
:doctype: book
:imagesdir: images
:toc: right
:toclevels: 2
ifndef::ebook-format[:leveloffset: 1]

Related

Can I use Basil.js to change a page's width using a csv?

I want to make book covers using Indesign's Data Merge.
The indd is a spread where page 1 is the flap from the back cover, page 2 is the back cover, page 3 is the spine, page 4 is the front cover, page 5 is the flap from the front cover.
Page 3, the spine, should vary it's width from a value set in a CSV used for data merging all variable text and images. It should then export to PDF with the correct spine width.
Could this be done using Basil.js ?
I haven't tried Basil.js before.

Full bleed column with bottom padding with wkhtmltopdf

I'm converting a HTML page with wkhtmltopdf from HTML to PDF. My page consists of a left column with full bleed background color. How can I force a bottom/top padding so that my content is not pushed against the edge of the page (as demonstrated below), while keeping the full bleed background color for the left column?
I've tried p {page-break-inside: avoid;} without success. Setting padding on the page level goes against the full bleed.

Place image at bottom left corner of pdf with iText

I'm having some trouble placing an image in the bottom-left corner of a PDF document.
Here's my code:
PdfReader reader = new PdfReader("source.pdf");
PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(pdfTarget));
Image qrImg = Image.getInstance("qrcode.png");
qrImg.setAbsolutePosition(0,0);
// place the image at the i-th page
PdfContentByte content = stamper.getOverContent(i);
content.addImage(qrImg);
This works for almost every pdf document I tried unless a single one that you can find here: https://ufile.io/50016
For this document the bottom left corner starts at (50,50) so the absolute position should be (50,50) that is incorrect for all the others pdfs.
I can't find a way to place the image at (0,0) or any other fixed absolute position that results in placing it always at the bottom left corner.
Any advice?
Pdf documents describe the page with a key called MediaBox. This is the raw size of the page. There's another key called CropBox that defines the visible area of the page. In your document the cropbox start at 54,55.4 and that's the offset you'll have to apply to the image. Check PdfReader.getCropBox() to get the dimensions.

Make PDF page sizes fit image sizes

I'm trying to create a PDF document from images of varying sizes so that each page of the PDF displays one of the images unscaled, the page size should fit the image dimensions.
I'm using Prawn to generate the PDF from a list of image file names. To get the image dimensions I use FastImage.
Prawn::Document.generate('Output.pdf') do
list_of_image_filenames.each do |i|
image_size = FastImage.size(i)
start_new_page(:size => image_size, :layout => :portrait)
image(i)
end
end
To test it I'm using three PNG files of dimensions 560x560, 600x600, and 600x600. I've made sure that FastImage returns the correct image dimensions.
The resulting PDF (Preview tells me it's PDF version 1.4) looks like this:
It starts with 3 empty pages (one of which is probably due to the fact that I didn't put anything on the first page), then the first image, which is cropped. Except the first one, which I'm ignoring for now, these pages are of size 560x560 px, according to Preview.
Next are two empty pages, then the second image, which also doesn't fit on the page. These pages have dimensions 600x600 px.
Finally, two more blank pages and the third image, cropped again, page dimensions also 600x600 px.
Here is a sample of one of the cropped images; the original image is a complete rounded rectangle with the digit "1" inside.
Why do the images not fit on the page? How can I put the individual unscaled images on pages fitting their dimensions?
May not be an exact answer but Probably too long for a comment. I have a few suggestions:
Have you tried specifying image size and position? e.g.
image(i,position: :left, vposition: :top, fit: image_size)
This will place an image in the top left corner of the document an will force it to fit in dimensions of the image_size Array. This might help with the cropping.
Also when setting page_size you need to pad for margins otherwise the image will not fit because it is outside the writable area try something like
image_size = FastImage.size(i)
#default margins are 0.5 inches so pad both height and width with 1 inch using in2pt
page_size = image_size.map{|p| p + in2pt(1) }
start_new_page(:size => page_size, :layout => :portrait)
I cannot guarantee this will work and it has not been tested but usually overflow onto additional pages has to do with the fact that you cannot place a specific object inside the bounds so padding the page size should help.
https://github.com/boazsegev/combine_pdf
you could try this gem.
cropped_size = [X0, Y0, X_max, Y_max]
combine_pdf = CombinePDF.new(pdf_path)
combine_pdf.pages.each{|page| page.crop(cropped_size)}
combine_pdf.save(new_pdf_path)

Images & Icons are getting pixelated when gallery loads

I have a Content Slider (All-in-one-banner sort of) on the home page of my website.
Every time this banner slides onto the next image in the queue, the other images (png format) on my page are getting pixelated. Especially it happens in Chrome.
Images and Icons such as the logos, icons used for navigation, etc... - they get pixelated when a new slide changes on the banner.
Please help me.
Demo link (Open in chrome):
When the slides in the banner change, Look at the logo on the top and the logos to the right, and also the profile pics below,: indiaemerge.com/ieys2013
The solution I could figure out is that one should NOT use an image with large dimensions.
For example: I was trying to use an image of size 800px X 400px to fit it into a division of 200px X 50px. Because of this the image was getting distorted when slides would change.
I reduced the dimensions and resolution of the image to match the target division's dimensions and it worked.
Another way to fix this is to use an svg image file.
So the lesson to be learnt here is that always try to use an image (in case it is png or jpg) whose size meets your requirement as precisely as possible. If it is an svg image file then there won't be any problem.

Resources