镜像(翻转)打印 PDF 文件
我使用 ASP.NET (Framework 3.5) 和 Crystal Reports 在 PDF 文件中生成我大学学生的身份证,但我想将卡打印在透明纸上并将其粘贴到相同尺寸的塑料卡上,因为我需要所有要打印的东西都是镜像的。 我尝试以镜像形式设计水晶报告本身,但找不到以镜像形式编写文本的方法。任何人都可以建议一种方法来完成这项工作,我想要的只是翻转 PDF 文件或 Crystal Report 中的内容。
I generating ID Cards of Students of My College in a PDF file using ASP.NET (Framework 3.5) and Crystal Reports But I Want to print the Cards in a Transparent Sheet and Paste it on a Plastic Card of same size for that i need the everything to be printed mirrored.
I tried designing the crystal reports in mirrored form itself but could not find a way to write text in mirrored form. Can anyone suggest a way to do this work all I want is to Flip the contents in PDF File or in Crystal Report.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
几个想法:
1)将 PDF 渲染为图像(使用 Ghostscript/ImageMagick 或商业 PDF 库((例如 Tif))并镜像图像以进行打印
2)镜像 PDF 本身,可能可以使用 iTextSharp
3)使用报告工具并尝试使用某种反向字体(可能是快速选项)
A couple of Ideas:
1) Render the PDF to an Image (using Ghostscript/ImageMagick or commercial PDF library( (eg Tif) and mirror the image for printing
2) Mirror the PDF Itself, might be possible with iTextSharp
3) Use the reporting tool and try and use some kind of reverse font (coud be quick option)
任何允许您导入页面并直接写入 PDF 内容流的 API 都可以让您执行此操作。
在 iText (Java) 中,它看起来像这样:
上面的代码正在执行以下操作:
Document()
页面大小与当前Document() 页面大小匹配代码>PdfImportedPage
。一些解决方法:
公平警告:我的 2d 矩阵 fu 并不是那么强大。我几乎肯定做错了什么。调试这些东西是真正的 PITA。东西要么“看起来正确”,要么完全搞砸了,完全脱离了页面(因此看不见,所以你不知道它往哪个方向走)。我经常将页面矩形更改为 [-1000 -1000 1000 1000],这样我就可以看到它们都去了哪里。有趣的东西。
至于复制注释之类的……哎呀。 PdfCopy 通过它的
addPage()
方法为您完成所有这些工作,但这并不能让您首先转换页面内容。您对 PdfImportedPage 所做的任何更改都将被忽略。您真的陷入了艰难的道路...手动复制所有繁琐的位并更改它们以补偿翻转的页面...或者将源代码弄乱到addPage()
以获得结果你想要的。两者都需要对 PDF 有一定的深入了解。考虑到具体细节,您可能不需要担心它,但值得一提的是,以防情况不同的人有相同的目标。
Any API that lets you import pages and write directly to the PDF content stream will let you do this.
In iText (Java), it'd look something like this:
The above code is making the following ass-u-me-ptions:
Document()
page size matches the size of the currentPdfImportedPage
.Some workarounds:
FAIR WARNING: My 2d matrix-fu isn't all that strong. I'm almost certainly doing something wrong. Debugging these sorts of things is a real PITA. Stuff either "looks right" or is so badly screwed up its off the page entirely (ergo invisible, so you don't know which way it went). I often change the page rectangles by [-1000 -1000 1000 1000] just so I can see where it all went. Fun stuff.
As for copying annotations and such... ouch. PdfCopy does all that for you, via it's
addPage()
method, but that doesn't let you transform the page content first. Any changes you make to the PdfImportedPage are ignored. You're really stuck with The Hard Way... manually copying all the fiddly bits and changing them to compensate for your flipped page... or messing with the source toaddPage()
to get the results you want. Both require some in-depth knowledge of PDF.Given the specifics, you probably don't need to worry about it, but it's worth mentioning in case someone with a different situation comes along with the same goal.