Does the API support for PUB to PDF/A

Hi,
I am using Aspose.Total license for java.
Is there API support to convert Microsoft Publisher to PDFA? If there is, please provide if any example code.

Regards
Kalam

@kalaza

Yes, the Aspose.PUB API for Java supports converting Microsoft Publisher (.pub) files to PDF format. However, the documentation does not explicitly mention support for converting to PDF/A format.

Here is a simple example of how to convert a .pub file to PDF using Aspose.PUB for Java:

import com.aspose.pub.PubDocument;
import com.aspose.pub.PubFileFormat;

public class PubToPdfExample {
    public static void main(String[] args) {
        // Load the PUB file
        PubDocument document = new PubDocument("input.pub");

        // Save the document as PDF
        document.save("output.pdf", PubFileFormat.PDF);
    }
}

In this example, replace "input.pub" with the path to your Microsoft Publisher file, and "output.pdf" will be the resulting PDF file.

For PDF/A conversion, you may need to check if additional settings or libraries are required, as the current documentation does not provide specific details on this feature. You can explore the Aspose.PUB documentation for more information and updates regarding this functionality.

If you have further questions or need assistance, feel free to ask!

Sources:
[1]: Aspose.PUB Product family | Documentation

Hi,
Thanks for the quick reply.
Does this mean that you don’t know if the Apose.PUB for java has PDF/A conversion support or not?

I have already checked those materials you have referenced here. Nothing found.

Anything concrete?

@kalaza

We are afraid that no direct PDF/A conversion is supported yet. You need to use Aspose.PDF to convert resultant file into PDF/A.

Thanks, I had the same understanding and aready did that same as you have mentioned.

Hi again,
I am using the example code like here: Aspose.PUB-for-Java/Examples/src/main/java/com/aspose/pub/conversion/ConvertPUBtoPDF.java at master · aspose-pub/Aspose.PUB-for-Java · GitHub

And the christmas.pub file from the example. There is some font related error. Do you get the same error?

class com.aspose.pub.exceptions.ConvertException: Can't create PDF font with name = JuneBug --> PDF: Font JuneBug was not found\n" +
    'com.aspose.pub.internal.l40y.lf.lI(Unknown Source)\n' +
    'com.aspose.pub.lc.lI(Unknown Source)\n' +
    'com.aspose.pub.lc.lI(Unknown Source)\n' +
    'com.aspose.pub.lc.lI(Unknown Source)\n' +
    'com.aspose.pub.lc.lI(Unknown Source)\n' +
    'com.aspose.pub.lc.convertToPdf(Unknown Source)\n' +

Using halloween-flyer.pub file different font error:

class com.aspose.pub.exceptions.ConvertException: Can't create PDF font with name = skullphabet --> PDF: Font skullphabet was not found\n" +
    'com.aspose.pub.internal.l40y.lf.lI(Unknown Source)\n' +
    'com.aspose.pub.lc.lI(Unknown Source)\n' +
    'com.aspose.pub.lc.lI(Unknown Source)\n' +
    'com.aspose.pub.lc.lI(Unknown Source)\n' +
    'com.aspose.pub.lc.lI(Unknown Source)\n' +
    'com.aspose.pub.lc.convertToPdf(Unknown Source)\n' +

Check the attachment:
image.png (52.0 KB)

Java version:

java -version
openjdk version "11.0.24" 2024-07-16
OpenJDK Runtime Environment (build 11.0.24+8-post-Ubuntu-1ubuntu322.04)
OpenJDK 64-Bit Server VM (build 11.0.24+8-post-Ubuntu-1ubuntu322.04, mixed mode, sharing)

My Java code for pub to pdf conversion is

IPubParser parser = PubFactory.createParser(args.inputFilePath);
// Save as PDF file format
Document doc = parser.parse();
PubFactory.createPdfConverter().convertToPdf(doc, args.outputFilePath);

However, in your above example code PubDocument even could not found in the aspose-pub jar.

@kalaza

We are working on this case and will get back to you shortly.

@kalaza

We tested using 22.8 version of the API in our environment while using the code snippet in the screenshot and we could not replicate the issue that you have mentioned.
image.png (18.4 KB)

Attached is the output PDF that we have obtained.
result_out.pdf (3.5 MB)

Could you please make sure to refresh the Maven Cache and make sure that all indices are up to date.

Hi, Thanks. Which Java version you are using in this testing?

