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

Printing to PDF using Telerik PDF utilities

7 Answers 176 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Lindsay Miles
Top achievements
Rank 1
Lindsay Miles asked on 24 Oct 2013, 11:38 PM
Hello,

I'm trying to build a print mechanism for my SL app and have so many issues with the MS PrintDocument, I thought I'd seek help using the Telerik PDF functionality if possible.

In summary, my app is a drawing app. I have a usercontrol (diagramCtl) with a canvas and a couple textboxes. the user draws on the fixed-size canvas and adds data to the text boxes. The user can open as many diagrams as they want and each is held in its own tab.

I want to take a diagram with the text data and print to pdf AND also be able to take all diagrams and print to a doc (not necessarily a single page) with as many pages as needed.

I already build the page-data in code and it prints a single page using the Microsoft PrintDocument. 

I want to use that page-data to send to your pdf utilities and export a pdf file as the Microsoft PrintDocument just does not do well once we need multiple pages.

Is there a sample on how to do this in Silverlight using your PDF utilities?
I've no idea what is possible with your pdf utilities in Silverlight.

Thanks

7 Answers, 1 is accepted

Sort by
0
Accepted
Petya
Telerik team
answered on 29 Oct 2013, 01:48 PM
Hello,

There is a control in the RadControls for Silverlight suite which can produce PDF documents and it is called RadRichTextBox. In order to utilize it in your scenario you can do one of the following:
  • Create a snapshot of the user control (for example, by creating a RadBitmap). Images can be added to a RadDocument as InlineImages.
    RadBitmap bitmap = new RadBitmap(myFrameworkElement);
    ImageInline image = new ImageInline(bitmap.Bitmap);
    The generated document can be exported to any of the supported by the control formats, including PDF.
  • Build a RadDocument at run time based on your user control. Instead of simply taking a picture of the control you could create paragraphs, images, tables, etc. document elements and build a document according to RadRichTextBox's document hierarchy. The resulting document you can export to PDF using the respective format provider. You can find some guidelines on how to create a document run-time in this help article.

I hope this is helpful! Do not hesitate to contact us if you have additional comments or questions.

Regards,
Petya
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Lindsay Miles
Top achievements
Rank 1
answered on 29 Oct 2013, 03:45 PM
Petya, thanks for your help and suggestions on this.
I like option 2.

Further question(s):

Once I've added to a RadRichTextBox in the Visual Tree (as the documentation suggests), how would I handle multiple pages?
Does the RadRichTextBox and RadDocument handle that for me? (which I doubt).

Printing multiple images along with text data requires multiple pages. I need to bump an image to the next page if no space available on current page (in the printing cycle).

I know you don't support ms products but here's some explanation why I'm looking to your products as a solution.
Using the microsoft PrintDocument, one can check page size etc and set the HasMorePages flag appropriately (which is so buggy and unreliable MS should be embarrassed) and it creates another page or ends printing (again - highly unreliable). Also, if I print the same doc a number of times with no changes, I get a number of prints but all different. A page missing, an image missing, never the same consistently.

My only thought is it must be timing due to the asynchronous nature of SL. Processes ending before others etc, thus varied printed docs...

Any further feedback on multiple pages would be useful!

Thanks
0
Accepted
Petya
Telerik team
answered on 30 Oct 2013, 04:01 PM
Hi,

RadRichTextBox has three layout modes - Flow, FlowNoWrap and Paged. When in Paged mode the control automatically layouts the document shown in it in pages. To your other questions, if the current page does not have enough space for an image the image is moved to a separate page as well.

I suggest you check how the control behaves with different types of document in our online demos here. Should any other questions arise, feel free to contact us again.

Regards,
Petya
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Scott
Top achievements
Rank 1
answered on 28 Nov 2013, 03:21 AM
Hello,

It appears that both of the methods you show to create a PDF of a RadDiagram end up using a rasterized image. Is there any mechanism that would allow me to get the RadDiagram into a PDF as vectors (line art and text)? That way when a user zooms in on the PDF RadDiagram, it scales well and would not get pixelized.

Suggestions?

Thanks,

Scott

0
Petya
Telerik team
answered on 29 Nov 2013, 02:57 PM
Hello Scott,

Unfortunately at this point such mechanism is not available. We will consider including this for one of our next releases.

Let us know if you have any additional feedback.

Regards,
Petya
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Ramkumar
Top achievements
Rank 1
answered on 04 Dec 2013, 05:25 AM
Hi,
  Is that possible to covert the data entered in the textbox to pdf? please anyone help me this task!
0
Petya
Telerik team
answered on 06 Dec 2013, 03:44 PM
Hello Ramkumar,

You can use either one of the approaches I initially suggested here and build a RadDocument in one of the following ways:
  • Take a snapshot of the control and insert it as an image in RadDocument.
  • Create a RadDocument run-time following these guidelines. In the particular case of TextBox I'd suggest using this approach as the control already contains content (text) which can be used to easilly create a RadDocument.
Once the document is ready you can export it to PDF using the respective format provider.

If you encounter any difficulties implementing this, please do not hesitate to get back to us.

Regards,
Petya
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
General Discussions
Asked by
Lindsay Miles
Top achievements
Rank 1
Answers by
Petya
Telerik team
Lindsay Miles
Top achievements
Rank 1
Scott
Top achievements
Rank 1
Ramkumar
Top achievements
Rank 1
Share this question
or