4 Answers, 1 is accepted
Ok. I have figured it out. It seems like this issue related with dispatcher.
RadDocument doc = XamlFormatProvider.Import(XamlFormatProvider.Export(radDocument));
Dispatcher.Invoke(new Action(()=>{ PdfFormatProveider.Export(doc, stream); }), DispatcherPriority.Normal);
In these code, the images in header are not exported to pdf, but in the following code, they will. And this issue doesn't exist in word exporting.
Dispatcher.Invoke(new Action(()=>{
RadDocument doc = XamlFormatProvider.Import(XamlFormatProvider.Export(radDocument));
PdfFormatProveider.Export(doc, stream);
}), DispatcherPriority.Normal);
Any explaintion of these things?
What's in the "radDocument" instance? If the document contains images with UriSource set, this is known issue - the problem is that the images are always loaded asynchronously, and at the moment of the export they are still not loaded. You can vote for and subscribe for the item in our public portal here:
When loading images from UriSource, there is no way to tell when the images have been loaded
Your workaround works as it gives the asynchronous calls enough time to finish and load the images.
Can you confirm that this is the problem? If this is not the case, could you please open support ticket and send us the problematic document, so that we can investigate it further?
Regards,
Boby
Telerik by Progress
<t:RadDocument xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:t="clr-namespace:Telerik.Windows.Documents.Model;assembly=Telerik.Windows.Documents" xmlns:s="clr-namespace:Telerik.Windows.Documents.Model.Styles;assembly=Telerik.Windows.Documents" xmlns:r="clr-namespace:Telerik.Windows.Documents.Model.Revisions;assembly=Telerik.Windows.Documents" xmlns:n="clr-namespace:Telerik.Windows.Documents.Model.Notes;assembly=Telerik.Windows.Documents" xmlns:th="clr-namespace:Telerik.Windows.Documents.Model.Themes;assembly=Telerik.Windows.Documents" version="1.4" LayoutMode="Paged" LineSpacing="1" LineSpacingType="Auto" ParagraphDefaultSpacingAfter="0" ParagraphDefaultSpacingBefore="0" SectionDefaultPageSize="816,1056" StyleName="defaultDocumentStyle">
<t:RadDocument.Captions>
<t:CaptionDefinition IsDefault="True" IsLinkedToHeading="False" Label="Figure" LinkedHeadingLevel="0" NumberingFormat="Arabic" SeparatorType="Hyphen" />
<t:CaptionDefinition IsDefault="True" IsLinkedToHeading="False" Label="Table" LinkedHeadingLevel="0" NumberingFormat="Arabic" SeparatorType="Hyphen" />
</t:RadDocument.Captions>
<t:RadDocument.ProtectionSettings>
<t:DocumentProtectionSettings EnableDocumentProtection="True" Enforce="True" HashingAlgorithm="SHA1" HashingSpinCount="100000" PasswordHash="I9RxDtXIHnP4iQgLWUe5VDbcSEM=" ProtectionMode="ReadOnly" Salt="lHVaT2YOFavakLJ+RvLDkQ==" />
</t:RadDocument.ProtectionSettings>
<t:RadDocument.Styles>
<s:StyleDefinition DisplayName="Document Default Style" IsCustom="False" IsDefault="False" IsPrimary="True" Name="defaultDocumentStyle" Type="Default">
<s:StyleDefinition.ParagraphStyle>
<s:ParagraphProperties LineSpacing="1" LineSpacingType="Auto" SpacingAfter="0" SpacingBefore="0" />
</s:StyleDefinition.ParagraphStyle>
<s:StyleDefinition.SpanStyle>
<s:SpanProperties FontFamily="Times New Roman" FontSize="14.67" FontStyle="Normal" FontWeight="Normal" />
</s:StyleDefinition.SpanStyle>
</s:StyleDefinition>
<s:StyleDefinition DisplayName="Heading 1" IsCustom="True" IsDefault="False" IsPrimary="True" Name="Heading1" Type="Paragraph" UIPriority="9">
<s:StyleDefinition.SpanStyle>
<s:SpanProperties FontFamily="Times New Roman" FontSize="21.3333333333333" FontWeight="Bold" />
</s:StyleDefinition.SpanStyle>
</s:StyleDefinition>
<s:StyleDefinition DisplayName="Heading 2" IsCustom="True" IsDefault="False" IsPrimary="True" Name="Heading2" Type="Paragraph" UIPriority="9">
<s:StyleDefinition.SpanStyle>
<s:SpanProperties FontFamily="Times New Roman" FontSize="16" FontWeight="Bold" />
</s:StyleDefinition.SpanStyle>
</s:StyleDefinition>
<s:StyleDefinition DisplayName="Normal" IsCustom="True" IsDefault="False" IsPrimary="True" Name="Normal" Type="Paragraph" UIPriority="0">
<s:StyleDefinition.ParagraphStyle>
<s:ParagraphProperties TextAlignment="Justify" />
</s:StyleDefinition.ParagraphStyle>
<s:StyleDefinition.SpanStyle>
<s:SpanProperties FontFamily="Times New Roman" FontSize="14.6666666666667" />
</s:StyleDefinition.SpanStyle>
</s:StyleDefinition>
<s:StyleDefinition BasedOnName="TableNormal" DisplayName="TableGrid" IsCustom="False" IsDefault="False" IsPrimary="True" Name="TableGrid" Type="Table" UIPriority="59">
<s:StyleDefinition.ParagraphStyle>
<s:ParagraphProperties LineSpacing="1" SpacingAfter="0" />
</s:StyleDefinition.ParagraphStyle>
<s:StyleDefinition.SpanStyle>
<s:SpanProperties FontFamily="Times New Roman" FontSize="14.67" />
</s:StyleDefinition.SpanStyle>
<s:StyleDefinition.TableStyle>
<s:TableProperties Borders="1,None,#FF000000,none,,">
<s:TableProperties.TableLook>
<t:TableLook />
</s:TableProperties.TableLook>
</s:TableProperties>
</s:StyleDefinition.TableStyle>
</s:StyleDefinition>
<s:StyleDefinition DisplayName="TableNormal" IsCustom="False" IsDefault="True" IsPrimary="True" Name="TableNormal" Type="Table" UIPriority="59">
<s:StyleDefinition.ParagraphStyle>
<s:ParagraphProperties LineSpacing="1" SpacingAfter="0" />
</s:StyleDefinition.ParagraphStyle>
<s:StyleDefinition.SpanStyle>
<s:SpanProperties FontFamily="Times New Roman" FontSize="14.67" />
</s:StyleDefinition.SpanStyle>
</s:StyleDefinition>
</t:RadDocument.Styles>
<t:Section>
<t:Section.Headers>
<t:Headers>
<t:Headers.Default>
<t:Header IsLinkedToPrevious="False">
<t:Header.Body>
<t:RadDocument LayoutMode="Flow" LineSpacing="1" LineSpacingType="Auto" ParagraphDefaultSpacingAfter="0" ParagraphDefaultSpacingBefore="0" SectionDefaultPageSize="816,1056" SelectedBibliographicStyleName="\APA.XSL" StyleName="defaultDocumentStyle">
<t:RadDocument.ProtectionSettings>
<t:DocumentProtectionSettings EnableDocumentProtection="True" Enforce="True" HashingAlgorithm="SHA1" HashingSpinCount="100000" PasswordHash="I9RxDtXIHnP4iQgLWUe5VDbcSEM=" ProtectionMode="ReadOnly" Salt="lHVaT2YOFavakLJ+RvLDkQ==" />
</t:RadDocument.ProtectionSettings>
<t:Section FirstPageNumber="1">
<t:Paragraph>
<t:ImageInline Extension="png" Height="42" RawData="iVBORw0KGgoAAAANSUhEUgAAASwAAAAqCAYAAAAJU2bcAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAACxMAAAsTAQCanBgAABOASURBVHhe7Z0J/C5TGcf/RGijCHErXaSybxXV5UaIXCJJbrnZQ3Epa9YsoQXZd7rInu3a92RfW2RNSNmyREq4fb8zc/6fd5mZd5/3/f/N7/P5fc7MvGfOnJk585znPM9zzjvdUIkRi9UnrLMRyU7wk/AF+Gu469QLz3uRtESJUYfpaPTTku2icQof1qRku2vgfmYj8eNNQ0+u2Q9wn7uS7BfvVeFeuBz3+Vq8G+XdjuQX8V4dxpP3umS7RImBxvRJWmIEAQE0D8le8V4dFodbxJslSowulAJrZGI5OGO8mYrxSVqixKhCKbBGJv6dpFl4NUlLlBhVKAXWyMSN8Ll4MxXnJWmJEqMKpcAagZh64XmvkOgh/G90oBqnwnPjzRIlRhcUWB9rgV+AWbgVpp2TxR/AEm0CoTWVZCl4LLwJXgC/CSfxW788vyVK9BQtxWGtPmGd+Uj+Eu/V4Xo+lBWT7b7h7RLW0AqKDmvgep8hWRb+E15C+S95vESJTjEQAotyZyX5ErShq325bxyRdpo/wmsp+y7ShuimwKKs95OsAj8NvXfrpcH7Wfh7eA3l3UfaNXDNhUjWg5+Cb8Kn4Z3wPK6VNgRsCMosRGBxnXeQnAifgFfAueBmcG+uoRZYokRH6KvASsrbA24AZ/ZYDhRc+3GNM+LddFBmxwKLMuYn2R1ar3d6LAcKLj/IXLsRZb6XRGN5Gi6EP4EKFT/wtPdSJVgoz7yp4QvkWyLZjEDetgUW536Q5HRomoWjKeNo8n6P7f9AO55loMJ2W3gMXJk8/yMtUaJt9M3oTuPekuRP8DuwkbASC8PTOe8iqKbTE1C2H7fCUaN2I2ElFoXncJ58T3woFWofBnWm8RPwSrg5bLYTURNNK0t2BclzVlNaGaZdR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M7TjmXg5htsa/wOS+jouTTcomlwvu3B+EnrYFt7OK8OybvzWdtenyWv300mkvoZe2bH4WKPw998SwKrRIl+gUZsJLzDMv+oxEmyHQOBNT2CqiUhOxLAs1KbUTM0dTVbJ1sPg9+NBTss3hsaz+91cyIHFaXAKjGw4MPSMK+mbU9+KnR12UX4wDqxMb4twLPTzOLIQK3VIExtWA6/tIG5r8atHXAhnueIcTT1zYZVokQT0KCsA0Mbht5Ip62Uwqo56InTbOEw7McwMl1AjecKK39z2Z4RI6xEKbBKDDIUVsbg6EFyrXTDTko0AQRRcGo5bSYEfmoTcg6l08cWI0/P/jquV5hu2rRgpC9RokSJQcbQ0P8B4iEWSGS8JuEAAAAASUVORK5CYII=" Width="300" />
</t:Paragraph>
</t:Section>
</t:RadDocument>
</t:Header.Body>
<t:Header.WatermarkSettings>
<t:DocumentWatermarkSettings Type="NoWatermark" />
</t:Header.WatermarkSettings>
</t:Header>
</t:Headers.Default>
</t:Headers>
</t:Section.Headers>
<t:Paragraph StyleName="Normal">
<t:Span Text="asdfasdfsdfasd" />
</t:Paragraph>
</t:Section>
</t:RadDocument>
Here is the radDocument, the image is saved as rawdata.
I am unable to reproduce the issue. Here is the code I tested with:
RadDocument doc =
new
XamlFormatProvider().Import(File.ReadAllBytes(@
"c:\temp\xaml.xaml"
));
File.WriteAllBytes(@
"c:\temp\xaml.pdf"
,
new
PdfFormatProvider().Export(doc));
and the image in the header is exported as expected.
Regards,
Boby
Telerik by Progress