I am having issue to view XFA PDF in Google chrome. I am able to open the same PDF in Acrobat reader but when I view in chrome I get “Please wait...” message.
Can you please let me know if there is any solution to fix this issue?
The XML Forms Architecture is deprecated in ISO 32000-2 (released in 2017). One of the reasons for deprecation was the fact that adoption of XFA was poor. This wasn't a problem when Adobe Reader had a high penetration, but it became problematic with the advent of pdf.js, Chrome's PDF viewer, Microsoft's PDF viewer, etc. None of those viewers supported XFA. Instead of rendering the XML stream, they just render the single (static) PDF page that is usually stored inside an XFA document. PDF renders much quicker than XML, and the static PDF page saying "Please wait..." was there to bridge the gap between opening the document and rendering the XML in Adobe Reader. It's also the page that is shown by PDF viewers who don't support XFA. Those viewers know how to render the PDF part of the form, but they don't know how to parse the XFA stream.
To make a long story short: there is no fix for your issue. Google Chrome doesn't support XFA, and as XFA is deprecated, Google Chrome won't support XFA in the future either.
There might be a workaround if you are allowed to flatten the form. For instance: XFA is often used as a templating format.
The template defines what a final document has to look like.
XML data is merged into the template.
The XFA template with the data is flattened to an ordinary PDF document.
Once an XFA form is flattened to an ordinary PDF document, the document is no longer interactive. No data can be entered; all interactivity is gone. There is no XFA XML stream inside the document anymore.
There are two products that can flatten an XFA form: Adobe LC Enterprise Suite, and iText's pdfXFA add-on. Both of these products are closed source, commercial products.
Related
When a PDF document is protected with a security policy from Adobe LiveCycle ES or Adobe AEM Forms, it can only be opened by Adobe Reader. Here's what it looks like when you try to open it in another PDF viewer.
Microsoft Edge:
Firefox (internally uses PDF.js):
But I have seen secured PDF documents that in other viewers show customised instructions to download and install Adobe Reader. Obviously there is a way to add unprotected content to protected PDF files, that other PDF viewers will display. How can I do it?
Here's an example of a PDF file I'm talking about.
When opened in Adobe Reader:
When opened in Firefox:
I also posted this question on Adobe forums, and someone replied with the correct answer there. AEM Forms has a feature that allows to add cover page to a policy-protected document: https://help.adobe.com/en_US/AEMForms/6.1/RMHelp/WS2d2a17056e219198-31ba356e14172797744-8000.html
I believe the only way to do what you are asking would be to supply the 'custom content' during initial authoring of the PDF with Adobe LiveCycle ES for instance.
(How this is accomplished may be similar to how it works for dynamic XFA content where the page contains some content that non-XFA compliant readers can fallback on to display instead of just erring out.)
But I think the only way to add such content to an existing PDF using non-Adobe software would involve violating the Rights Managment policy the author intended, which is not something you want to do.
I am trying to print a section of an existing pdf to a new pdf. The original is searchable and selectable but the new pdf cannot do either. I am using "adobe acrobat reader DC" and print via "Microsoft Print to PDF". Unsure if there is any other relevant information.
After searching for a period of time I could not find an answer that allows for direct PDF to PDF print.
I did find a workaround however.
I downloaded a free software called PrimoPDF. Once installed, PrimoPDF becomes a printer option within Adobe acrobat reader. I then selected my desired pages and printed to PrimoPDf instead of Microsoft Print to PDF. This Generated a .ps file. I then imported the .ps file into PrimoPDF application and was able to generate a .pdf from that. The newly generated pdf was searchable and selectable and exactly what I needed.
Hopefully someone else finds this useful in the future.
Generally refrying (printing to PostScript then converting back to PDF) is a bad idea. The reason that Microsoft Print to PDF created a file that wasn't searchable is because when Adobe Reader detects that the printer it is targeting isn't capable of rendering the PDF correctly because of any number of reasons, like it doesn't have the right fonts for example, it will render the PDF itself and send an image to the printer. A simpler PDF probably would have worked just fine.
You are much better off getting a tool that will simply allow you to extract the pages you need to a new file rather than printing.
Well, after spending quite some time playing with this, I think I may have found a solution soon after I posted the question. Bit embarrassing but hey, it seems to work now.
I don't want to delete the question yet, in case someone wants the details. Basically, I tried again point (c) but in the XML I put back I used an embedded image. So, it seems I can change the XFA template master page using iText. More testing to follow ...
=========================
The problem: Apply watermark to a PDF XFA (dynamic or not). At the end the PDF should still be an XFA and should have all its security settings intact. I don't have control over the PDFs coming in.
The question: Can I use iText 5 to do that? If yes, is it via PdfStamper.getUnderContent() or via XfaForm.setXfa() or something else ? The first 2 didn't work for me yet.
I wonder if it's some XFA detail that I am missing (i.e. when I try to replace the XML), not sure how the XFA is actually protected from changes. Do I need to generate some UUID, encrypt some things, something about signatures ...
Btw, if I take the PDF generated by iText after replacing the XML, then open and save in LC, the watermark shows
thanks,
Cristian
========================
Anyway, that's the short version of my question. If you think you can help and/or are interested in more details ...
I know this or similar questions came up before but what I have tried so far didn't work for me. I also admit I am not a IText, XFA or PDF Standard expert. I browsed a number of forums posts, the Itext book, browsed the specs, no luck yet.
The PDF input has no regular usage rights, no security. When opened in Acrobat it will show the restrictions on Changing Document/Document Assembly/Adding templates but I have a feeling all XFAs have that. Nothing comes back from the following ...
System.out.println(" permissions " + reader.getPermissions());
System.out.println(" usage rights " + reader.hasUsageRights());
System.out.println(" viewer pref" + reader.getSimpleViewerPreferences());
Here are some of the things I have been through:
a) doing in it LC (https://forums.adobe.com/thread/496558)
This works. If I try to place an image on the master page, then it shows as watermark on all pages when saved from LC.
b) trying to write under using iText (https://sourceforge.net/p/itext/mailman/message/17225398/)
I found a post from '07 suggesting using pdfStamper.getUnderContent(). The thread does not seem to conclude if it did work eventually for the person asking
For me, the code works for a simple PDF, but not for XFA
PdfContentByte under = pdfStamper.getUnderContent(1);
under.beginText();
BaseFont FONT = BaseFont.createFont("c:/windows/fonts/times.ttf", BaseFont.WINANSI, BaseFont.EMBEDDED);
under.setFontAndSize(FONT, 40);
under.showTextAligned(Element.ALIGN_CENTER, "TEST_TEXT", 200, 600, 45);
under.endText();
c) generate the XML and replace it using iText (Some pdf file watermark does not show using iText)
After reading the post above and section 8.6 from itext in action, it seemed this is the correct path, so:
I create a simple XFA using LiveCycle
Save as xfa1.pdf and extract xml (using iText) to xfa1.xml
in LC add an image to the masterpage and save as xfa2.pdf
open xfa2.pdf and notice the watermark is present
extract XML from xfa2 to xfa2.xml and compare to xfa1.xml - notice the image element
either place the image element in original XML or use xfa2.xml and replace the XFA in original xfa1.pdf using iText, let's call it xfa3_itext;
Relevant code:
XfaForm xfa = new XfaForm(reader);
DocumentBuilderFactory fact = DocumentBuilderFactory.newInstance();
fact.setNamespaceAware(true);
DocumentBuilder db = fact.newDocumentBuilder();
Document doc = db.parse(new FileInputStream(xml));
xfa.setDomDocument(doc);
xfa.setChanged(true);
XfaForm.setXfa(xfa, stamper.getReader(), stamper.getWriter());
I have tried with a sample PDF that was provided by a customer and with a simple XFA form created in LiveCycle Designer, no luck. If I open xfa3_itext in LiveCycle it does the watermark and if I save it again from LiveCycle as dynamic XFA PDF, the new PDF shows the watermark.
phew, that is a long post ... sorry.
thanks for reading and for any feedback
We have a requirement to convert XFA Form (Adobe LiveCycle Form) to PDF/A-1B.
We're attempting to use iText 5.4.0 to parse the PDF, populate the XFA fields and then save the modified PDF back out.
All the examples I can find with iText talk about populating XFA fields into PDF.
Can I convert an XFA form ( static / dynamic and generated using LiveCycle) to PDFA 1b directly?
As need PDFA for sure and can’t live with plain PDFs. So as workaround we were thinking about converting the PDF to PDFA. Is that the right approach or we are missing something here.
You can also use Adobe LiveCycle Forms Server or PDF Generator for this purpose. It supports conversion of XFA-based forms (either static or dynamic) to either PDF/A-1b or PDF/A-1a.
Yes, you can convert XFA forms to PDF/A using iText in combination with XFA Worker. However, XFA Worker is a closed source product. So you need to be an iText customer if you want to achieve what you want.
Note that we've done exactly what you need in a project for the Ministry of Justice in Belgium. I've written the following blog post about this project: : http://lowagie.com/xfabpm
Disclaimer: I'm the CEO of the iText Software Group. This answer isn't meant to promote the product. It's a genuine answer to this question.
I was also looking for the same problem and I reached an easy solution, you can try this out:
Drag and drop it xfa format PDF into chrome, it will open in chrome browser.
You will find three options at right corner:
Rotate clockwise
Download
Print
Click on "Print"
Change destination "save as PDF" and save.
Saved PDF is flat PDF(Acroform) and can be edited easily
I'm a converting my Word document into pdf using the built-in microsoft office converter (save as--> pdf).
I want my pdf to be protected (users cannot copy text from it). i can't seem to find any options for this when converting to pdf.
Any hint?
Thanks.
Found it, Can be done with Adobe Acrobat Professional, not the Acrobat Reader.
PDF, or portable document format, forms were created by Adobe as a form of universal file format. Adobe Acrobat Reader, which allows you to view PDF files, is available for free download. Unfortunately, to manipulate documents and perform functions like changing security settings, you must have the full Adobe Acrobat software. With it, you can create secure PDFs, but you can also change security settings on PDF forms.
You can use export to PDF feature in LibreOffice, just set permission password and then disable Content Copying.