We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Problem saving new PDF to PDF-A standard

Hi there,


I tried to use the simple example of converting an image via aspose pdf.

aspose.pdf.Pdf pdf1 = new aspose.pdf.Pdf();
aspose.pdf.Section sec1 = pdf1.getSections().add();
aspose.pdf.Image img1 = new aspose.pdf.Image(sec1);
sec1.getParagraphs().add(img1);
byte[] bytes = IOUtils.toByteArray(is);
img1.getImageInfo().setMemoryData(bytes);
img1.getImageInfo().setTitle(“JPEG image”);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
pdf1.setConformance(???);
pdf1.save(baos);


One thing I am not able to do is setting the PdfConformance Level. The Enum seems a bit weird for my understanding. Can you provide any assistance on this please?

Oh and it might be nice if the package structure would match the other aspose products, starting with com.aspose instead of just aspose.

Thanks in Advance.

Hi there,


Thanks for your inquiry. Please check following code snippet to convert Image to PDF and then saving it PDFA using DOM approach. Hopefully it will help you to accomplish the task.

String inFile = myDir + “Test
(2).tif”
;<o:p></o:p>

com.aspose.pdf.Document doc = new com.aspose.pdf.Document();

com.aspose.pdf.Page page = doc.getPages().add();

java.io.FileInputStream imageStream = new java.io.FileInputStream(

new java.io.File(inFile));

page.getPageInfo().getMargin().setBottom(0);

page.getPageInfo().getMargin().setTop(0);

page.getPageInfo().getMargin().setLeft(0);

page.getPageInfo().getMargin().setRight(0);

page.getPageInfo().setHeight(

com.aspose.pdf.PageSize.getA4().getHeight());

page.getPageInfo().setWidth(com.aspose.pdf.PageSize.getA4().getWidth());

// Create an image object

com.aspose.pdf.Image image1 = new com.aspose.pdf.Image();

// Add the image into paragraphs collection of the section

page.getParagraphs().add(image1);

// Set the ImageStream to a MemoryStream object

image1.setImageStream(imageStream);

ByteArrayOutputStream baos = new ByteArrayOutputStream();

doc.save(baos);

ByteArrayInputStream bais= new ByteArrayInputStream(baos.toByteArray());

com.aspose.pdf.Document document = new com.aspose.pdf.Document(new ByteArrayInputStream(baos.toByteArray()));

document.convert(myDir+"logFile.txt", PdfFormat.PDF_A_1A, ConvertErrorAction.Delete);

document.save(myDir+"AsposePDF_PDFA.pdf");

document.dispose();


Please feel free to contact us for any further assistance.


Best Regards,

Thank you very much for your help :slight_smile:

Hi there,


Thanks for your feedback. It is good to know that you have managed to accomplish your requirement.

Please keep using our API and feel free to ask any question or concern. We will be more than glad to extend our support.

Best Regards,