This is a migrated thread and some comments may be shown as answers.

address labels

3 Answers 161 Views
PdfProcessing
This is a migrated thread and some comments may be shown as answers.
Fred Parcells
Top achievements
Rank 1
Fred Parcells asked on 06 Jun 2019, 12:58 PM
Trying to create pdf to print address labels on existing 3 column Avery 8460 form. I am using Telerik.Windows.Documents.Fixed.Model.RadFixedDocument and RadFixedDocumentEditor with Telerik.Windows.Documents.Fixed.Model.Editing.Tables.Table but can't get everything to line up. I'm thinking using Block with position and size would be better. Can anyone point me in the right direction? ASP.NET C# Any examples out there? Thanks Fred

3 Answers, 1 is accepted

Sort by
0
Georgi
Telerik team
answered on 11 Jun 2019, 12:12 PM
Hi Fred,

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
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Fred Parcells
Top achievements
Rank 1
answered on 11 Jun 2019, 12:58 PM

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;
        }

0
Tanya
Telerik team
answered on 13 Jun 2019, 02:47 PM
Hi Fred,

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
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
PdfProcessing
Asked by
Fred Parcells
Top achievements
Rank 1
Answers by
Georgi
Telerik team
Fred Parcells
Top achievements
Rank 1
Tanya
Telerik team
Share this question
or