FDPF: Image is too large for page - image

I'm using FPDF to create PDFs full of images. Some of these images are by far too long for a page and I need it to spread to the next page. Scaling it to a default page height won't do.
What I'm trying to archive is to automatically insert a page break at some position. I could split the image in parts and insert every part on a new page, but I would very much like to not do that. Is there a way I haven't found yet that FPDF does that for me?
$pdf = new FPDF("P", "mm", "A4");
$pdf->SetAutoPageBreak(true);
$pdf->SetDisplayMode('real');
$pdf->Image($picUrl, 12, $pdf->GetY(), 185);
$pdf->Output($project->getName().".pdf", "D");

Why exactly would you not like to split the image in parts and insert every part on a new page? This seems like the logical way (and it can be automated in PHP if you have the proper libraries).
What you could do is insert the same image over and over again, with different offsets. Then you will have visually the same result, but I don't know if FPDF will be smart enough to not store the image several times.

Related

Inserted Photo and/or Kable Table will not stay where it's placed between text in R markdown

I have two things I have been using, neither of which are keeping the image/table exactly where I placed it within the text in R markdown when knitted to a pdf.
![caption](path) will place the image where there is space on the page. That is, if the page has space, the image will print between the desired text. However, if the page does not have the space, the text is placed to fill the page and then the image awkwardly inserts itself in the middle of the paragraph on the next page.
I am having a similar problem with my kable tables. I have tried using latex_options = 'hold_position', but this seems to only keep my tables from grouping together.
Is there a way to have my table stay between the text that I want? So if it needs to start a whole new page, to fit it, it can without trying to fill the space with the text below.
Thank you in advance.

Adding Images Efficiently to a Google Spreadsheet

I am exploring using a GAS script to build a human-readable product catalogue as a Google Spreadsheet, it's easy to generate a PDF or print from there. The product data is all quickly accessible via an API including image URLs for each product.
I'm running into issues because inserting an image which references a URL, then re-sizing it takes 3-4 seconds in my prototype, and I might have 150x products. Runtime is capped at 6 minutes. Here's a simplified example of the image processing loop that I'm imagining:
function insertImages(sheet, array_of_urls) {
for (var i in array_of_urls) {
let image = sheet.insertImage(list_of_urls[i], 1, (i+1)*3);
image.setWidth(90);
image.setHeight(90);
}
}
I think it takes so long because of the interaction with the UI. Can anyone recommend a way that I could make the script functionally efficient?
Insert images over cells:
If you want the images over cells (that is, not contained in a specific cell), I don't think there's a way to make this significantly faster. There's no method to insert multiple images at once.
You could at most try to retrieve the image blobs, resize the images through some third party before inserting them, and finally insert them via insertImage(blobSource, column, row).
In any case, there are ways to get through the 6 minute execution time limit. See, for example, this answer.
Insert image in cells:
If you don't have a problem having the images in specific cells, and not over cells, I'd suggest adding the images via IMAGE formula, using setFormulas.
The image size can be set through the IMAGE formula, the following way:
=IMAGE("URL", 4, [height in pixels], [width in pixels])
Also, to make sure the cells' height is large enough for the images to be seen, you can use setRowHeights.
Code snippet:
function insertImages(sheet, array_of_urls) {
const formulas = array_of_urls.map(url => ["=IMAGE(\"" + url + "\", 4, 90, 90)"]);
const firstRow = 1;
sheet.getRange(firstRow,1,formulas.length,formulas[0].length).setFormulas(formulas);
sheet.setRowHeights(firstRow, formulas.length, 90);
}

Aspose PDF .Net repeating same image multiple times in a table

I'm trying to add a table to a PDF. Each row will have an image in a column. There are 3 images which will repeat in the rows.
If I just directly add the image to table cell like below, performance is very poor. It may be cause each image is treated as a separate new one.
cell.Paragraphs.Add(new Image(imagePath + "on.png"));
The below article describes how to add images to resources and reuse it. But I'm not able to figure out how this should be applied to a table cell. To be precise I'm able to add Aspose.Pdf.Image to a cell but not Aspose.Pdf.XImage.
https://docs.aspose.com/display/pdfnet/Manipulate+Images#ManipulateImages-AddImagetoExistingPDFFile
You can try to reuse the same Image object.
Image img = new Image(imagePath + "on.png");
cell.Paragraphs.Add(img):
cell.Paragraphs.Add(img):

Displaying images from Google Sheets as a table in a web site

I've created a Google Spreadsheet with logo images in one column of cells, but when I try to create a table to add into my website the images do not display in the table.
I need them to display so The logos are visible within a webpage? Does anyone know why the images are not displaying in table format, or how I can fix this.
Not sure which method did you choose to display images. My solution worked for images embedded with the IMAGE function and not showing inside the new spreadsheets, but showing inside the old. I must admit I haven't tested it with embedded documents but it should work too:
SPACE character is an offending character in the new Google spreadsheets when embedding images using the IMAGE function. Replace it with another, 'safe' character like '-' or '_'
Not sure how much this helps, since I don't know what you did/did wrong, but here's a pasted table with images from the new Google Sheets. The only thing of note is that in the pasted table, all images scale to the cell size with aspect ratios retained, ignoring the parameters in the spreadsheet.
formula: =IMAGE("https://www.google.com/images/srpr/logo3w.png")
copy/pasted into document:
original spreadsheet:

Mosaicking PDF documents?

I have (or, rather, will soon have) a number of maps created in ArcGIS 10.0 and exported as PDF documents. The maps all show contiguous areas, being rather like the pages in a map book. There will also be a smaller-scale map depicting the entire area (let's call it the "study area"), but with less detail, rather like that page of a map atlas that shows what page depicts what area.
I wonder if there is any way to create thumbnails of the larger-scale maps and mosaic them such as to create an index map of the study area. A user would then be able to see, for a particular point on the smaller-scale map, which of the larger-scale maps depicts that part of the study area. (And perhaps see that map by clicking on the larger map?) Does anyone have any ideas I can implement this? I would prefer exporting the maps in PDF format, but, if I can't do all of the above with PDF, then any other format to which a map can be exported from ArcGIS, such as JPG or TIF, will work.
You should be able to create a PDF which does this.
What you need to do is render each page to a small image.
Then collect each of these images and add them as a mosaic to an index page.
Then put links from each small image back to the original PDF page.
If the hierarchy was more than one level deep you could repeat the process.
You need a PDF component to do this. What you want in terms of features is something which does decent PDF rendering. It's an easy thing to do badly and a difficult thing to do well.
ABCpdf .NET does good quality rendering so it's what I would suggest, but then I would because I work on it. :-)

Resources