Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic PDFs of very large charts (Read 2943 times)
David Long
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 136
Location: England
Joined: Oct 23rd, 2006
PDFs of very large charts
Dec 3rd, 2021 at 11:22am
Print Post  
One of our customers would like to print very large PDF documents generated by our software using the PdfExporter class. I can read these files in a PDF reader such as MS Edge, but Adobe Reader truncates the chart to a maximum size of 200 x 200 inches. They use Adobe Reader as they would like to print out the whole chart for annotation on a continuous role printer or use the 'Poster Print' feature. This is a feature that Adobe Reader offers. They know more about PDF formats that me and say...

"I know from PDF version 1.6 onward (from way back in 2004) they added an inbuilt scale-factor to deal with larger than 200x200 documents of the sort that your software produces, though the library in the software seems to be creating v1.5 and doesn’t have any of these parameters."

I've tried various combinations of the PdfExporter parameters, but nothing seems to help.

Any ideas?
DavidL
« Last Edit: Dec 3rd, 2021 at 2:07pm by David Long »  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3343
Joined: Oct 19th, 2005
Re: PDFs of very large charts
Reply #1 - Dec 6th, 2021 at 8:15am
Print Post  
I can see Adobe Reader showing size warning when exporter.PageSize is set to DiagramSize. It opens correctly if PageSize is set to A4, and the customer might still be able to print it as a poster through Reader's 'Multiple' page and scale options. Another possibility is to export with smaller exporter.Scale, and then print the document at reciprocal custom scale, like 50% exported and 200% printed.

Code
Select All
void TestPdf()
{
	diagram.ClearAll();

	var inch = (float)MeasureUnit.Inch.Convert(1, MeasureUnit.Millimeter, null);
	diagram.Bounds = new RectangleF(0, 0, 400 * inch, 400 * inch);

	for (int i = 0; i < 400; i++)
	{
		var node = diagram.Factory.CreateShapeNode(
			i * inch, i * inch, 0.9f * inch, 0.9f * inch);
		node.Text = i.ToString();
	}

	var exporter = new PdfExporter();
	exporter.PageSize = PageSize.A4;
	exporter.Export(diagram, "test1.pdf");

	diagram.Bounds = new RectangleF(0, 0, 199 * inch, 199 * inch);
	exporter.Scale = 50.0f;
	exporter.PageSize = PageSize.DiagramSize;
	exporter.Export(diagram, "test2.pdf");
} 



Regards,
Slavcho
Mindfusion
  

Untitled_027.png ( 65 KB | 118 Downloads )
Untitled_027.png
Back to top
 
IP Logged
 
David Long
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 136
Location: England
Joined: Oct 23rd, 2006
Re: PDFs of very large charts
Reply #2 - Dec 6th, 2021 at 3:21pm
Print Post  
The first solution gives an OK result so I can run that by the client, but in the second solution, setting diagram.Bounds down to 199 x 199 inches results in the last box or two being missed off the pdf output (and the on-screen chart)

DavidL
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3343
Joined: Oct 19th, 2005
Re: PDFs of very large charts
Reply #3 - Dec 6th, 2021 at 5:04pm
Print Post  
200x200 didn't work maybe because of the page margins size, or try subtracting a smaller value such as a millimeter instead of a full inch. You should be able to fit all nodes also by setting a bit smaller scale - it should probably be automatically calculated anyway from current diagram.Bounds.Size, dividing the 199x199 or whatever max size you find works.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
David Long
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 136
Location: England
Joined: Oct 23rd, 2006
Re: PDFs of very large charts
Reply #4 - Dec 7th, 2021 at 10:04am
Print Post  
If the client's diagram is 250 x 250 inches (for example) then reducing the diagram size below 200 inches will still result in boxes being missed off the output.

DavidL
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3343
Joined: Oct 19th, 2005
Re: PDFs of very large charts
Reply #5 - Dec 7th, 2021 at 4:21pm
Print Post  
It should work for any size as long as you set exporter's Scale appropriately -

Code
Select All
void TestPdf()
{
	//int sizeTest = 800;
	//int sizeTest = 400;
	int sizeTest = 250;

	diagram.ClearAll();

	var inch = (float)MeasureUnit.Inch.Convert(1, MeasureUnit.Millimeter, null);
	diagram.Bounds = new RectangleF(
		0, 0, sizeTest * inch, sizeTest * inch);

	for (int i = 0; i < sizeTest; i++)
	{
		var node = diagram.Factory.CreateShapeNode(
			i * inch, i * inch, 0.9f * inch, 0.9f * inch);
		node.Text = i.ToString();
	}

	var exporter = new PdfExporter();

	// margin size in inches
	var m = exporter.Margins;
	var mw = (m.Left + m.Right) / 100;
	var mh = (m.Top + m.Bottom) / 100;

	// max size supported by PDF Reader
	var scaleTo = diagram.Bounds;
	scaleTo.Width = (200 - mw) * inch;
	scaleTo.Height = (200 - mh) * inch;

	// set Bounds to max size
	var diagBounds = diagram.Bounds;
	diagram.Bounds = scaleTo;

	// scale to fit original bounds into max size
	exporter.Scale = 100 * Math.Min(
		scaleTo.Width / diagBounds.Width,
		scaleTo.Height / diagBounds.Height);

	// export
	exporter.PageSize = PageSize.DiagramSize;
	exporter.Export(diagram, "test2.pdf");

	// restore original Bounds
	diagram.Bounds = diagBounds;
} 



Regards,
Slavcho
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint