简体   繁体   English

如何确保生成的 PDF 在 PDFsharp 中保持一致?

[英]How do I ensure generated PDFs are consistent in PDFsharp?

I am using PDFsharp and System.Drawing.Image to convert TIFF files to PDFs.我正在使用 PDFsharp 和 System.Drawing.Image 将 TIFF 文件转换为 PDF。 After I generate the data to a stream, I convert it to a base64 string.在我将数据生成为 stream 之后,我将其转换为 base64 字符串。 However, even though I convert the same file, when I compare them, the strings have a couple characters that are different between runs.然而,即使我转换同一个文件,当我比较它们时,字符串有几个字符在运行之间是不同的。 They appear perceptually the same but I do not know why there is variation in the end result.它们在感知上看起来是一样的,但我不知道为什么最终结果会有所不同。

Is there something in PDFsharp that needs to be set in order for PDF generation to be the exact same when I attempt to convert the same file?当我尝试转换同一个文件时,PDFsharp 中是否需要设置某些内容才能使 PDF 生成完全相同? I know that if I have a PdfDocument p that p.Info.CreationDate is set to the current time so I set it to new DateTime() instead.我知道如果我有一个PdfDocument pp.Info.CreationDate被设置为当前时间,所以我将它设置为new DateTime()

I do not believe the variability is caused by the byte array to base64 string because I use Convert.ToBase64String(myByteAarray) .我不相信可变性是由字节数组到 base64 字符串引起的,因为我使用Convert.ToBase64String(myByteAarray)

To do the actual conversion, I use a process based on work by Steven Wellens: https://stackoverflow.com/a/35209378/19831782为了进行实际转换,我使用了基于 Steven Wellens 工作的过程: https://stackoverflow.com/a/35209378/19831782

Fonts will be embedded using random names, so there will be some minor differences between PDF files created in different runs. Fonts 将使用随机名称嵌入,因此在不同运行中创建的 PDF 文件之间会有一些细微差别。

The GUID of the document (if any) will be different on each run.文档的 GUID(如果有)在每次运行时都不同。

There is no option (yet) to generate identical PDF files in different runs.没有选项(还)在不同的运行中生成相同的 PDF 文件。

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

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