We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Lines in the Rectangle Background

Thread ID:

Created:

Updated:

Platform:

Replies:

51759 Nov 13,2006 11:18 PM UTC Nov 16,2006 05:20 PM UTC ASP.NET Web Forms (Classic) 9
loading
Tags: PDF
Tester
Asked On November 13, 2006 11:18 PM UTC

I have been working with your tool almost for 15 days, and I have to say it is a very useful tool.

My Question is:
I am using the Grid Model for create the PDF, I need to create a Background with lines in a rectangle (example: \\\\\ covering all the rectangle), but I can't. It looks that there is not a simple way to do that.

Could you please help me?

Thanks in advance

Dhivya K [Syncfusion]
Replied On November 14, 2006 02:03 PM UTC

Hi Eric,

Thank you for your interest in Essential PDF.

We can fill the rectangle with lines using template.
Template has various features .It is more flexible. It has lot of different settings.It allows to set background for all the pages,even or odd pages,single page.

Here are some code snippets to fill the rectangle with lines.

//Create a PDF document
PDFDocument doc = new PDFDocument();

// Adding the template area.
PDFTemplateArea template = doc.Templates.Add(rect);

//Draw lines in the created template
template.Graphics.DrawLine(new PointF(x,0),new PointF(0,y));

Here is the sample for your reference:
Background (line).zip


Please take a look into it and let me know if you have any queries.

Regards,
Dhivya.

Tester
Replied On November 14, 2006 07:28 PM UTC

Hi Dhivya,
Thank you for your answer, it is working great, but I am still having some problems because the sequence of rectangles is generated automatically (different size for each rectangle), and for some reasons that I don't know the line is drew in totally different way that it shoul be (for the others rectangles.

My guess is that maybe the next sentence: template = pdfDoc.Templates.Add(rectField);
must be cleaned in each new cycle.

Thanks again for your help

Tester
Replied On November 14, 2006 07:37 PM UTC

I am sending an attachment to you with the screenshot of the generated PDF.



Example17.zip

Tester
Replied On November 14, 2006 09:35 PM UTC

Hi Dhivya!

Thank you very much, The issue is now fixed, The only thing that I wonder now about this topic is if there exist a way for make the line less dark,if it is possible to change the color of the line in the template.

Thanks!

Dhivya K [Syncfusion]
Replied On November 15, 2006 02:25 PM UTC

Hi Erick,

Thanks for your regular updates. You can set the color of the lines using GraphicState properties as follows:

//Adding the graphics state for setting properties of all drawing objects
IPDFGraphicState state = doc.CreateGraphicState();
//Set the color
state.ForeColor = Color.LightGray;
template.Graphics.DrawLine(new PointF(x,0),new PointF(0,y),state);

I will provide you with a sample by tomorrow.

Regards,
Dhivya.

Tester
Replied On November 15, 2006 03:57 PM UTC


Hi!

yes, it works but the problem that I noted is that then the lines stop to draw in the middle of the page. It happend when I use the IPDFGraphicState state for draw the line of the template.

Do you know what is the reason?

Thanks again!

Administrator [Syncfusion]
Replied On November 16, 2006 04:47 AM UTC

Hi Erick,

Thank you for your interest in Essential PDF. I was able to reproduce the issue. The problem
arrives because coordinates were not properly calculated. Could you please add the following
line. That will rectify your error.

template.Graphics.DrawLine(new PointF(x1,x2),new PointF(y2,y1),state);
template.Graphics.DrawLine(new PointF(x3,x4),new PointF(y4,y3),state);

Here is the sample for your reference.
 LineBackground.zip  


Please take a look at this and let me know if you have any other question.

Regards,
Prakash.R

Administrator [Syncfusion]
Replied On November 16, 2006 05:17 PM UTC


Hi Eric,

Yes we do have options to that allows to have hatch patch. We can do that using the tilling brush support by Essential PDF. Here is code to fill a rectangle with tilling brush

//Create Tiling brush.
IPDFTilingBrush brush = pdfDoc.CreateTilingBrush( new SizeF( 15,15 ) );
props.Brush = brush;

// Draw into brush.
IPDFGraphicState brushState = pdfDoc.CreateGraphicState();
string first = @"\\";
PointF loc = PointF.Empty;
brushState.ForeColor = new PDFColor(Color.LightBlue);
brush.Graphics.DrawText( loc, first, pdfFont, brushState );

here is a sample for your refference: http://www.syncfusion.com/Support/user/uploads/Background_3b98874e.zip

Please take a look and let me know if you have any queries.

Regards,
Ajish.
>Hi Prakash,

I wonder if threre exist a property that allow to have a hatch pattern (implemented) in the background using the grid model.

Thanks!


Ajish [Syncfusion]
Replied On November 16, 2006 05:20 PM UTC

Hi Eric,

Yes we do have options to that allows to have hatch patch. We can do that using the tilling brush support by Essential PDF. Here is code to fill a rectangle with tilling brush

//Create Tiling brush.
IPDFTilingBrush brush = pdfDoc.CreateTilingBrush( new SizeF( 15,15 ) );
props.Brush = brush;

// Draw into brush.
IPDFGraphicState brushState = pdfDoc.CreateGraphicState();
string first = @"\\";
PointF loc = PointF.Empty;
brushState.ForeColor = new PDFColor(Color.LightBlue);
brush.Graphics.DrawText( loc, first, pdfFont, brushState );

here is a sample for your refference: http://www.syncfusion.com/Support/user/uploads/Background_3b98874e.zip

Please take a look and let me know if you have any queries.

Regards,
Ajish.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;