Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » Draw, Display, Images, Bitmaps, Icons » PDF file from Report
PDF file from Report [message #56414] Tue, 09 March 2021 13:50 Go to previous message
mubeta is currently offline  mubeta
Messages: 77
Registered: October 2006
Member
Hi all,
using PdfDraw object for export an multiplepages report in PDf file result in a very big file when there are images. For reduce the size of the resulting PDF file, I modified the method PdfDraw::DrwImageOp(...) in this way:
void PdfDraw::DrawImageOp(int x, int y, int cx, int cy, const Image& _img, const Rect& src, Color c)
{
	Image img = _img;
	if(!IsNull(c))
		img = CachedSetColorKeepAlpha(img, c);
	
	Tuple2<int64, Rect> key = MakeTuple(img.GetSerialId(), src);
	int q = images.Find(key);
	if(q < 0)
	{
		//q = images.GetCount();
		//images.Add(key, img);
		
	  Image h = sJPEGDummy();
		q = images.GetCount();
		images.Add(key, h);
		data = JPGEncoder(40).SaveString(img);
		img = h;
	}
	
	if(img.GetSerialId() == sJPEGDummy().GetSerialId())
		jpeg.Add(data);
	
	page << "q "
	     << Pt(cx) << " 0 0 " << Pt(cy) << ' '
	     << Pt(x) << ' ' << Pt(pgsz.cy - y - cy)
	     << " cm /Image" << q + 1 << " Do Q\n";
	     
}



This will convert every images in compressed JPEG, that in fact result in a smaller PDF file. But, I'm not sure that when the same image is repeated multiple times in the report, the PDF file will contain this image only once or multiple times. It seems to me that the Tuple2 key is intended for this scope, but in fact if I export a test report with only the same image for mulitple pages, without other content, the file size increase proportionally with the page numbers.
What I'm missing?

Many thanks!!
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: [PATCH READY] New plugin/icons/silk
Next Topic: Maximum images size in QTF
Goto Forum:
  


Current Time: Sun May 18 18:00:38 CEST 2025

Total time taken to generate the page: 0.02872 seconds