My company decided to move from Infragistics to Telerik .
For PDF development I am using Telerik.Windows.Documents.Flow.FormatProviders.Pdf and Telerik.Windows.Documents.Flow.Model.RadFlowDocument to create PDF.PDF is complex with tables/images etc but I did not have any issue there.Everything was as in Telerik online spec.
Now I have different issue that was almost stopover for me.PDF that I got with Telerik is 10 times bigger in size then with Infragistics.
Example bellow will create the simplest PDF doc with only one line of text, and that document is 245 kb.Same example with Infragistic is 14 kb.
Exact same relations is also when I add images in..I can see that Telerik document is much higher in quality [when I put images] but we prefer size/performance then quality of PDF.
Can you point what I have to change? Is any FormatProviders.Pdf settings that I can use to create smaller size document ?Or ?
class TEST
{
public void ExportToPdf(string PdfURL)
{
Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider provider =
new Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider();
using (Stream output = File.OpenWrite(PdfURL))
{
Telerik.Windows.Documents.Flow.Model.RadFlowDocument document = CreateRadFlowDocument();
provider.Export(document, output);
}
}
private Telerik.Windows.Documents.Flow.Model.RadFlowDocument CreateRadFlowDocument()
{
RadFlowDocument document = new RadFlowDocument();
RadFlowDocumentEditor editor = new RadFlowDocumentEditor(document);
editor.ParagraphFormatting.TextAlignment.LocalValue = Alignment.Justified;
Section section = editor.InsertSection();
section.PageMargins = new Telerik.Windows.Documents.Primitives.Padding(4);
section.PageOrientation = Telerik.Windows.Documents.Model.PageOrientation.Landscape;
//test text
editor.InsertText("TEST Telerik.Windows.Documents.Flow.Model.RadFlowDocument PDF ");
return document;
}
}

Hi Team,
I need to automate a scenario of comparing 2 PDF files based on the content, format, alignment, etc. Is it possible to do it using Telerik Test Studio or any other telerik products.
--
Thanks,
Siva.


I have to put 2 tif images on
same page, one is regular "check" size, other is "T4" doc size ...
Page orientation is landscape
I did calculation , resizes images, everything works great ... BUT
"check image" position is on
the bottom of page ?
I need it on top of page.
Tried all alignments etc but did not figure out .
I attached PDF page [as JPG] .
This is simple class that produced PDF.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Telerik.Windows.Documents.Flow.FormatProviders.Pdf;
using Telerik.Windows.Documents.Flow.Model;
using Telerik.Windows.Documents.Flow.Model.Editing;
using Telerik.Windows.Documents.Flow.Model.Styles;
using Telerik.Windows.Documents.Spreadsheet.Model;
using Telerik.Windows.Documents.Fixed.FormatProviders.Pdf;
using System.IO;
namespace TEST{
class TELERIK_WordProcessing_PDFTest
{
public void ExportToPdf(string PdfURL)
{
Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider provider =
new Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider();
using (Stream output = File.OpenWrite(PdfURL))
{
Telerik.Windows.Documents.Flow.Model.RadFlowDocument document = CreateRadFlowDocument();
provider.Export(document, output);
}
}
private Telerik.Windows.Documents.Flow.Model.RadFlowDocument CreateRadFlowDocument()
{
RadFlowDocument document = new RadFlowDocument();
RadFlowDocumentEditor editor = new RadFlowDocumentEditor(document);
editor.ParagraphFormatting.TextAlignment.LocalValue = Alignment.Justified;
Section section = editor.InsertSection();
section.PageMargins = new Telerik.Windows.Documents.Primitives.Padding(4);
//LANDSCAPE format 11 x 8.5 inches
double landscapeWidth = 11 * 96; //1056.00 pixels
double landscapeHeith = 8.5 * 96; //816.00 pixels
section.PageSize = new System.Windows.Size(landscapeWidth, landscapeHeith);
section.PageOrientation = Telerik.Windows.Documents.Model.PageOrientation.Landscape;
section.VerticalAlignment = Telerik.Windows.Documents.Flow.Model.Styles.VerticalAlignment.Top;
//insert 2 images , regular check and T4 in row, one one page
string imageBackCheck = @"C:\temp\test\BACK.tif";
string imageT4 = @"C:\temp\test\FrontA4Page.tif";
//open image to find size
int width = 0;
int height = 0;
SingleImageSize(imageT4, out width, out height);
using (FileStream fileStream = File.OpenRead(imageT4))
{
editor.InsertImageInline(fileStream, "tif", new System.Windows.Size(width, height));
}
SingleImageSize(imageBackCheck, out width, out height);
using (FileStream fileStream = File.OpenRead(imageBackCheck))
{
editor.InsertImageInline(fileStream, "tif", new System.Windows.Size(width, height));
}
return document;
}
private void SingleImageSize(string URL, out int destWidthFirst, out int destHeightFirst)
{
//need to shrink tif image to fit page [ 2 images in row ]
destWidthFirst = 0;
destHeightFirst = 0;
System.Drawing.Image FrontImage = System.Drawing.Image.FromFile(URL);
int sourceWidthFirst = FrontImage.Width;
int sourceHeightFirst = FrontImage.Height;
float nPercent = GetPercentShrink(sourceWidthFirst);
destWidthFirst = (int)(sourceWidthFirst * nPercent);
destHeightFirst = (int)(sourceHeightFirst * nPercent);
}
private float GetPercentShrink(int SourceWidth)
{
//some custom size calculation for lanscape mode [note margin is 4], 523 is half of page
int nConstWidth = 523;// 527;
return (float)nConstWidth / (float)SourceWidth;
}
}
}
Hi,
I create several documents using word processing and finally merge them into a single one using RadFlowDocument.Merge method. When you open that document in Word and insert a header, the header will only be set for single merged documents and not consistently across the whole document.
To repro:
- Create 2 RadFlowDocuments, with a single page and some simple demo text
- Merge them into a single one
- Export the merged document as docx.
- Open the exported document in word and add some text to the header on page 1.
- Scroll down to page 2 and confirm that the header is not there.
I can't tell whether this is a bug or a feature, but is there a way to workaround this? Ultimately I just want to merge several documents into one and have consistent headers and footers across the whole document.
Thanks in advance
Florian


