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

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):

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);
}

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:

FDPF: Image is too large for page

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 to imagelist

I m working in delphi-2010
i have an imagelist,in which i have added some .png images.
and i have also picture for showing the picture from imagelist.
i want to show the picture on picture box from imagelist.
i wrote the following code,but here addImage(,) takes 2 argument
one is Values:TCustomImagelist
and another is Index of Image
how i identify the value of customimagelist.
image1.Picture:=imagelist1.AddImage( , );
TImageList.AddImage adds a single image from one TImageList to another. I don't think this is what you intended.
If you want to show one of the images from a TImageList in a TImage, you could use something like this:
imageList1.GetBitmap(0, image1.Picture.Bitmap);

Resources