使用Aspose Pdf for java从字节数组创建PDF

时间:2017-03-23 11:40:18

标签: java pdf aspose aspose.pdf

我正在尝试使用字节数组生成pdf文件,我正在使用此代码:

    byte[] input = content.getBytes();
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    Document pdfDoc = new Document(new ByteArrayInputStream(input));
    pdfDoc .save(output, SaveFormat.Pdf);

但我得到了这个错误:

Incorect file format com.aspose.pdf.exceptions.InvalidPdfFileFormatException: Incorect file format
at com.aspose.pdf.internal.p116.z6.m1(Unknown Source)
at com.aspose.pdf.internal.p75.z26$z1.deserialize(Unknown Source)
at com.aspose.pdf.internal.p115.z8.deserialize(Unknown Source)
at com.aspose.pdf.internal.p109.z17.<init>(Unknown Source)
at com.aspose.pdf.internal.p109.z17.<init>(Unknown Source)
at com.aspose.pdf.internal.p79.z2.m1(Unknown Source)
at com.aspose.pdf.internal.p109.z16.<init>(Unknown Source)
at com.aspose.pdf.internal.p79.z2.m5(Unknown Source)
at com.aspose.pdf.internal.p24.z13.m2(Unknown Source)
at com.aspose.pdf.internal.p24.z13.<init>(Unknown Source)
at com.aspose.pdf.ADocument.m1(Unknown Source)
at com.aspose.pdf.ADocument.<init>(Unknown Source)
at com.aspose.pdf.ADocument.<init>(Unknown Source)
at com.aspose.pdf.Document.<init>(Unknown Source)

请帮助我解决这个问题吗?

0 个答案:

没有答案