Hi,
I try to do the following:
1. Load .docx document into the RichTextBox
2. Let the user edit the document
3. Perform MailMerge on the document
4. Export the result as PDF witha compliance level PdfComplianceLevel.PdfA1B
Only the WordsProcessing library supports the compliance level, so I need to convert the RadDocument to a RadFlowDocument.
When I export the RadDocument from the RichTexBox back to .docx I somehow loose all the styles (See WordBefore.png, WordAfter.png).
When I export the RadDocument to .rtf, it keeps the correct styles, but when I import it using the Telerik.Windows.Documents.Flow.FormatProviders.Rtf.RtfFormatProvider, I get the following Exception:
Message: The document element is already associated with a parent.Parametername: itemStackTrace: bei Telerik.Windows.Documents.Flow.Model.Collections.DocumentElementCollection`2.VerifyDocumentElementOnInsert(T item) bei Telerik.Windows.Documents.Core.Data.DocumentElementCollectionBase`2.Add(T item) bei Telerik.Windows.Documents.Flow.FormatProviders.Rtf.Import.RtfImportContext.AddInline(InlineBase inline) bei Telerik.Windows.Documents.Flow.FormatProviders.Rtf.Import.TagHandlers.GroupTagHandlers.BookmarkEndHandler(RtfGroup group, RtfImportContext context) bei Telerik.Windows.Documents.Flow.FormatProviders.Rtf.Import.RtfDocumentImporter.DoVisitGroup(RtfGroup group) bei Telerik.Windows.Documents.Flow.FormatProviders.Rtf.Import.RtfElementIteratorBase.VisitElement(RtfElement element, Boolean recursive) bei Telerik.Windows.Documents.Flow.FormatProviders.Rtf.Import.RtfElementIteratorBase.VisitGroupChildren(RtfGroup group, Boolean recursive) bei Telerik.Windows.Documents.Flow.FormatProviders.Rtf.Import.RtfDocumentImporter.ImportRoot(RtfGroup rtfGroup) bei Telerik.Windows.Documents.Flow.FormatProviders.Rtf.Import.RtfDocumentImporter.Import(Stream input) bei Telerik.Windows.Documents.Flow.FormatProviders.Rtf.RtfFormatProvider.ImportOverride(Stream input) bei Telerik.Windows.Documents.Common.FormatProviders.FormatProviderBase`1.Import(Stream input)...Do you have any proposal for me how I can accomplish this?
Hello,
I am trying to:
1 - Open a PDF created from Gridview's ExportToPdf function
2 - Draw a title on the page
3 - Save the PDF
When I run my code everything executes, but the final PDF is a blank page, but with the same length as the original PDF.
If I only open the page and then immediately save the PDF without attempting to draw on the page, the result is the same.
First, can PDFProcessing do this? I've heard that not all of your various PDF exports are compatible with all of the imports yet.
If that is the case, do you have an alternate way for me to get some title text on the PDF file generated by GridView's ExportToPdf function?
Thanks in advance,
Scott