3 Answers, 1 is accepted
If I am understanding your scenario correctly, you would like to position content on a page and print it on a label printer, am I right? If so, you can achieve this using the Position property of the FixedContentEditor class. Please, find attached a sample project demonstrating this approach.
If this is not the case, I will be thankful if you can share more details on the result you would like to achieve. Can you elaborate more on the requirement to line up the content?
Looking forward to hearing from you.
Regards,
Georgi
Progress Telerik
Thanks for the reply and your solution. I did about the same thing except I have multiple pages. One suggestion on the docs. Please put the using reference on every snippet example. It's confusing sometimes between flow and fixed. Here's my code:10 rows by 3 columns per page
using Telerik.Windows.Documents.Fixed.Model;
using Telerik.Windows.Documents.Fixed.Model.Data;
using Telerik.Windows.Documents.Fixed.Model.Editing;
public RadFixedDocument CreateLabelsPdfDocument()
{
RadFixedDocument document = null;
if (!string.IsNullOrEmpty(rptTitle) && rptDisplay != null)
{
const double xPosStart = 12, yPosStart = 40, xPosOffset = 278, yPosOffset = 100;
double xPos = 12, yPos = 40;
document = new RadFixedDocument();
RadFixedPage page = document.Pages.AddPage();
FixedContentEditor editor = new FixedContentEditor(page);
SimplePosition simplePosition = new SimplePosition();
simplePosition.Translate(xPosStart, yPosStart);
editor.Position = simplePosition;
for (int i = 0; i < rptDisplay.ReportTables[0].RowData.Count(); i++)
{
Block textBlock = new Block();
string text = VariableWithAddressText;
if (!string.IsNullOrEmpty(text))
{
textBlock.InsertText(text);
textBlock.InsertLineBreak();
}
editor.DrawBlock(textBlock);
xPos += xPosOffset;
if ((i + 1) % 3 == 0)
{
xPos = xPosStart;
yPos += yPosOffset;
}
simplePosition.Translate(xPos, yPos);
editor.Position = simplePosition;
if((i + 1) % 30 == 0)
{
xPos = xPosStart;
yPos = yPosStart;
page = document.Pages.AddPage();
editor = new FixedContentEditor(page);
simplePosition.Translate(xPosStart, yPosStart);
editor.Position = simplePosition;
}
}
}
return document;
}
I am happy that everything is now working as desired.
Thank you for the suggestion. We already started adding the namespaces to the most confusing classes like PdfFormatProvider and will consider adding them to the other API members as well.
Regards,
Tanya
Progress Telerik