p:media getting rendered differently across browsers - pdf

I'm on PF 6.2 and trying to use the p:media component for displaying PDFs.
(I shifted from using pe:documentViewer only because it currently doesn't display digital signatures, since PDF.js doesn't support that feature in the first place).
However, I observe that the look-n-feel of the rendered PDF viewer is different across browsers.
My usage:
<p:media id="pdfVw" height="600" width="800" value="#{viewerController4.pdfDocumentStream}" player="pdf" cache="false">
<f:param name="id" value="#{viewerController4.currentDocId}" />
</p:media>
In the backing bean:
public StreamedContent getPdfDocumentStream() throws IOException {
FacesContext context = FacesContext.getCurrentInstance();
if (context.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE) {
return new DefaultStreamedContent();
} else {
String id = context.getExternalContext().getRequestParameterMap().get("id");
Doc doc = pdfDocMap.get(id);
return new DefaultStreamedContent(new FileInputStream(new File(doc.getDocPath())), "application/pdf", doc.getDocName());
}
}
About the look-n-feel...for example, in Chrome:
* no thumbnail strip for the pages!
* that string "Microsoft word-Dokument1" is coming from the PDF's "title" attribute (I wish I could suppress displaying it !)
In Firefox:
* the thumbnail strip is there
* the digital signature is gone!
* that title string is not there (for me, it's a plus)
* the menus are also completely different compared to Chrome
(In IE, it's even more different)
My client's target browser is Chrome.
If I could somehow suppress that title and start showing the thumbnail strip in Chrome, that would solve my purpose entirely. Any advice?

I came to know....to expect the thumbnail strip in Chrome would be a wrong expectation, while using p:media. This is because, while with p:media, Chrome would use its own PDF viewer and not Adobe's (so, there may not be all Adobe like features available). More here:
https://community.adobe.com/t5/acrobat/adobe-acrobat-features-not-showing-up-in-chrome/td-p/10480323?page=1
On the topic of the title getting displayed on the toolbar, I still couldn't find any solution to easily suppress or soft-modify it, other than editing the title metadata of the PDF itself.
Also, came across this nice document that lists the various <f:param> that can be passed to configure viewers :)
https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/pdf_open_parameters.pdf

Related

Tagged annotation link not reading properly in PDF with JAWS?

What is the problem?
By using PDFBOX I tried to tag a link which contains annotation. The PDF creating sample code is here. I tagged a nested paragraph link by using PDFBOX. The newly created tagged PDF is passing the Adobe checker.
What I observed?
After tagging pdf I tried to read it using JAWS. But unfortunately the jaws is not reading links in both "entire document mode" and "read currently visible page" mode. Then I jumped to StructTree Root and compared with adobe created tagged PDF vs our tagged PDF. The ParentTree(NUMTree) is not matching with adobe tagged pdf.
Tagged by me
Tagged by Adobe
What I Tried?
I tried to replicate the adobe numtree in my pdf. Almost I am able to create same but except one object.
Above image left side is adobe tagged and right side is created by me. I didn't understand the adobe why it is created entire structtree under this (142 O R) object? I am adding annotation object to TumTree by using this code
private void addWidgetContent(PDObjectReference objectReference, PDStructureElement fieldElem, String type, int pageIndex) {
COSDictionary annotDict = new COSDictionary();
COSArray annotArray = new COSArray();
annotArray.add(COSInteger.get(currentMCID));
annotArray.add(objectReference);
annotDict.setItem(COSName.K, annotArray);
annotDict.setString(COSName.LANG, "EN-US");
annotDict.setItem(COSName.P, currentElem.getCOSObject());
annotDict.setItem(COSName.PG, pages.get(pageIndex).getCOSObject());
annotDict.setName(COSName.S, type);
annotDicts.add(annotDict);
setNextMarkedContentDictionary();
numDictionaries.add(annotDict);
fieldElem.appendKid(objectReference);
currentElem.appendKid(fieldElem);
}
And one more bug I saw in Adobe preflight is
How can I fix these bugs and what is the correct way of tagging link annotation to be read by JAWS? Please help me .......
I got some update to share. Now I crated parent tree root without having any bugs. Here the file tagged pdf file.
Still this tagged pdf not reading links. Why ?????????

How to get rid of unwanted extra pages when converting a goole document to pdf via google-apps-script?

I have an old script that (among other things) converts a google document to pdf.
It used to work ok, but now two extra blank pages appear in the pdf version of the file.
I just discovered that this problem affects also the "download as pdf" menu option in google documents. There is a number of workarounds in that case, but I need a workaround for google-apps-script.
In this post the solution to a similar problem seems to involve a fine tuning of the page size. I tried something like that, but it does not trivially apply.
I also tried some other (kind of random) variations for the page size and margins, but to no avail.
Below I'm pasting a minimal working example. It should create a document file "test" and its pdf version "test.pdf" in your main drive folder.
Any help getting rid of the two extra pages is greatly appreciated.
Thanks
function myFunction() {
// this function
// - creates a google document "test",
// - writes "this is a test" inside it
// - saves and closes the document
// - creates a pdf version of the document, called "test.pdf"
//
// the conversion is ok, except two extra blank pages appear in the pdf version.
// create google document
var doc = DocumentApp.create('test');
var docFile = DriveApp.getFileById( doc.getId() );
// set margins (I need landscape layout)
// this is an attempt to a solution, inspired by https://stackoverflow.com/questions/18426817/extra-blank-page-when-converting-html-to-pdf
var body = doc.getBody();
body.setPageHeight(595.2).setPageWidth(841.8);
var mrg = 40; // in points
body.setMarginTop(mrg).setMarginBottom(mrg);
body.setMarginLeft(mrg).setMarginRight(mrg);
// write something
body.appendParagraph('this is a test').setHeading(DocumentApp.ParagraphHeading.HEADING2).setAlignment(DocumentApp.HorizontalAlignment.CENTER);
// save and close file
doc.saveAndClose();
// convert file to pdf
var docblob = docFile.getAs('application/pdf');
// set pdf name
docblob.setName("test.pdf");
// save pdf file
var file = DriveApp.createFile(docblob);
}
I found the source of the problem and a solution in this post on the google product forum, dating 8 months back.
The extra pages appear in the pdf if the option in view -> print layout is not checked.
I did some further tests, with my accounts and my colleagues'.
The results are consistent:
when view -> print layout is not checked two extra pages appear in the pdf version of the document
when view -> print layout is checked the pdf version of the document has the expected number of pages.
this setting affects also the documentApp services in Google Apps Script. That is: the above script produces the expected pdf version only if the "view->print layout" option in Google Documents is checked.
I do not see how this behaviour could be a "feature", so I think it's a bug. By the way "print layout" does not seem to have any visible effect on my documents (other than messing up the pdf version). I'm surprised that after 8 months the bug is still out there.
Number 3 above surprised me, because I did not think that an option set manually in a (any) google document would affect my scripts.
I'm currently looking for a way of setting the "print layout" option from inside the script. So far I had no luck with that.

The font properties looks similar but looks and feel is different in two pdf documents

I have a PDF template document given by my client as a reference. My application has to create it. When i compared the PDF generated by my application and the template given by the client i could see the look and feel are slightly different.I opened it in Adobe acrobat pro dc, i could still see the font properties are same. Please see the link below to see the PDFs header i created which has the above mentioned issue.
Please see the image:
I have the font properties defined in xml as below.This will be unmarshalled later.
<font name="Arial Narrow" id="blackBold" fsize="12" type="bold" rgb="0,0,0"/>
I have the different font type defined in a map like below,
fontAndAlignmentMap.put("bold", 1);
//Internally this will be resolved to-->com.itextpdf.text.Font.BOLD = 1;
The itext Font will be created from an unmarshalled xml font object as below:
FontFactory.registerDirectories();
com.itextpdf.text.Font itextFont =
FontFactory.getFont(sbcFont.getName(), sbcFont.getFsize(), fontAndAlignmentMap.get(sbcFont.getType()), new BaseColor(r,g,b));
The 10 page pdf document have different fonts and formatting.The Statically defined fonts are unmarshalled and loaded into the itextFontMap as shown below.
itextFontMap.put(sbcFont.getId(), itextFont);
sbcFont.getId() are "blackBold","blackRegular" etc.Depends on the use the appropriate font will be pulled from this map.
Phrase pSbc = new Phrase("Summary of Benefits and Coverage:",
SBCMappingSingletonBuilder.itextFontMap.get("blackBold"));`
Phrase pSbcDesc = new Phrase(
" What this Plan Covers & What You Pay For Covered Services",
SBCMappingSingletonBuilder.itextFontMap.get("blackRegular"));
When i printed the family name of the com.itextpdf.text.Font object.
blackBold.getFamilyname() :Arial Narrow
blackRegular.getFamilyname() :Arial Narrow
This is what printed from the code.
sbcFont.getName() :Arial Narrow Bold
sbcFont.getName() :Arial Narrow
Phrases added to a PdfPCell; PdfPCell added to PdfPTable and then to the document.
Can any one please throw some light here.I am using java 1.6 and itextpdf-5.3.4
The sample template which i am referring please click
here
The one i am tring to create similar to the template,please click
here
I opened the pdf in Adobe Acrobat Pro.The bold font look like narrow even though the font properties are showing as bold in Adobe Acrobat Pro.But when i opened the pdf in a browser,it looks good.

Grails / RenderPdf Arabic Chars

We have a grails app, in which we are using the Render Plugin to render content in .pdf. It all works fine for English, but unfortunately for Arabic (which we must render) all the charactes seem "broken". Some numbers and spaces there...
The render plugin uses IText, and I have tried the approach with:
...
def renderer = new ITextRenderer()
FontResolver resolver = renderer.getFontResolver()
renderer.getFontResolver().addFont("/usr/share/fonts/truetype/ttf-arabeyes/ae_AlArabiya.ttf", BaseFont.EMBEDDED)
...
(the font used here is just an example), but in any case, it doesn't work.
Anybody any experience with this kind of issue?
Thank you in advance!
renderer.getFontResolver.addFont(fontPath, BaseFont.IDENTITY_H, BaseFont.EMBEDDED_SUBSET);
The default encoding for fonts in iText is WinAnsiEncoding, AKA Code Page 1252. You need to specify an encoding that contains the characters you want...
Yep. Google Code produced this bit of code for the addFont you're using:
public void addFont(String path, boolean embedded)
throws DocumentException, IOException {
addFont(path, BaseFont.CP1252, embedded);
}
IDENTITY_H lets you address all the glyphs in a given font. I always recommend it, though there is a small drawback. Using IDENTITY_H forces the font to be an embedded subset in iText, no way around it.

Adobe Flex 3: can I get TTF/OTF system fonts and embed at runtime?

Adobe Flex 3: can I get TTF/OTF system fonts and embed at runtime?
Hi,
I'm a Stack Overflow noob so please go easy on me.
I've searched all day and found dozens of tutorial/examples on how to use [Embed] metadata or
Flash SWF files but they all tell me to either use a path in the source attrib or a text string in the systemFont attrib. What I want to do is; at runtime get all installed fonts on a given machine, determine which are TTF/OTF, embed them all and offer them in a comboBox. Something along these lines;
public function embedFonts():void{
try{
//get all device and embedded fonts
availableFonts = Font.enumerateFonts(true);
availableFonts.sortOn("fontName", Array.CASEINSENSITIVE);
for each(var thisFont:Font in availableFonts)
{
[Embed(systemFont=thisFont.fontName,
fontName=thisFont.fontName,
mimeType='application/x-font')]
//this bit need to create a unique variable name on each loop
var thisfont:Class;
}
}
catch(error:Error){
//if cant embed it's likely not to be TTF or OTF
//so move on to the next font.
}
}
Does anyone know a way?
Many, many thanks
You can't embed fonts at runtime.
And what would be the point?
Your swf runs on my machine, enumerates fonts on my machine, then embeds them
and offer them back to me? They are installed, use them directly, no need to embed.
So not only that is it not possible, but probably nobody will ever implement such a feature.