My Java version: openjdk version “11.0.24” 2024-07-16
Aspose: aspose-pub-22.8.jar

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.aspose.pub.internal.pdf.internal.imaging.internal.p825.z3 (file:/var/lib/tomcat9/repos/src/lib/aspose-pub-22.8.jar) to field java.io.ByteArrayInputStream.buf
WARNING: Please consider reporting this to the maintainers of com.aspose.pub.internal.pdf.internal.imaging.internal.p825.z3
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Exception in thread "main" class com.aspose.pub.exceptions.ConvertException: Can't create PDF font with name = skullphabet --> PDF: Font skullphabet was not found
com.aspose.pub.internal.l40y.lf.lI(Unknown Source)
com.aspose.pub.lc.lI(Unknown Source)
com.aspose.pub.lc.lI(Unknown Source)
com.aspose.pub.lc.lI(Unknown Source)
com.aspose.pub.lc.lI(Unknown Source)
com.aspose.pub.lc.convertToPdf(Unknown Source)
example_test.ConvertPUBtoPDF.main(ConvertPUBtoPDF.java:22)
	at com.aspose.pub.internal.l40y.lf.lI(Unknown Source)
	at com.aspose.pub.lc.lI(Unknown Source)
	at com.aspose.pub.lc.lI(Unknown Source)
	at com.aspose.pub.lc.lI(Unknown Source)
	at com.aspose.pub.lc.lI(Unknown Source)
	at com.aspose.pub.lc.convertToPdf(Unknown Source)
	at example_test.ConvertPUBtoPDF.main(ConvertPUBtoPDF.java:22)

Code:

package example_test;

import com.aspose.pub.Document;
import com.aspose.pub.IPubParser;
import com.aspose.pub.PubFactory;

public class ConvertPUBtoPDF {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		//ExStart: 1
		// The path to the documents directory.
        String dataDir = "/home/kalam/Downloads/";
        
        String fileName = dataDir + "halloween-flyer.pub";
        
		IPubParser parser = PubFactory.createParser(fileName);

		Document doc = parser.parse();

		com.aspose.pub.PubFactory.createPdfConverter().convertToPdf(doc, dataDir + "halloween-flyer_out.pdf");
		
		System.out.println("Execution done.");
		//ExEnd: 1
	}

}

@kalaza

Please allow us to investigate a bit more and we will get back to you shortly.

Ok, thanks.

Waiting for your support, hopefully you manage to repro my case and provide a solution.

@kalaza

We tried with JDK1.8 in our environment and could not replicate the issue. The API last release is quite old and we further need to check its compatibility with JDK11. Can you please try with JDK1.8 in your environment to see if its working or the issue is your environment specific?

Hi,
Thanks and now i get it work. Problem was my Linux environment was missing some Microsoft core fonts.

Another question, there is always a xml log file creates during the PDF to PDFA conversion and left as trash. Is there a way to use the API to instruct delete the file after converion?

My PDF to PDFA code:

try (com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document(pathForPDF)) {
		pdfDocument.convert(inputFile.getPath()+"out.xml",PdfFormat.PDF_A_1A, ConvertErrorAction.Delete);
		// Save as PDF/A
		pdfDocument.save(outputFilePath);
	    }
	    	    

@kalaza

Instead of saving the log file to a physical file path, you can use stream and dispose that stream after the document is converted and saved.

ok, thanks.

More question about the performance. Have you done any performance analysis with your APIs? Would be good to know the result.

I found your example files takes about 8-11 sec for PUB to PDF conversion. is this normal?

@kalaza

Yes, we do performance analysis before releasing the API update. We test it with 1000s of sample files. The real performance of the API should be measured in Release mode instead of Debug. Also, the load time of a file depends upon the structure and complexity. Nevertheless, please check in Release mode as well with the latest version of the API and let us know if results are not as per your expectations.

We test it with 1000s of sample files.
I could not understand this unfortunately. So, for example if you are testing with the halloween-flyer.pub to pdf then how long it takes?

1000s, Is it seconds or milliseconds?

please check in Release mode
How to do that?
Isn’t when I am using a released Aspose.pub jar is a out of the box is release mode?
It would be good if you provide any code example.

@kalaza

All tests are done during the development and with pre-release build of the API. We are afraid that we do not publish the stats of our tests.

These are the number of sample and different files that we use for API testing. Its not the time of processing.

Furthermore, please note that the API performance depends upon file complexity (as shared earlier) as well as the environment and Java Heap Size where it is being used. We will surely address this case where you are facing the performance issue in terms of file generation time. However, we may need some details like your environment (OS Name and Version, JDK Version, Installed RAM Size, Java Heap Size, etc.).

There is no special code sample for that. We requested that you please check your sample application in release mode, which typically means testing it as it would behave in a production environment.

Hi Thanks.
Here is my performance test result. Could you verify if the performance is as expected according to your standard?

Test Environment:
OS:
Ubuntu 22.4 LTS
Java:
openjdk version “11.0.24” 2024-07-16
OpenJDK 64-Bit Server VM
VM settings:
Max. Heap Size (Estimated): 7.76G
Using VM: OpenJDK 64-Bit Server VM
Memory:
32 GigaBytes

image.png (35.9 KB)

@kalaza

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PUBJAVA-34

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.