将字符串转换为PDF [英] Convert a string to PDF
问题描述
下午好世界。我正在开发一个VB net 2017程序来使用REST服务来生成PDF文件。
PDF带有属性pdf的字符串响应和用基数64编码。
我将尝试用指令解码字符串:
strPdf = New System.Text.ASCIIEncoding()。GetString(Convert.FromBase64String(strWork_PDF))。
strWork_PDF是一个变量字符串,我已经拥有了编码信息。
更正:我的回复包含徽标和某种格式,所以也许它不是100%的字符串变量。
从那里,我需要创建PDF文件;我认为解码后的字符串包含正确的PDF格式,但我不对。我得到的PDF就像解码后的字符串一样,纯文本,完全没有格式,所以也许我需要一个模板,但除非我的供应商想把它交给我,否则我没有。< br $> b $ b
这就是我想要找到的,如何转换它。
I'我将非常感谢您寻求解决方案或进行调查的任何帮助或提示。
我的尝试:
我正在分析Itextsharp.dll组件以查看它是否适合我需要的内容。
Good Afternoon World. I'm developing a VB net 2017 program to consume a REST service to generate a PDF file.
The PDF comes in a string response with the attribute "pdf" and is encoded in base 64.
I'm going to try to decode the string with the instruction:
strPdf = New System.Text.ASCIIEncoding().GetString(Convert.FromBase64String(strWork_PDF)).
strWork_PDF is a variable string in which I already have the encoded information.
CORRECTION: My response includes a Logo and some kind of a format, so maybe it´s not a 100% string variable.
From there, I'll need to create the PDF file; I supposed the decoded string contains the right format for the PDF, but I was not right. The PDF I´m getting is just like the same as the decoded string, plain text, with no format at all, so maybe I need a template,but I don´t have it unless my vendor want to deliver it to me.
That´s what I´m trying to find out, how to convert it.
I´ll appreciate any help or tip about where to look for a solution or to investigate.
What I have tried:
I´m analyzing the Itextsharp.dll component to see if it suits what I need in the meantime.
推荐答案
A PDF文件不是字符串。它是一个字节序列。
如果您的响应包含Base64编码的PDF文件,您只需要将其转换回字节数组:
A PDF file is not a string. It is a sequence of bytes.
If your response contains a Base64-encoded PDF file, you just need to convert that back to an array of bytes:
Dim pdfBytes As Byte() = Convert.FromBase64String(strWork_PDF)
这篇关于将字符串转换为PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!