Updating pdf from javascript

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2008 05:50 PM
I would like to add some info onto pdf files, updating their metadata and adding a cover page for example. I'm using the iText library (http://www.lowagie.com/iText/). As far as I know, IText expects accessing the file, or an InputStream, or a byte[]. I thought this could be easily solved, but I'm not able to access the pdf file. So what are the solutions for loading pdf file from JS scripts as "document.content" is only good for text content? Therefore, the only way I see is using document.url. Unfortunately, accessing the content needs authentication, and without authentication, only the login page is returned.
Could anybody suggest a way to authenticate from within JS Script for accessing content, with simple authentication or maybe using session ticket (I need a way to save content back to document, but that's another question!) -or another way to do it?
Another side question about javascript is how to load a config file (eg an xml file present in alfresco/extension/myFile.xml). Is it possible to use the "classpath:" value (no success as of now)?
Thanks for any help,
best regards,
Stéphane
- Labels:
-
Archive

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2008 04:26 AM
I'm partially replying to myself.
To get the pdf file from within the JS script, I need to use the ticket:
tck = session.getTicket();var url = "http://localhost:8080/alfresco/" + document.downloadUrl + "?ticket=" + tck;
this time, the document is accessible.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2008 10:09 AM
I haven't found any way to update binary content through javascript API. I can access it, process it, but not write it back. There seems to be a
node.properties.content.write(content);
in Alfresco-2.1E for dealing with binary content, but will it be part of 2.9CE? if not, what solution could I chose from JS scripts to deal with binary or streams? Thanks!
Regards
Stéphane
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2008 12:08 PM
Cheers,
Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2008 06:58 AM
Try something like this:
var updatedVersion = document.transformDocument("application/pdf", tempFolder);// Check it out and update content on the working copy - "pdf" is the current versionvar workingCopy = pdf.checkout();workingCopy.properties.content.write(updatedVersion.properties.content);// Check it back inworkingCopy.checkin("Document updated", true);
Simon

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2010 04:07 AM
Thanks in Advance,
Reddy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2010 12:31 PM
Cheers,
Peter

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2010 07:14 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2010 07:46 AM
from what i understand this method solves the save and upload the pdf we wanted to change, but how to access something like an annotation?
is this even possible?
Best regards,
Pedro
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2010 02:11 PM
For that you might want to look at something like rendition services [1] (added in Alfresco 3.3), or the "embedders" forge project [2].
Cheers,
Peter
[1] http://wiki.alfresco.com/wiki/Rendition_Service
[2] http://forge.alfresco.com/projects/embedders/
