I wil really appreciate if somebody can help me with an issue. We would like to have a solution to convert EPS files to TIFF. I found a code sample and tried it EPS to TIFF Converter using Java | Aspose.PDF
But I got an exception
class com.aspose.pdf.exceptions.InvalidPdfFileFormatException: Incorrect file header
com.aspose.pdf.internal.l11t.l0u.l0n(Unknown Source)
com.aspose.pdf.internal.l11t.l0u.(Unknown Source)
com.aspose.pdf.internal.l11t.l0u.(Unknown Source)
com.aspose.pdf.internal.l8y.lf.lb(Unknown Source)
com.aspose.pdf.internal.l11t.l0p.(Unknown Source)
com.aspose.pdf.internal.l8y.lf.le(Unknown Source)
com.aspose.pdf.internal.l3v.l1f.lI(Unknown Source)
com.aspose.pdf.internal.l3v.l1f.(Unknown Source)
com.aspose.pdf.ADocument.lf(Unknown Source)
com.aspose.pdf.ADocument.(Unknown Source)
com.aspose.pdf.Document.(Unknown Source)
Also I tried to convert an EPS file online and it failed either.
@igor.ivanov
Could you please share your sample EPS file for our reference as well? We will test the scenario in our environment and address it accordingly.
@igor.ivanov
Below is the correct code snippet to convert EPS file into TIFF using Aspose.PDF for Java:
System.out.println("Convert PDF to TIFF...");
CompressionType compressingType = CompressionType.CCITT3; // Default compression type
com.aspose.pdf.devices.ColorDepth colorDepth = com.aspose.pdf.devices.ColorDepth.Default;
OutputStream imageStream = null;
Document pdfDocument = null;
try {
// Load the EPS file as a PDF document
pdfDocument = new Document(dataDir + "218801.eps", new PsLoadOptions());
// Create an output stream for the TIFF file
imageStream = new FileOutputStream(dataDir + "sample.pdf.tiff");
// Set resolution (dots per inch)
com.aspose.pdf.devices.Resolution resolution = new com.aspose.pdf.devices.Resolution(300);
// Configure TIFF settings
com.aspose.pdf.devices.TiffSettings tiffSettings = new com.aspose.pdf.devices.TiffSettings();
tiffSettings.setCompression(compressingType);
tiffSettings.setDepth(colorDepth);
tiffSettings.setSkipBlankPages(false);
// Create a TiffDevice and process the PDF document into a TIFF file
TiffDevice tiffDevice = new TiffDevice(resolution, tiffSettings);
tiffDevice.process(pdfDocument, imageStream);
System.out.println("Converting PDF to TIFF done");
} finally {
// Ensure resources are closed
if (pdfDocument != null) {
pdfDocument.close();
}
if (imageStream != null) {
imageStream.close();
}
}
We tried it in our environment and faced below exception:
class com.aspose.pdf.exceptions.PdfException: Problem with Ps2Pdf occurs ---> java.io.IOException: Resetting to invalid mark
--- End of inner exception stack trace ---
com.aspose.pdf.l6y.lI(Unknown Source)
com.aspose.pdf.ADocument.lI(Unknown Source)
com.aspose.pdf.ADocument.lI(Unknown Source)
com.aspose.pdf.ADocument.<init>(Unknown Source)
com.aspose.pdf.Document.<init>(Unknown Source)
Aspose.Test.PdftoTiff(Test.java:5129)
Aspose.Test.Run(Test.java:166)
Aspose.Test.main(Test.java:76)
at com.aspose.pdf.l6y.lI(Unknown Source)
at com.aspose.pdf.ADocument.lI(Unknown Source)
at com.aspose.pdf.ADocument.lI(Unknown Source)
at com.aspose.pdf.ADocument.<init>(Unknown Source)
at com.aspose.pdf.Document.<init>(Unknown Source)
at Aspose.Test.PdftoTiff(Test.java:5129)
at Aspose.Test.Run(Test.java:166)
at Aspose.Test.main(Test.java:76)
Caused by: java.io.IOException: Resetting to invalid mark
at java.io.BufferedInputStream.reset(BufferedInputStream.java:448)
at com.aspose.pdf.internal.l17y.ld.reset(Unknown Source)
at com.aspose.pdf.internal.eps.postscript.l3if.cy_(Unknown Source)
at com.aspose.pdf.internal.l16v.l0t.lt(Unknown Source)
at com.aspose.pdf.internal.l16v.l0t.lf(Unknown Source)
at com.aspose.pdf.internal.l16v.l0t.lI(Unknown Source)
at com.aspose.pdf.internal.l16v.l0t.lI(Unknown Source)
... 8 more
Therefore, an issue has been registered in our issue tracking system for its resolution. We will be attaching the ticket with this forum thread shortly and you will receive an automated response. We will look into the details of the ticket and let you know as soon as it is resolved. Please be patient and spare us some time.
We apologize for the inconvenience.
@igor.ivanov
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): PDFJAVA-44624
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.