Hi,
I have an app that outputs a number of SFCharts to a PDF which works fine.
The client who I am developing the app for has asked for me to make them "look nicer" and has suggested adding borders around the charts?
Is this possible? Are there any design alterations I can make to the PDF via the APIs?
Thank
Hi Raymond,
We can create borders around the image by drawing the rectangle along with the same bounds of the image. We have created a Charts to PDF sample for drawing borders around the image for your reference. Please try the below sample on your end and let us know the result.
Sample Link: https://www.syncfusion.com/downloads/support/directtrac/general/ze/ChartToPDF-2005967772
Output: https://www.syncfusion.com/downloads/support/directtrac/general/pd/Chart-1718242915
Please refer to the UG link for more details,
https://help.syncfusion.com/file-formats/pdf/working-with-images
https://help.syncfusion.com/file-formats/pdf/working-with-shapes
Please let us know if you need any further assistance in this.
Regards,
Gowthamraj K
Hi,
I've looked at the sample and applied the same principle.
I have multiple charts and use xy coordinates to base the position of them.
int xChartStartPosition = 30;
int xNewLineChartStartPosition = 30;
int yNewLineChartStartPosition = 250;
int yChartStartPosition = 60;
I have a number of charts in a stream.
foreach (Stream item in gaugeStream)
{
PdfBitmap pdfBitmap = new PdfBitmap(item);
if (isNewLine == true)
{
diagrampage.Graphics.DrawImage(pdfBitmap, new Syncfusion.Drawing.RectangleF(xNewLineChartStartPosition, yNewLineChartStartPosition, 100, 150));
diagrampage.Graphics.DrawRectangle(borderPen, new Syncfusion.Drawing.RectangleF(xNewLineChartStartPosition, yNewLineChartStartPosition, 100, 150));
xNewLineChartStartPosition = xNewLineChartStartPosition + 150;
}
else
{
diagrampage.Graphics.DrawImage(pdfBitmap, new Syncfusion.Drawing.RectangleF(xChartStartPosition, yChartStartPosition, 100, 150));
diagrampage.Graphics.DrawRectangle(borderPen, new Syncfusion.Drawing.RectangleF(xNewLineChartStartPosition, yNewLineChartStartPosition, 100, 150));
}
horizontalcount = horizontalcount + 1;
if (horizontalcount < 5)
{
xChartStartPosition = xChartStartPosition + 130;
}
else
{
isNewLine = true;
}
}
}
However, the border that is applied is considerably taller than the chart. Also, it is only applying the border to the bottom images.
I cant get a screenshot under 100kb to attach.
Hi Raymond,
We suspect that the problem may occurs only with particular images. Could you please
share the compressed image/simplified sample to reproduce the issue on our end,
so that it will helpful for us to check and provide a solution.
Regards,
Gowthamraj K
Hi,
The image in question is a SFGaugeChart - there can be anything from 1 to 10 of them exported to the PDF>
Regards,
Raymond
Hi Raymond,
We can achieve this requirement by manually
calculating the previous image bounds and draw the image based on the Y
position with borders around the images. We have attached the sample and output
document for your reference, please find the sample from below link,
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/ChartToPDF-1794470504
Output: https://www.syncfusion.com/downloads/support/directtrac/general/pd/Chart1933480078
Kindly please try the above solution on your end and let
us know if it suits your requirement.
Regards,
Gowthamraj K