How to check whether PDF file is password protected or not programmatically in Flutter? - flutter

I want to check whether the local PDF file selected by the user is password protected or not in a flutter.
I have chosen a PDF file path by FilePicker and fetched it in the code below.
File file = File(path);
Now I want to check whether my selected PDF file is password protected or not.

Related

TYPO3 BE file upload validation

I want validate file upload in TYPO3-Backend. When a user uploads a file (image) there should be a validation, that fields like "Alternative Text" has to be filled.
I can set
$GLOBALS['TCA']['sys_file_metadata']['columns']['alternative']['config']['eval'] = 'required';
but that does not work by uploading a file but only afterwards when editing metadata.
So can i do it via hook or any other idea?

upload image to media server with chopper

I try to upload photo to media server this way
#Post(path: 'file')
#Multipart()
Future<Response<UploadPhotoResponse>> uploadPhoto(#PartFile('file') String file);
String file is file path from android storage.
and it uploads, but then i can't display it with CachedNetworkImage. Media server give me file without extension. So i must designate that i upload image with jpeg extension. Google say to me that i have to set filename some where. So content type of file will be image/jpeg. How i can do it ?

Load and save images on Flutter

I Want to let the user chose images from his gallery and add them to the app, and i want the image to be saved on the local app storage, so should i create a Database for saving the pictures or just for saving the path to those pictures (refrence)
It's up to you if you want to manage the references in a database, depending on your needs.
If you need to store plain pictures without anymore linked informations I would just go for path_provider's application Directory, as the example tells (https://pub.dev/packages/path_provider):
Directory appDocDir = await getApplicationDocumentsDirectory();
String appDocPath = appDocDir.path;
And then just use the whole directory.
If you need to store more meta data, as e.g. like count of a picture or some origin url etc. then i would go for a sqlite database storing the references and meta data in a table.

VSCODE extension - How to show file save dialog

Is it possible in existing API, to show a dialog to user to save a file at custom location ?
if you want custom path and data saving, I think the best you can do is:
vscode.window.showSaveDialog({...options}).then(fileInfos => {
// here you can use fs to handle data saving
fs.writeFileSync(fileInfos.path, yourData)
});
This will prompt the user to enter a saving location and store the user choice in the fileInfos response.
Here is the doc: https://code.visualstudio.com/api/references/vscode-api#SaveDialogOptions
Yes, your extension can use the workbench.action.files.saveAs command to bring up the save as dialog for the current file.

GWT:How to generate pdf save/open window?

I am using GWT2.4 version in my application.In this I application I have created Form using GWT control (like textbox,textaera).
I have also created preview of form.In that preview I have button of pdf generation.
Now I want to create behavior to deal with pdf link same as browsers(Mozilla/chrome).
For example in Mozilla on click of pdf link it asks for either save or open in a pop up window.
While debugging I found a jar name iText which can be used to create pdf, I want to implement browsers behavior in this also.
Please help me out.
Thanks in advance.
Read file contents into byte array.
Then do request for servlet or service, for eg. this way:
Window.Location.replace("rest/downloadPdf");
That Service should return Response with the right content type:
#Path("downloadPdf")
#GET
#Produces({"application/pdf"})
#Consumes(MediaType.TEXT_PLAIN)
public Response downloadPdf() throws Exception {
byte[] bytes = getYourPDFContents();
return Response
.ok(bytes, MediaType.APPLICATION_OCTET_STREAM)
.header("Content-Disposition", "attachment; filename=\"yourFile.pdf\"")
.build();
}
Browser will then show save as dialog.
That's example of Service, you must include Jersey library into your project to be able to use method like I've wrote above .