This is the code used for merging:
private void MergeDifferentDocumentsPagesWithFixed()
{
string[] documentsToMerge =
{
"14301-STOCK_Proforma.pdf",
"14302-STOCK_Proforma.pdf",
"14303-STOCK_Proforma.pdf",
"14304-STOCK_Proforma.pdf",
"14305-STOCK_Proforma.pdf",
"14330-STOCK_Proforma.pdf"
};
RadFixedDocument doc = new RadFixedDocument();
PdfFormatProvider provider = new PdfFormatProvider();
foreach (string current_item in documentsToMerge)
{
string path = @"..\..\Samples\" + current_item;
RadFixedDocument docToMerge;
if (!File.Exists(path))
{
continue;
}
using (Stream stream = File.OpenRead(path))
{
docToMerge = provider.Import(stream);
}
doc.Merge(docToMerge);
}
string outputFilePath = @"..\..\mergedFixed.pdf";
File.Delete(outputFilePath);
using (Stream output = File.OpenWrite(outputFilePath))
{
provider.Export(doc, output);
}
Process.Start(new ProcessStartInfo() { FileName = outputFilePath, UseShellExecute = true });
}
Workaround:
private void MergeDifferentDocumentsPages(string resultFileName)
{
string[] documentsToMerge =
{
"14301-STOCK_Proforma.pdf",
"14302-STOCK_Proforma.pdf",
"14303-STOCK_Proforma.pdf",
"14304-STOCK_Proforma.pdf",
"14305-STOCK_Proforma.pdf",
"14330-STOCK_Proforma.pdf"
};
File.Delete(resultFileName);
using (PdfStreamWriter fileWriter = new PdfStreamWriter(File.OpenWrite(resultFileName)))
{
foreach (string documentName in documentsToMerge)
{
string path = @"..\..\Samples\" + documentName;
using (PdfFileSource fileToMerge = new PdfFileSource(File.OpenRead(path)))
{
foreach (PdfPageSource pageToMerge in fileToMerge.Pages)
{
fileWriter.WritePage(pageToMerge);
}
}
}
}
Process.Start(new ProcessStartInfo() { FileName = resultFileName, UseShellExecute = true });
}
InvalidOperationException is thrown when exporting font that is available but not used. The stack trace is as follows: at System.Linq.Enumerable.Max(IEnumerable`1 source) at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.Fonts.Cid.CidSet.CopyPropertiesFrom(IPdfExportContext context, FontBase font) at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.Fonts.CidFontDescriptor.CalculateCidSet(IPdfExportContext context, CidFontBase font) at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.Fonts.CidFontDescriptor.<>c__DisplayClass34.<CopyPropertiesFrom>b__30() at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Utilities.PdfObjectsExtensions.ToPrimitive[P,T](PdfProperty`1 pdfProperty, Func`2 convertToPrimitive, Func`1 getDefaultValue) at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.Fonts.CidFontDescriptor.CopyPropertiesFrom(IPdfExportContext context, FontBase font) at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.Fonts.CidFontObject.CopyPropertiesFromOverride(IPdfExportContext context, FontBase font) at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.Fonts.CidFontObject.CopyPropertiesFrom(IPdfExportContext context, FontBase font) at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.Fonts.Type0FontObject.CopyPropertiesFromOverride(IPdfExportContext context, FontBase font) at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Export.PdfExporter.WriteFontsFromContext(PdfWriter writer, IPdfExportContext context) at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Export.PdfExporter.Export(IRadFixedDocumentExportContext context, Stream output) at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider.ExportOverride(RadFixedDocument document, Stream output) at Telerik.Windows.Documents.Common.FormatProviders.FormatProviderBase`1.Export(T document, Stream output)
The attached gif file illustrates the inability to open the newly added file with the password:
Sub Main()
Dim sZipFilePath As String = "..\..\test.zip"
File.Delete(sZipFilePath)
CreateArchive(sZipFilePath)
Dim decryptionSettings As DecryptionSettings = EncryptionSettings.CreateDecryptionSettings()
AddHandler decryptionSettings.PasswordRequired, AddressOf DecryptionSettings_PasswordRequired
Dim compressionSettings As CompressionSettings = Nothing
Dim encoding As Encoding = Nothing
Using oFS As FileStream = File.Open(sZipFilePath, FileMode.OpenOrCreate)
Using oArchive As ZipArchive = ZipArchive.Update(oFS, encoding, compressionSettings, decryptionSettings)
Using entry As ZipArchiveEntry = oArchive.CreateEntry("newText.txt")
Dim writer As StreamWriter = New StreamWriter(entry.Open())
writer.WriteLine("Hello world!")
writer.Flush()
End Using
End Using
End Using
End Sub
Private Sub CreateArchive(sZipFilePath As String)
Using stream As Stream = File.Open(sZipFilePath, FileMode.Create)
Dim _encryptionSettings As PasswordEncryptionSettings = EncryptionSettings.CreatePkzipPasswordEncryptionSettings()
_encryptionSettings.Password = "telerik"
Dim compressionSettings As CompressionSettings = Nothing
Dim encoding As Encoding = Nothing
Using archive As ZipArchive = ZipArchive.Create(stream, encoding, compressionSettings, _encryptionSettings)
Using entry As ZipArchiveEntry = archive.CreateEntry("text.txt")
Dim writer As StreamWriter = New StreamWriter(entry.Open())
writer.WriteLine("Hello world!")
writer.Flush()
End Using
End Using
End Using
End Sub
Private Sub DecryptionSettings_PasswordRequired(ByVal sender As Object, ByVal e As PasswordRequiredEventArgs)
e.Password = "telerik"
End Sub
Workaround: Until this bug is fixed the obsolete API could be used instead:
ZipArchive archive = new ZipArchive(stream, ZipArchiveMode.Create, true, encoding, compressionSettings, encryptionSettings)
ZipArchive oArchive = new ZipArchive(stream, ZipArchiveMode.Update, true, encoding, compressionSettings, decryptionSettings)
A page with a negative value rotation is exported as a blank image.
Workaround: Use only the Enum Rotation values (Rotate0, Rotate90, Rotate180, Rotate270).
If row has a property set on it (for example "hidden" or a style), but it does not otherwise have any cells in it, the application might run into an infinite loop. The xml will look like this:
<sheetData>
<row r="1" spans="1:2" x14ac:dyDescent="0.35">
<c r="A1"><v>1</v></c>
<c r="B1"><v>2</v></c>
</row>
<row r="2" spans="1:2" s="1" customFormat="1" x14ac:dyDescent="0.35"/>
</sheetData>
The last row has formatting applied, so it is present as an element, but has no cells. This file (when the xml is not formatted) will cause an infinite loop on import.
I have the following form:
From the screen shot above you can see that the line above 75 is perfectly ok i.e. it doesn't go and intersect with the lines of the 72
but when i perform the following code
The value of the TextBoxField is not visible until the field is clicked.
Workaround: Force content update:
foreach (var widget in textBoxField.Widgets)
{
widget.RecalculateContent();
}
If the update still doesn't fix the issue, change the font prior to setting the value of the field:
foreach (var widget in textBoxField.Widgets)
{
widget.TextProperties.Font = FontsRepository.Helvetica;
}