When importing a document containing a CIDFont with default width (DW) set as PdfReal (double) an exception is thrown: System.InvalidCastException: 'Unable to cast object of type 'Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Types.PdfReal' to type 'Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Types.PdfInt'.'
44 0 obj
<< /BaseFont /NotoSansMono-Medium /CIDSystemInfo << ... >> /CIDToGIDMap /Identity /DW 600.00000 ... /Subtype /CIDFontType2 /Type /Font >>
endobj
According to the PDF Specification: DW - integer - (Optional) The default width for glyphs in the CIDFont. Default value: 1000.
When using the RadFixedDocument.Pages.AddPage() method RadFixedPages are created without PageNumber set.
Such behavior is observed when exporting a RadFlowDocument to a RadFixedDocument using the ExportToFixedDocument as well.
PDF / X: the X stands for exchange; a PDF / X document can in principle be processed by any printing company. This means, for example, that only CMYK colors may be used, that all fonts must be present in the PDF, that the document must not be encrypted, and so on.
Hi,
I am trying to convert a HTML body to a PDF using HtmlFormatProvider and PdfFormatProvider.
It works well when I try to create a pdf with "normal" characters, but when I use characters like "åäö" the characters is either missing or replaced with other character.
I have found a similiar issue but that was due to the fact that the person was using .net core I am using .net framework.
Am I missing something when I am converting it to a PDF or is there a limitation with special characters like "åäö".
private string CreateAndStorePdf(string htmlBody)
{
Telerik.Windows.Documents.Extensibility.JpegImageConverterBase jpegImageConverter = new Telerik.Documents.ImageUtils.JpegImageConverter();
Telerik.Windows.Documents.Extensibility.FixedExtensibilityManager.JpegImageConverter = jpegImageConverter;
var provider = new HtmlFormatProvider();
var document = provider.Import(htmlBody);
var exportProvider = new PdfFormatProvider();
var fixedExportProvider = new Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider();
var fileName = "_original.pdf";
try
{
using (var outputStream = new MemoryStream())
{
exportProvider.Export(fixedExportProvider.ExportToFixedDocument(document), outputStream);
outputStream.Seek(0, SeekOrigin.Begin);
var pdfBytes = new BinaryReader(outputStream).ReadBytes((int)outputStream.Length);
return fileName;
}
}
catch (Exception ex)
{
Log.Error(ex, "The pdf could not be created.");
return null;
}
}
ArgumentOutOfRangeException is thrown when importing a document because of wrongly parsing to Unicode mapping.
System.ArgumentOutOfRangeException: 'Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index'
When exporting merged documents when they are imported with ImportSettings set to ReadOnDemand an exception is thrown: KeyNotFoundException: 'The given key was not present in the dictionary.'
When a document containing a SignatureField is exported with the IsEncrypted property set to true, a not set UserPassword is required to open it, which makes it impossible to be opened. An InvalidOperationException is thrown with the message "Password is not correct." when importing with PdfProcessing; Adobe Acrobat also doesn't recognize the password.
Workaround: Exporting with AES256 encryption does not have this problem:
provider.ExportSettings = new PdfExportSettings
{
IsEncrypted = true,
EncryptionType = EncryptionType.AES256
};
This could be implemented by linking to RadFixedPages or Bookmarks.
Until this feature is developed this could be custom created with the help of Link annotations:
RadFixedPage toc = new RadFixedPage();
document1.Pages.Insert(0, toc);
FixedContentEditor editor = new FixedContentEditor(toc);
foreach (RadFixedPage page in document1.Pages)
{
int pageNumber = document1.Pages.IndexOf(page);
if (pageNumber > 0)
{
int factor = 20;
int offsetX = 70;
int offsetY = 20 + factor * pageNumber;
editor.Position.Translate(offsetX, offsetY);
Block block = new Block();
block.GraphicProperties.FillColor = new RgbColor(255, 5, 99, 193);
block.InsertText($"Page {pageNumber}");
Size blockSize = block.Measure();
editor.DrawBlock(block);
Location location = new Location
{
Left = 0,
Top = 0,
Zoom = 0,
Page = page
};
GoToAction goToAction = new GoToAction();
goToAction.Destination = location;
Link uriLink = toc.Annotations.AddLink(goToAction);
uriLink.Rect = new Rect(offsetX, offsetY, blockSize.Width, blockSize.Height);
}
}