简体   繁体   English

PDF小丑不呈现文本

[英]PDF Clown does not render text

I use PDF Clown to create PDF files containing text and different shapes. 我使用PDF小丑创建包含文本和不同形状的PDF文件。 Saving the files brings the desired result. 保存文件带来了预期的结果。 But when I print the pages or render them to bitmaps, only the shapes are visible and the text elements are missing. 但是,当我打印页面或将它们渲染为位图时,只有形状可见,文本元素丢失了。

I tried already different versions of the library with multiple files, always getting the same result. 我尝试了具有多个文件的库的不同版本,总是得到相同的结果。

Maybe someone can give me a hint on this issue. 也许有人可以给我提示这个问题。

EDIT: 编辑:

This is a simplified form of the source code I use (with same result as described above; see the image at the end): 这是我使用的源代码的简化形式(具有与上述相同的结果;请参见最后的图像):

File file = new File();

Document document = file.Document;
document.PageSize = PageFormat.GetSize(PageFormat.SizeEnum.A4, PageFormat.OrientationEnum.Portrait);

Page page = new Page(document);
document.Pages.Add(page);

PrimitiveComposer composer = new PrimitiveComposer(page);


//draw a rectangle
composer.SetFillColor(DeviceRGBColor.Get(System.Drawing.Color.LightSalmon));
composer.DrawRectangle(new RectangleF(30, 42, 300, 32));
composer.Fill();


//draw some text
composer.SetFillColor(DeviceRGBColor.Get(System.Drawing.Color.Black));
composer.SetFont(new StandardType1Font(document, StandardType1Font.FamilyEnum.Courier, true, false), 32);
composer.ShowText("Hello World!", new PointF(32, 48));
composer.Flush();


//save the file
file.Save(@"..\document.pdf", SerializationModeEnum.Standard);


//and print it
Renderer renderer = new Renderer();
renderer.Print(file.Document, false);

Result of the above code (the printed version was created with virtual printer Adobe PDF ; also tested with XPS Document Writer ): 以上代码的结果(打印版本是使用虚拟打印机Adobe PDF创建的;还使用XPS Document Writer进行了测试):

在此处输入图片说明

(I don't have enough points to add a comment so I put this comment as an answer.) If you look in the source for the RenderingSample class, you will see this comment: (我没有足够的分数来添加评论,所以我将此评论作为答案。)如果您查看RenderingSample类的源代码,则会看到以下评论:

This sample demonstrates how to render a PDF page as a raster image. 此示例演示如何将PDF页面呈现为光栅图像。 Note: rendering is currently in pre-alpha stage; 注意:目前渲染处于预Alpha阶段; therefore this sample is nothing but an initial stub (no assumption to work!). 因此,此样本不过是一个初始存根而已(无任何假设!)。

I don't think Stephano Chizzolini got around to finishing it. 我不认为Stephano Chizzolini可以完成它。

There is another NuGet download, PDFClown.Net version 2.0.0, by Matthieu. Matthieu还有另一个NuGet下载文件,即PDFClown.Net版本2.0.0。 It has tags for PDF-To-Image, Rasterizer and PDF, but I have not been able to get it to work either. 它具有用于PDF到图像,光栅化器和PDF的标签,但我也无法使其正常工作。 I cannot find documentation for it. 我找不到它的文档。 Inspection of the properties for the downloaded NuGET assembly shows version 0.1.2.0 instead of 2.0.0. 对下载的NuGET程序集的属性进行检查的结果显示版本为0.1.2.0,而不是2.0.0。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM