When ever any zip files attach to PDF, that I am not able to save/open. While opening getting error in attached image, any java code can help in removing this error so I can download successfully.
image.png (11.6 KB)
When ever any zip files attach to PDF, that I am not able to save/open. While opening getting error in attached image, any java code can help in removing this error so I can download successfully.
image.png (11.6 KB)
It seems that the issue you’re experiencing with opening ZIP file attachments in a PDF is related to limitations in Adobe Reader rather than a problem with the Aspose API itself. Users have reported similar issues, and it may be beneficial to check related discussions on forums where solutions have been suggested, such as ensuring the file is properly transformed for compatibility with Adobe Reader.
If you want to remove the ZIP attachments from the PDF to avoid this error, you can use the following Java code snippet. This code demonstrates how to delete all attachments from a PDF document using Aspose.PDF:
package com.aspose.pdf.examples.AsposePdfExamples.Attachments;
import com.aspose.pdf.Document;
import com.aspose.pdf.examples.Utils;
public class DeleteAllAttachmentsFromPDF {
public static void main(String[] args) {
runExamples();
}
public static void runExamples() {
// The paths to resources and output directories.
String testID = "com/aspose/pdf/examples/AsposePdf/Attachments/deleteallattachments/";
String dataDir = Utils.getDataDir(testID);
String outputDir = Utils.getOutDir(testID);
System.out.println("============================");
System.out.println("Example deleteAllAttachmentsFromPDF start");
deleteAllAttachmentsFromPDF(dataDir, outputDir);
System.out.println("Example deleteAllAttachmentsFromPDF end");
}
private static void deleteAllAttachmentsFromPDF(String dataDir, String outputDir) {
// Open a document
Document pdfDocument = new Document(dataDir + "input.pdf");
// Delete all attachments
pdfDocument.getEmbeddedFiles().delete();
// Save the updated file
pdfDocument.save(outputDir + "output.pdf");
}
}
This code will open a specified PDF file, remove all embedded files (attachments), and save the modified document. Make sure to replace "input.pdf"
with the path to your actual PDF file.
If you continue to face issues, consider checking the Adobe Reader forums for additional insights or potential fixes related to ZIP file handling.
Sources:
[1]: PDF ZIP Attachments - cannot Save Zip Attachment in Adobe Reader
[2]: DeleteAllAttachmentsFromPDF.java
I don’t know much about this type of zip file. But I would like to learn more. Thank you so much!
Are you adding the .zip attachments in PDF yourself or just receiving such files from external sources? Can you please share the sample code snippet and the sample file for our reference so that we can test the scenario in our environment and address it accordingly.